当我在 flutter 应用程序中使用嵌套的 Navigators 时,我正在尝试更新 Web URL。
/具有一个导航到该/sub路线的FlatButton的默认路线。然后在_generateSubRoute->/second
这是我的例子:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
routes: {
// When navigating to the "/" route, build the FirstScreen widget
'/': (context) => Scaffold(
body: FlatButton(
onPressed: () {
Navigator.of(context).pushNamed('/sub');
},
child: Text(
"Go to sub",
),
),
),
// When navigating to the "/second" route, build the SecondScreen widget. …Run Code Online (Sandbox Code Playgroud)