'Flutter platform specific plugin - Reply already submitted
I am trying to call multiple methods from my platform specific plugin and I am having hard time with errors
E/MethodChannel#fuzzy_plugin( 3277): Failed to handle method call E/MethodChannel#fuzzy_plugin( 3277): java.lang.IllegalStateException: Reply already submitted
The code of a plugin is:
class FuzzyPlugin {
static const MethodChannel _channel = MethodChannel('fuzzy_plugin');
static Future<String?> get platformVersion async {
final String? version = await _channel.invokeMethod('getPlatformVersion');
return version;
}
static Future<List<String>> fuzzySystems() async {
final List<dynamic>? systems =
await _channel.invokeListMethod("getFuzzySystems");
return systems!.cast<String>();
}
static Future<bool> load(String json) async {
final bool success = await _channel.invokeMethod("load", {"json": json});
return success;
}
}
The methods called in java are
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
switch (call.method){
case "getPlatformVersion":
result.success("Android " + android.os.Build.VERSION.RELEASE);
break;
case "getFuzzySystems":
result.success(FuzzyLibraryController.getInstance().getFuzzySystems());
break;
case "load":
String json = call.argument("json");
FuzzyLibraryController.getInstance().load(json);
result.success(true);
break;
default: result.notImplemented();
}
}
and the method in which i test the plugin is in separate flutter project, android app with next statement
Future<bool> b = FuzzyPlugin.load("working json file, tested");
b.then((value) => () {
Future<List<String>> fs = FuzzyPlugin.fuzzySystems();
fs.then((result) {
print(result);
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|