-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How listen javascript funciton name from flutter #404
Comments
I solved this problem with dynamic channel name for Android and iOS #523 . Hope it's helpful |
I don't clear.I will explaing again.
This my dart file
I want if i click Prohibited ads Link in webview to go new dart page. |
see my commnet again.Thanks. |
Hi @heinzan, your HTML should be using the channel name post message to communicate with flutter like this: <CHANNEL_NAME>.postMessage(); Eg: In this case, "Prohibited" is the <CHANNEL_NAME> and is the empty string. Next, in dart code, you have to declare code to listen to your channel like this:
|
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();
}
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,
),
),
);
}
}
The text was updated successfully, but these errors were encountered: