颤振导航抽屉

时间:2019-10-10 22:37:19

标签: flutter

应用程序路由无法导航到具有以下错误的路由,这可能是问题所在 按以下顺序搜索路线的生成器:

  1. 对于“ /”路由,使用“ home”属性(如果非空)。
  2. 否则,如果“ routes”表具有该路由的条目,则使用该表。
  3. 否则,将调用onGenerateRoute。对于未由“ home”和“ routes”处理的任何有效路由,它应返回非null值。
  4. 最后,如果onUnknownRoute上的所有其他操作都失败了。

很遗憾,未设置onUnknownRoute。 引发异常时,这是堆栈:

  

_WidgetsAppState._onUnknownRoute。 (软件包:flutter / src / widgets / app.dart:772:9)   _WidgetsAppState._onUnknownRoute(软件包:flutter / src / widgets / app.dart:785:6)   NavigatorState._routeNamed(包:flutter / src / widgets / navigator.dart:1625:22)   NavigatorState.pushReplacementNamed(包:flutter / src / widgets / navigator.dart:1690:35)   Navigator.pushReplacementNamed(package:flutter / src / widgets / navigator.dart:958:34)

Handler: "onTap"
Recognizer: TapGestureRecognizer#b0943
  debugOwner: GestureDetector
  state: ready
  won arena
  finalPosition: Offset(95.2, 239.2)
  finalLocalPosition: Offset(95.2, 95.4)
  sent tap down
//drawer item call
      _createDrawerItem (
                    icon: Icons.schedule,
                    text: 'Schedules',
                    onTap: () => Navigator.pushReplacementNamed(context, Routes.notification)),
                _createDrawerItem (
                    icon: Icons.notifications,
                    text: 'Notifications',
                    onTap: () => Navigator.pushReplacementNamed(context, Routes.notification)),
                _createDrawerItem (
                    icon: Icons.person,
                    text: 'Profile',
                     onTap: () => Navigator.pushReplacementNamed(context, Routes.notification)),
                _createDrawerItem (
                    icon: Icons.info,
                    text: 'About Us',
                    onTap: () => Navigator.pushReplacementNamed(context, Routes.notification)),
              ],
            ),
          ),
        );

    //the custom drawer item
    Widget _createDrawerItem({IconData icon, String text, GestureTapCallback onTap}){
      return ListTile(
        title: Row(
          children: <Widget>[
            Icon(icon),
            Padding(
                padding: EdgeInsets.only(left: 8.0),
            child: Text(text),
            )
          ],
        ),
        onTap: onTap,
      );
    }


    //class to navigate to
    import 'package:flutter/material.dart';
    import '../home.dart';

    class NotificationPage extends StatelessWidget{

      static const String routeName = '/notification/';

      @override
      Widget build(BuildContext context) {
        // TODO: implement build
        return new Scaffold(
          appBar: AppBar(
            title: Text('Notfications'),
          ),
            drawer: HomePage(),
            body: Center(
                child: Text("Notes")

     1. List item

            )
        );
      }
    }

0 个答案:

没有答案