go_navigator 1.0.1 copy "go_navigator: ^1.0.1" to clipboard
go_navigator: ^1.0.1 copied to clipboard

A comprehensive Flutter Navigation System that provides a set of utilities for managing routes, passing arguments, and navigating through your application with ease.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:go_navigator/go/go.dart';
import 'package:go_navigator/go/go_navigator.dart';


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

/// The main application widget.
class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

/// The state for the main application widget.
class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      /// The `MaterialApp` widget, which is the root of the application.
      onGenerateRoute: (RouteSettings routeSettings) => GoNavigator(
        initialRoute: const Page1(),
        routes: {
          /// Define the routes for the application using the `NavigationSystem`.
          Page1.routeName: (context, args) => const Page1(),
          Page2.routeName: (context, args) =>  Page2(title: args?['title'],),
          Page3.routeName: (context, args) => const Page3(),
          Page4.routeName: (context, args) => const Page4(),
        },
      ).generateRoute(routeSettings),
    );
  }
}

/// The first page of the application.
class Page1 extends StatelessWidget {
  static const routeName = '/d1';
  const Page1({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(' Page 1'),
      ),
      body: const Center(
        child: Text('This is  Page 1 content.'),
      ),
      floatingActionButton: FloatingActionButton(
          heroTag: 'p1_f',
          onPressed: () {
            /// Navigate to Page2 when the floating action button is pressed.
            Go(context).to(routeName: Page2.routeName,args:{
              'title':'this is very necessary data'
            } );
          },
          child: const Icon(Icons.arrow_forward_ios_rounded)),
    );
  }
}

/// The second page of the application.
class Page2 extends StatelessWidget {
  static const routeName = '/d2';
  const Page2({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title:  Text(' Page 2 - Data $title'),
      ),
      body: const Center(
        child: Text('This is  Page 2 content.'),
      ),
      floatingActionButton: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          FloatingActionButton(
            heroTag: 'p2_b',
            onPressed: () {
              /// Pop the current page to return to the previous page.
              Go(context).pop();
            },
            child: const Icon(Icons.arrow_back_ios_new_rounded),
          ),
          const SizedBox(
            width: 10,
          ),
          FloatingActionButton(
              heroTag: 'p2_f',
              onPressed: () {
                /// Navigate to Page3 when the second floating action button is pressed.
                Go(context).to(routeName: Page3.routeName);
              },
              child: const Icon(Icons.arrow_forward_ios_rounded)),
        ],
      ),
    );
  }
}

/// The third page of the application.
class Page3 extends StatelessWidget {
  static const routeName = '/d3';
  const Page3({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(' Page 3'),
      ),
      body: const Center(
        child: Text('This is  Page 3 content.'),
      ),
      floatingActionButton: FloatingActionButton(
        heroTag: 'p3_b',
        onPressed: () {
          /// Pop the current page to return to the previous page.
          Go(context).pop();
        },
        child: const Icon(Icons.arrow_back_ios_new_rounded),
      ),
    );
  }
}

/// The third page of the application.
class Page4 extends StatelessWidget {
  static const routeName = '/e4';
  const Page4({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(' Page 3'),
      ),
      body: const Center(
        child: Text('This is  Page 3 content.'),
      ),
      floatingActionButton: FloatingActionButton(
        heroTag: 'p3_b',
        onPressed: () {
          /// Pop the current page to return to the previous page.
          Go(context).pop();
        },
        child: const Icon(Icons.arrow_back_ios_new_rounded),
      ),
    );
  }
}
3
likes
120
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter Navigation System that provides a set of utilities for managing routes, passing arguments, and navigating through your application with ease.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on go_navigator