-
Notifications
You must be signed in to change notification settings - Fork 937
Description
how listen Javascriptinterface function name from flutter here is myCode.
Webviewmanager.java
@JavascriptInterface
public void loginFacebook() {
src.main.java.com.flutter_webview_plugin.FlutterWebviewPlugin.channel.invokeMethod("fbLogin" , null);
}
I want to know how listen that function from flutter.
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@OverRide
State createState() {
// TODO: implement createState
return _Main();
}
}
class _Main extends State {
final _webviewPlugin = FlutterWebviewPlugin();
StreamSubscription _onDestroy;
@OverRide
void initState() {
super.initState();
_webviewPlugin.onUrlChanged.listen((String url) {
print(url);
});
_webviewPlugin.onDestroy.listen((_) => SystemNavigator.pop());
}
void dispose(){
_webviewPlugin.dispose();
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
theme: new ThemeData(primaryColor: Colors.deepOrange),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: PreferredSize(
child: Container(),
preferredSize: Size.fromHeight(0.0),
),
body: WebviewScaffold(
url: selectUrl,
appCacheEnabled: true,
withLocalStorage: true,
withJavascript: true,
supportMultipleWindows: true,
hidden: true,
withZoom: true,
),
),
);
}
}