fast_nav 0.0.2 copy "fast_nav: ^0.0.2" to clipboard
fast_nav: ^0.0.2 copied to clipboard

outdated

Navigate without context. Call navigation methods from your business logic.

example/lib/main.dart

import 'package:fast_nav/fast_nav.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: FastNav.init(GlobalKey<NavigatorState>()),
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const Page1(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Page 1')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              child: const Text('Push page 2'),
              onPressed: () => FastNav.push(const Page2()),
            ),
            ElevatedButton(
              child: const Text('Nested navigation'),
              onPressed: () => FastNav.push(const NestedPage1()),
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Page 2')),
      body: Center(
        child: ElevatedButton(
          child: const Text('Pop page 2'),
          onPressed: () => FastNav.pop(),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return NestedNavigator(
      navigatorKey: GlobalKey<NavigatorState>(),
      name: 'nested',
      home: Scaffold(
        appBar: AppBar(title: const Text('Nested Page 1')),
        body: Center(
          child: ElevatedButton(
            child: const Text('Push nested page'),
            onPressed: () =>
                FastNav.push(const NestedPage2(), navigatorName: 'nested'),
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Nested Page 2')),
      body: Center(
        child: ElevatedButton(
          child: const Text('Pop nested page 2'),
          onPressed: () => FastNav.pop(navigatorName: 'nested'),
        ),
      ),
    );
  }
}
0
likes
0
pub points
26%
popularity

Publisher

verified publisherrexios.dev

Navigate without context. Call navigation methods from your business logic.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on fast_nav