The Kotlin generator generates FlutterError as a Throwable, which causes it to be a checked exception in Java. In Java, however, we make it a RuntimeException subclass, so it's not a checked exception.
This causes problems when trying to use the Kotlin generator but a Java implementation, because the generated interface to implement doesn't list any thrown exceptions (since Kotlin doesn't do checked exceptions). For instance, I tried to convert url_launcher_android to the Kotlin generator, but I get
unreported exception FlutterError; must be caught or declared to be thrown
on the Java side unless I declare the the implementation to throw. But if I do that, I get
'launchUrl(String, Map<String, String>, boolean)' in 'io.flutter.plugins.urllauncher.UrlLauncher' clashes with
'launchUrl(String, Map<String, String>, boolean)' in 'io.flutter.plugins.urllauncher.UrlLauncherApi';
overridden method does not throw 'io.flutter.plugins.urllauncher.FlutterError'
I think we probably just want to make the Kotlin generator generate FlutterError as a subclass of RuntimeException rather than Throwable.
The Kotlin generator generates
FlutterErroras aThrowable, which causes it to be a checked exception in Java. In Java, however, we make it aRuntimeExceptionsubclass, so it's not a checked exception.This causes problems when trying to use the Kotlin generator but a Java implementation, because the generated interface to implement doesn't list any thrown exceptions (since Kotlin doesn't do checked exceptions). For instance, I tried to convert
url_launcher_androidto the Kotlin generator, but I geton the Java side unless I declare the the implementation to throw. But if I do that, I get
I think we probably just want to make the Kotlin generator generate
FlutterErroras a subclass ofRuntimeExceptionrather thanThrowable.