stack_router 1.0.0 copy "stack_router: ^1.0.0" to clipboard
stack_router: ^1.0.0 copied to clipboard

outdated

A stack-based routing library using an [IndexedStack](https://api.flutter.dev/flutter/widgets/IndexedStack-class.html) to route between different widgets. A stack-based routing library using an Indexe [...]

Stack router #

A stack-based routing library using an IndexedStack to route between different widgets. Includes its own Scaffold, App Bar and Snack bar implementation.

Basic demo gif.

Usage #

import 'package:stack_router/stack_router.dart';

class ExampleStackRoutes {
  static const String firstRoute = 'firstRoute';
  static const String secondRoute = 'secondRoute';
}

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      child: StackRouter(
        initialRoute: ExampleStackRoutes.firstRoute,
        builder: (router) {
          return [
            StackRoute(
              route: ExampleStackRoutes.firstRoute,
              child: Center(
                child: ElevatedButton(
                  onPressed: () {
                    router.pushRoute(ExampleStackRoutes.secondRoute);
                  },
                  child: const Text(
                    "Go to second route",
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
            ),
            StackRoute(
              route: ExampleStackRoutes.secondRoute,
              child: StackRouterScaffold(
                appBar: const StackRouterAppBar(
                  title: Text("I'm a Title", style: TextStyle(fontSize: 24)),
                ),
                child: Expanded(
                  child: Container(
                    color: Colors.blue,
                    alignment: Alignment.center,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        const Text(
                          "I'm the second route",
                          style: TextStyle(
                            color: Colors.white,
                          ),
                        ),
                        const Padding(padding: EdgeInsets.only(top: 16)),
                        ElevatedButton(
                          style: ButtonStyle(
                            backgroundColor:
                                MaterialStateProperty.all(Colors.white),
                          ),
                          onPressed: () {
                            router.showSnackBar(
                              snackBar: const StackRouterSnackBar(
                                title: Text(
                                  "I'm a snackbar!",
                                  style: TextStyle(color: Colors.white),
                                ),
                              ),
                            );
                          },
                          child: const Text(
                            "Show snack bar",
                            style: TextStyle(color: Colors.black),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ];
        },
      ),
    );
  }
}

To see it in action, try running the example.

3
likes
0
pub points
42%
popularity

Publisher

unverified uploader

A stack-based routing library using an [IndexedStack](https://api.flutter.dev/flutter/widgets/IndexedStack-class.html) to route between different widgets. A stack-based routing library using an IndexedStack to route between different widgets.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on stack_router