MissingPluginException (MissingPluginException(No implementation found for method getTimeZoneName on channel dexterx.dev/trail))
358
example code of flutter_local_notifications
has native implement part
You can reference
https://github.com/MaikuB/flutter_local_notifications/blob/ac730a0298edd8335cde07a09a396c46cc8c9292/flutter_local_notifications/example/android/app/src/main/kotlin/com/dexterous/flutter_local_notifications_example/MainActivity.kt#L23
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "dexterx.dev/flutter_local_notifications_example").setMethodCallHandler { call, result ->
if ("drawableToUri" == call.method) {
val resourceId = [email protected](call.arguments as String, "drawable", [email protected])
result.success(resourceToUriString([email protected], resourceId))
}
if ("getAlarmUri" == call.method) {
result.success(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM).toString())
}
if ("getTimeZoneName" == call.method) {
result.success(TimeZone.getDefault().id)
}
}
}
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on December 06, 2022Comments
-
Admin over 1 year
i am using flutter local notification for scheduling, when i use an MethodChannel instance i get an exception.
the main function:
const MethodChannel platform = MethodChannel('dexterx.dev/apptrail'); void main() async { WidgetsFlutterBinding.ensureInitialized(); await _configureLocalTimeZone(); runApp(MyApp()); }
_configureLocalTimeZone function is:
Future<void> _configureLocalTimeZone() async { tz.initializeTimeZones(); final String timeZoneName = await platform.invokeMethod('getTimeZoneName'); tz.setLocalLocation(tz.getLocation(timeZoneName)); }
the Exception is:
Exception has occurred. MissingPluginException (MissingPluginException(No implementation found for method getTimeZoneName on channel dexterx.dev/trail))
-
Victor Eronmosele over 3 yearsDid you write an implementation for the method channel on the native side?
-