Android到Flutter过度如丝般顺滑(二)

接上篇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集成(或现有的库)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值