flutter_router 1.0.3 flutter_router: ^1.0.3 copied to clipboard
Flutter routing library that adds flexible routing options like parameters and clear route definitions
import 'package:flutter/material.dart';
import 'package:flutter_router/flutter_router.dart';
void main() => runApp(MaterialApp(
onGenerateRoute: Router({
'/accounts/{id}': (context, match) => Account(match.parameters['id']),
'/': (context, match) => Index(),
}).get,
));
class Account extends StatelessWidget {
final String id;
Account(this.id);
@override
Widget build(BuildContext context) {
return Scaffold(body: Center(child: Text(this.id)));
}
}
class Index extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(body: Center(child: Text('Index')));
}
}