fluttercommunity / fluttercommunity/flutter_webview_plugin

How listen javascript funciton name from flutter

Open
#404 4 comments 0 reactions 0 assignees View on GitHub
waiting for feedback
Dominant language
Java
Stars
1.5k
Forks
938
PR merge metrics
No merged PRs in 30d

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,
),
),
);
}
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Webviewmanager.java and the FlutterWebviewPlugin usage in the issue, then review the WebviewScaffold and existing onUrlChanged/onDestroy APIs. Clarify the supported way to expose the loginFacebook callback to Flutter and document a complete, verifiable usage example.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, java
Domain
mobile-dev
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.