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)
            }
        }
    }
Share:
358
Admin
Author by

Admin

Updated on December 06, 2022

Comments

  • Admin
    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
      Victor Eronmosele over 3 years
      Did you write an implementation for the method channel on the native side?