它对我来说很好,所以如果可以的话,请发布一个简化的测试用例。你确定没有其他的吗
Navigator
MaterialApp
这是我用来测试的代码。
import 'package:flutter/material.dart';
class LoginPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
void _profile() {
Navigator.popAndPushNamed(context, "/Profile");
}
return new Scaffold(
appBar: new AppBar(
title: new Text('Login'),
),
drawer: new Drawer(
child: new InkWell(
onTap: _profile,
child: new Icon(Icons.navigate_next),
),
)
);
}
}
class Profile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Text('You made it!'),
),
);
}
}
void main() {
runApp(new MaterialApp(
home: new LoginPage(),
routes: <String, WidgetBuilder>
{
"/Profile": (BuildContext context) => new Profile(),
}
));
}
如果你不能找出你的版本和我的版本有什么不同,你可以尝试实现
onGenerateRoute
routes
参数到
材料应用