Navigator.pushNamed(context, "/screenNumberTwo");
我的源代码屏幕上的build方法(我们称之为
屏幕号码
)在的生成方法之后调用
screenNumberTwo
(尽管只有2号屏幕可见)。如果我和你一起行动,我会看到这一切发生
onPressed
在里面
MaterialButton
和
onTap
在里面
InkWell
,对于带参数和不带参数的路线。
我的路线如下所示
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
onGenerateTitle: (BuildContext context) =>
Localization.of(context).appTitle,
initialRoute: "/",
routes: {
"/": (context) => FirstScreen(),
"/select_category": (context) => SecondScreen(),
},
onGenerateRoute: (routeSettings) {
print("Route: ${routeSettings.name}");
var path = routeSettings.name.split('/');
if (path[1] == 'thirdscreen') {
if (path.length == 3) {
//(... where I set paramId)
return new MaterialPageRoute(
builder: (context) => new ThirdScreen(paramId),
settings: routeSettings);
} else if (path.length == 4) {
//(... where I set paramId and param2Id)
return new MaterialPageRoute(
builder: (context) => new ThirdScreen(
paramId, param2Id,
),
settings: routeSettings);
}
},
localizationsDelegates: [
const LocalizationDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('en'),
const Locale('pl'),
]);
}
}
这不是一个功能问题,更多的是一个问题,在我的例子中,颤振是在计算屏幕上燃烧CPU,而用户无论如何都不会看到它。。。如有任何建议,请更改内容/在何处查找问题,我们将不胜感激!