Created
June 2, 2025 15:48
-
-
Save iapicca/13d4cfc16259ca35e2b14413cf269c0e to your computer and use it in GitHub Desktop.
issue_169809
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:go_router/go_router.dart'; | |
void main() => runApp(const MyApp()); | |
final _router = GoRouter( | |
routes: [ | |
GoRoute( | |
path: '/', | |
builder: (context, state) => const HomePage(), | |
routes: [ | |
GoRoute(path: 'Page', builder: (context, state) => const Page1()), | |
GoRoute(path: 'page', builder: (context, state) => const Page2()), | |
], | |
), | |
], | |
); | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(context) => MaterialApp.router(routerConfig: _router); | |
} | |
class HomePage extends StatelessWidget { | |
const HomePage({super.key}); | |
@override | |
Widget build(context) => Scaffold( | |
appBar: AppBar(title: const Text('Home')), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
ElevatedButton( | |
onPressed: () => context.go('/Page'), | |
child: const Text('Upper Case'), | |
), | |
const SizedBox(height: 40), | |
ElevatedButton( | |
onPressed: () => context.go('/page'), | |
child: const Text('Lower Case'), | |
), | |
], | |
), | |
), | |
); | |
} | |
class Page1 extends StatelessWidget { | |
const Page1({super.key}); | |
@override | |
Widget build(context) => Scaffold( | |
appBar: AppBar(title: const Text('Page')), | |
body: const Center( | |
child: FlutterLogo( | |
size: 200, | |
style: FlutterLogoStyle.stacked, | |
textColor: Colors.red, | |
), | |
), | |
); | |
} | |
class Page2 extends StatelessWidget { | |
const Page2({super.key}); | |
@override | |
Widget build(context) => Scaffold( | |
appBar: AppBar(title: const Text('page')), | |
body: const Center( | |
child: FlutterLogo( | |
size: 200, | |
style: FlutterLogoStyle.stacked, | |
textColor: Colors.green, | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment