karakartal En basit şekilde
bool hasError = false;
tanımlayıp
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter WebView example'),
backgroundColor: appBarColor,
),
body: hasError? Center(
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Text(
text: "Something went wrong, please try again",
),
):
WebView(
initialUrl: 'https://google.com/',
onWebResourceError: (WebResourceError error) {
print("WebresourceError occured!");
setState(() {
hasError=true;
});
},
)
);
}
Şeklnde hata durumda ekrana uyarı yazdırabilirsiniz.