Skip to content

Instantly share code, notes, and snippets.

@obadajasm
Created April 16, 2021 12:49
Show Gist options
  • Save obadajasm/7ae0a65e17bb682b046f069618793a11 to your computer and use it in GitHub Desktop.
Save obadajasm/7ae0a65e17bb682b046f069618793a11 to your computer and use it in GitHub Desktop.
qr_example
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