short_navigation 1.2.0 copy "short_navigation: ^1.2.0" to clipboard
short_navigation: ^1.2.0 copied to clipboard

This package built to navigate between screens (routes) without using context (BuildContext).

example/lib/main.dart

// ignore_for_file: prefer_const_constructors

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: Go.navigatorKey, //*Pass this navigatorKey here
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ElevatedButton(
        onPressed: navigation,
        child: const Text("Go to Second Page"),
      ),
    );
  }

  navigation() {
    Go.to(SecondPage());
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ElevatedButton(
        onPressed: () => Go.back(),
        child: const Text("Go to Second Page"),
      ),
    );
  }
}
28
likes
160
pub points
67%
popularity

Publisher

unverified uploader

This package built to navigate between screens (routes) without using context (BuildContext).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on short_navigation