flutter 路由实践
实践工程中的总结:
1 flutter的路由有点类似于android的activity路由,在android中,activity的跳转需要在manifest.xml文件中注册才可以使用,flutter需要将widget(最好是Scaffold,Scaffold类似于android的activity)返回给router来进行路由。
2 dart创建对象可以直接调用类的构造函数创建,类似于:
void main() {
//runApp(MyApp());
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
3 To return an empty space that causes the building widget to fill available room, return “Container()”. To return an empty space that takes as little room as possible, return "Container(width: 0.0, height: 0.0)
这种报错目前实践是由于没有返回对应的widget,没有return。
4 函数做作为参数直接传递到构造函数在flutter中很常见,类似于
5 MaterialPageRoute为路由界面跳转动画针对不同的平台做了适配。
6 flutter的路由跳转是通过 Navigator.push和Navigator.pop来实现的。