nuvigator 0.5.1 copy "nuvigator: ^0.5.1" to clipboard
nuvigator: ^0.5.1 copied to clipboard

outdated

A powerful and strongly typed routing abstraction over Flutter navigator, providing some new features and an easy way to define routers with code generation.

example/lib/main.dart

import 'package:example/samples/navigation/samples_router.dart';
import 'package:flutter/material.dart';
import 'package:nuvigator/nuvigator.dart';

import 'samples/modules/sample_one/navigation/sample_one_router.dart';

void main() => runApp(MyApp());

class TestObserver extends NavigatorObserver {
  @override
  void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
    print('didPush $route');
  }

  @override
  void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
    print('didPop $route');
  }

  @override
  void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
    print('didRemove $route');
  }

  @override
  void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
    print('didReplace $oldRoute to $newRoute');
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Nubank',
      builder: Nuvigator(
//        debug: true,
        screenType: cupertinoDialogScreenType,
        inheritableObservers: [
          () => TestObserver(),
        ],
        router: SamplesRouter(),
        initialRoute: SamplesRoutes.home,
//        initialDeepLink: Uri.parse(
//            'exapp://deepPrefix/sampleOne/screenOne/id_1234_deepLink'),
      ),
    );
  }
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final router = Router.of<SamplesRouter>(context);
    return Scaffold(
      appBar: AppBar(
        title: const Text('nuvigator Example'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          const Hero(
            child: FlutterLogo(),
            tag: 'HERO',
          ),
          FlatButton(
              child: const Text('Go to sample one with flutter navigation'),
              onPressed: () async {
                final result = await router.sampleOneRouter
                    .toScreenOne(testId: 'From Home');
                print('ScreenOneResult: $result');
              }),
          FlatButton(
            child: const Text('Go to sample one with deepLink'),
            onPressed: () async {
              final result = await router
                  .openDeepLink<String>(Uri.parse(screenOneDeepLink));
              print('ScreenOneDeepLinkResult: $result}');
            },
          ),
          FlatButton(
            child: const Text('Go to sample two with flow'),
            onPressed: () async {
              final result = await router.toSecond(testId: 'From Home');
              print('SecondRouteResult: $result');
            },
          ),
        ],
      ),
    );
  }
}
48
likes
0
pub points
49%
popularity

Publisher

verified publishernubank.dev

A powerful and strongly typed routing abstraction over Flutter navigator, providing some new features and an easy way to define routers with code generation.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

analyzer, build, build_config, code_builder, dart_style, flutter, path_to_regexp, recase, source_gen

More

Packages that depend on nuvigator