Created
April 16, 2021 12:49
-
-
Save obadajasm/7ae0a65e17bb682b046f069618793a11 to your computer and use it in GitHub Desktop.
qr_example
This file contains 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:qlevar_router/qlevar_router.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp.router( | |
routeInformationParser: QRouteInformationParser(), | |
routerDelegate: QRouterDelegate( | |
AppRoutes().routes, | |
initPath: AppRoutes.productsPage, | |
), | |
); | |
} | |
} | |
class ProductsPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Center(child: Text('ProductsPage')); | |
} | |
} | |
class SingleProductPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Center(child: Text('SingleProductPage with id = ${QR.params['id']}')); | |
} | |
} | |
class AppRoutes { | |
static String productsPage = 'ProductsPage'; | |
static String singleProductPage = 'SingleProductPage'; | |
final routes = [ | |
QRoute( | |
name: productsPage, | |
path: '/products', | |
builder: () => ProductsPage(), | |
children: [ | |
QRoute( | |
path: '/:id', | |
builder: () => SingleProductPage(), | |
), | |
], | |
), | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment