应用程序路由无法导航到具有以下错误的路由,这可能是问题所在 按以下顺序搜索路线的生成器:
很遗憾,未设置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
)
);
}
}