https://github.com/evandersondev/routerfy
https://github.com/evandersondev/routerfy
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/evandersondev/routerfy
- Owner: evandersondev
- License: other
- Created: 2024-12-18T10:23:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-30T12:57:25.000Z (over 1 year ago)
- Last Synced: 2024-12-30T13:59:15.309Z (over 1 year ago)
- Language: C++
- Size: 267 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
BrowserRoutes createBrowserRoutes() {
return BrowserRoutes(
children: [
Route(
path: '/',
builder: (context) => HomePage(),
),
Route(
path: '/login',
builder: (context) => LoginPage(),
),
Route(
path: '/settings',
builder: () => SettingsPage(),
children: [
Route(path: '/profile', builder: (context) => ProfilePage()),
Route(path: '/themes', builder: (context) => ThemesPage()),
]
),
]
);
}
void main() {
setPathUrlStrategy();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return RouterfyProvider(
routes: createBrowserRoutes(),
child: MaterialApp(
title: 'Routerfy Example',
initialRoute: '/',
),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State createState() => \_HomePageState();
}
class \_HomePageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
spacing: 24,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('HOME'),
TextButton(
onPressed: () {
Routerfy.of(context).push('/login');
},
child: Text('L O G I N')),
],
),
),
);
}
}
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@override
State createState() => \_SettingsPageState();
}
class \_SettingsPageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('SETTINGS'),
RouterfyOutlet(),
],
),
);
}
}