Flutter学习中遇见的各种坑-持续更新

  1. 命名路由问题
    注册路由:
    code1: routes: {
    "new_route":(context) => NewRoute()
    }

启动路由:
code2: Navigator.pushNamed(context, "new_route");

抛出异常:
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'MaterialPageRoute' is not a subtype of type 'Route'

解决问题:
code2修改为:Navigator.pushNamed(context, "new_route");

你可能感兴趣的:(Flutter学习中遇见的各种坑-持续更新)