build method Null safety
- BuildContext context
override
It creates a row of buttons that allow the user to go back to the previous page, reload the current page, or go back to the previous page.
Args: context (BuildContext): The current BuildContext.
Returns: A widget that is a Padding widget with a Row widget inside.
Implementation
@override
Widget build(BuildContext context) {
return FutureBuilder<WebViewController>(
future: _webViewControllerFuture,
builder:
(BuildContext context, AsyncSnapshot<WebViewController> snapshot) {
final bool webViewReady =
snapshot.connectionState == ConnectionState.done;
final WebViewController? controller = snapshot.data;
return Padding(
padding: EdgeInsets.only(top: 10, bottom: 5, left: 10, right: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Flexible(
child: Row(
children: [
IconButton(
icon: const Icon(
Icons.arrow_back_ios,
color: Colors.white,
size: 30,
),
onPressed: !webViewReady
? null
: () async {
if (await controller!.canGoBack()) {
await controller.goBack();
} else {
Navigator.of(context).pop();
return;
}
},
),
TextButton(
child: Text('Volver'),
style: TextButton.styleFrom(
primary: Colors.white,
textStyle: TextStyle(fontSize: 22, color: Colors.white),
),
onPressed: !webViewReady
? null
: () async {
if (await controller!.canGoBack()) {
await controller.goBack();
} else {
Navigator.of(context).pop();
return;
}
},
)
],
)),
Flexible(
child: Row(
children: [
TextButton(
child: Text('Actualizar'),
style: TextButton.styleFrom(
primary: Colors.white,
textStyle: TextStyle(fontSize: 22, color: Colors.white),
),
onPressed: !webViewReady
? null
: () {
controller!.reload();
},
),
IconButton(
icon: const Icon(
Icons.replay,
color: Colors.white,
size: 30,
),
onPressed: !webViewReady
? null
: () {
controller!.reload();
},
),
],
)),
],
),
);
},
);
}