iam trying to open a flutter screen from native android
so iam trying to use MethodChannel for returning data to dart then invoke method that's gonna navigate me to the current screen
but my code is not working
this is my code
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
String channelName = "app_channel";
MethodChannel methodChannel = new MethodChannel(flutterEngine.getDartExecutor(), channelName);
methodChannel.invokeMethod("openCaller", false, new MethodChannel.Result() {
@Override
public void success(@Nullable Object result) {
Log.i("fromInvoke","success" + result.toString());
}
@Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.i("fromInvoke","failed" + errorMessage);
}
@Override
public void notImplemented() {
Log.i("fromInvoke","not implemented");
}
});
}
}
static const platform =
const MethodChannel('app_channel');
@override
void initState() {
super.initState();
platform.setMethodCallHandler(invokedMethods);
}
and this is a global function
Future<dynamic> invokedMethods(MethodCall methodCall) async {
switch (methodCall.method) {
case "openCaller":
print("arrived to open caller");
// Navigator.pushNamed(context, "/ring");
}
}