Android到Flutter过度如丝般顺滑(二)
16lz
2021-01-23
接上篇Android开发与Flutter开发的对应功能:
上篇基础地址如下:
https://blog.csdn.net/xueaoandroid/article/details/96204170
Intents
在Android中,Intents主要有两种使用创景:在Activity之间切换,以及调用外部组件,Flutter不具有Intents的概念,但如果需要的话,Flutter可以通过Native整合来触发Intents;
要在Flutter中切换屏幕,您可以访问路由以绘制新的widget,管理多个屏幕有两个核心概念和类:Route和Navigator,Route是应用程序的“屏幕”或“页面”的抽象(可以认为是activity),Navigator是管理Route的widget,Navigator可以通过push和pop route以实现页面的切换;
和Android相似,您可以在AndroidManifest.xml中声明您的Activities,在Flutter中,您可以将具有指定Route的Map传递到顶层MaterialApp实例;
void main() { runApp(new MaterialApp( home: new MyAppHome(), // becomes the route named '/' routes: <String, WidgetBuilder> { '/a': (BuildContext context) => new MyPage(title: 'page A'), '/b': (BuildContext context) => new MyPage(title: 'page B'), '/c': (BuildContext context) => new MyPage(title: 'page C'), }, ));}
然后,您可以通过Navigator来切换到命名路由的页面
Navigator.of(context).pushNamed('/b');
Intents的另一个用途是调用外部组件,如Camera或File Picker,为此,您需要和native集成(或现有的库)
更多相关文章
- Android 图片显示与屏幕适配的问题
- Android 禁止屏幕旋转 & 旋转屏幕时保持Activity内容
- android videoview视频铺满屏幕
- android 手势屏幕平移图片转换效果(也可以平移文本)
- Android 如何更换屏幕上锁界面背景图片
- Android之自定义Dialog屏幕旋转时自动关闭解决方法
- weex最新实践,android集成,vue写三端统一的页面