bloc_router_generator 0.0.6 bloc_router_generator: ^0.0.6 copied to clipboard
Bloc Route Generator.
import 'package:flutter/material.dart';
import 'app_routes.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: AppRoutesBuilder.getRoutes(),
initialRoute: AppRoutesBuilder.loginScreenRoute,
);
}
}
class LoginScreen extends StatelessWidget {
LoginScreen({Key? key}) : super(key: key);
String test = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Example'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.pushNamedAndRemoveUntil(
context, AppRoutesBuilder.loginScreenRoute, (route) => false);
},
child: const Text('Login'),
),
),
);
}
}
class HomeScreen extends StatelessWidget {
HomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Example'),
),
body: const Center(
child: Text('Home'),
),
);
}
}