Invoke Flutter (Dart) code from native Android home screen widget

后端 未结 4 1800
心在旅途
心在旅途 2020-12-14 19:15

I added a native Android home screen widget to my Flutter application.

In my AppWidgetProvider implementation, I\'d like to call dart code in my o

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 19:32

    First, please ensure that you are invoking FlutterMain.startInitialization() and then FlutterMain.ensureInitializationComplete() before attempting to execute any Dart code. These calls are necessary to bootstrap Flutter.

    Second, can you try this same goal using the new experimental Android embedding?

    Here is a guide for executing Dart code using the new embedding: https://github.com/flutter/flutter/wiki/Experimental:-Reuse-FlutterEngine-across-screens

    If your code still doesn't work as expected with the new Android embedding then it should be easier to debug what the problem is. Please post back with success, or any new error information.

提交回复
热议问题