bloc_router_generator 0.0.4 copy "bloc_router_generator: ^0.0.4" to clipboard
bloc_router_generator: ^0.0.4 copied to clipboard

discontinued
outdated

Bloc Route Generator.

example/lib/main.dart

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 {
  const LoginScreen({Key? key}) : super(key: key);

  @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 {
  const 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'),
      ),
    );
  }
}