Flutter Android Embedding V1和V2有什么区别 [英] What is the difference between Flutter Android Embedding V1 and V2

查看:2913
本文介绍了Flutter Android Embedding V1和V2有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Flutter开发具有背景知识的插件.
最近,我在 android_alarm_manager 插件中遇到了关于 Flutter android embedding 的一些事情.

README的一部分说:

对于Flutter Android Embedding V1,必须为后台服务提供回调,以使用背景隔离注册插件.

  • Flutter android嵌入 V1或V2到底是什么?
  • 这两者之间有什么区别?

解决方案

根据文档:

为了更好地支持将Flutter添加到现有项目中的执行环境,现已弃用了旧的Android平台端包装器,该包装器在io.flutter.app.FlutterActivity处托管Flutter运行时及其相关类. io.flutter.embedding.android.FlutterActivity上的新包装及其相关类现在替换了它们.

这些类更好地支持实际情况,其中FlutterActivity不是应用程序中的第一个也是唯一的Android Activity.

嵌入式v2为后台执行(例如Firebase消息传递)提供了更好的支持.签出 changeLog ).

如果要开发插件,则应考虑从嵌入式v2开始.现有程序包已被迁移或正在迁移.

I am working on a plugin for Flutter with background stuff.
Recently, I faced somethings about Flutter android embedding in the android_alarm_manager plugin.

A part of the README says:

For the Flutter Android Embedding V1, the background service must be provided a callback to register plugins with the background isolate.

  • What exactly is Flutter android embedding V1 or V2?
  • What are the differences between these two?

解决方案

According to docs:

In order to better support the execution environments of adding Flutter to an existing project, the old Android platform-side wrappers hosting the Flutter runtime at io.flutter.app.FlutterActivity and their associated classes are now deprecated. New wrappers at io.flutter.embedding.android.FlutterActivity and associated classes now replace them.

Those classes better support real world scenarios where the FlutterActivity isn't the first and only Android Activity in an application.

The embedded v2 provides better support for things like background execution (firebase messaging for instance. Checkout the changeLog).

If you are developing a plugin, you should consider starting with embedded v2. Existing packages are already migrated or migrating.

这篇关于Flutter Android Embedding V1和V2有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆