I'm trying to update an old flutter project. But i'm having some problems with the flutter_webview_plugin, so i want to migrate to webview_flutter. The problem i have is that i don't know how to adapt the code so it can do the same.
Here is the flutter_webview_plugin code, the bold lines are the ones i need to change.
void initState() {
super.initState();
final flutterWebviewPlugin = flutterWebviewPlugin(); //Need to change
flutterWebviewPlugin.onUrlChanged.listen((String url) {//Need to change
if (url.contains("https://www.laplata.com.py/")) {
final urlResult = Uri.parse(url);
flutterWebviewPlugin.close();
Navigator.of(context).pushReplacementNamed('pay', arguments: urlResult.queryParameters);
}
});
}
Widget build(BuildContext context) {
final urlPagopar = ModalRoute.of(context)?.settings.arguments;
final size = MediaQuery.of(context).size;
if ( urlPagopar != null ) {
return SafeArea(
child: WebviewScaffold( //Need to change
hidden: true,
initialChild: Center(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 50),
decoration: const BoxDecoration(
image: DecorationImage( image: AssetImage('assets/loading2.gif') )
)
)
),
url: urlPagopar as String,
),
);
}
else {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverPersistentHeader(
floating: true,
pinned: true,
delegate: SliverCustomHeaderDelegate(
minheight: size.height * 0.15,
maxheight: size.height * 0.15,
child: _cabecera()
)
),
SliverList(
delegate: SliverChildListDelegate([
SizedBox(
height: size.height * 0.85,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Spacer(),
Container( padding: const EdgeInsets.symmetric(horizontal: 20), height: 300, child: SvgPicture.asset( 'assets/error.svg')),
const SizedBox(height: 20),
const Text("UPS!!!... Ocurrió un error inesperado", style: TextStyle(fontFamily: "Montserrat", fontWeight: FontWeight.bold, fontSize: 18)),
const Spacer(),
const Text("Vuelva a intentarlo o comuniquese con nuestro contact center", textAlign: TextAlign.center, style: TextStyle(fontFamily: "Montserrat", fontSize: 18)),
const SizedBox(height: 20)
],
),
),
])
)
],
)
);
}
}