flutter_quick_nav 1.0.1
flutter_quick_nav: ^1.0.1 copied to clipboard
A quick and easy Flutter navigation utility with fade transitions.
flutter_quick_nav #
flutter_quick_nav
is a lightweight Flutter navigation utility that simplifies screen transitions using clean and intuitive methods. It provides a smooth fade animation and streamlines navigation by wrapping common patterns like push
, replace
, and pushAndRemoveUntil
.
โจ Features #
- ๐ Navigate to a new screen with a fade transition.
- ๐ Replace the current screen.
- ๐งน Push and remove all previous routes until a specified named route.
- ๐งผ Clean API using just
BuildContext
andWidget
.
๐ Screenshots #
Note: This package affects screen transitions only, not UI layout.
๐ง Installation #
1. Depend on it #
Add this to your packageโs pubspec.yaml
file:
dependencies:
flutter_quick_nav: ^1.0.0
2. Install it #
Run either of the following commands in your terminal:
flutter pub get
3. Import it #
import 'package:flutter_quick_nav/flutter_quick_nav.dart';
๐น Quick Usage #
Use these one-liners to navigate your app with elegant fade transitions:
โ Push a new screen #
FlutterQuickNav.push(context, const SecondPage());
๐ Replace the current screen #
FlutterQuickNav.replace(context, const FinalPage());
๐งน Push and remove until a named #
FlutterQuickNav.pushAndRemoveUntil(context,const HomePage());
when using named routes #
FlutterQuickNav.pushAndRemoveUntil(context,const HomePage(),untilRoute: '/home',); // when using named routes
๐งโ๐ป Usage Example #
import 'package:flutter/material.dart';
import 'package:flutter_quick_nav/flutter_quick_nav.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'flutter_quick_nav Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
useMaterial3: true,
textTheme: const TextTheme(
bodyMedium: TextStyle(fontSize: 16),
headlineSmall: TextStyle(fontWeight: FontWeight.bold),
),
),
home: const HomePage(),
// routes: {'/home': (context) => const HomePage()}, // Optional if using named routes
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('๐ Home Page'),
centerTitle: true,
),
body: Center(
child: ElevatedButton.icon(
onPressed: () {
FlutterQuickNav.push(context, const SecondPage());
},
icon: const Icon(Icons.arrow_forward_rounded),
label: const Text('Go to Second Page'),
style: _buttonStyle(),
),
),
);
}
}
class SecondPage extends StatelessWidget {
const SecondPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('๐งญ Second Page'),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon(
onPressed: () {
FlutterQuickNav.replace(context, const FinalPage());
},
icon: const Icon(Icons.auto_awesome),
label: const Text('Replace with Final Page'),
style: _buttonStyle(background: Colors.deepPurple),
),
const SizedBox(height: 20),
ElevatedButton.icon(
onPressed: () {
FlutterQuickNav.pushAndRemoveUntil(
context,
const HomePage(),
// untilRoute: '/home', // Optional named route
);
},
icon: const Icon(Icons.home_rounded),
label: const Text('Reset to Home'),
style: _buttonStyle(background: Colors.green),
),
],
),
),
);
}
}
class FinalPage extends StatelessWidget {
const FinalPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('๐ฏ Final Page'),
centerTitle: true,
),
body: const Center(
child: Text(
'๐ You made it to the final page!',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
textAlign: TextAlign.center,
),
),
);
}
}
/// Reusable button style for consistent design
ButtonStyle _buttonStyle({Color background = Colors.indigo}) {
return ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
elevation: 4,
backgroundColor: background,
foregroundColor: Colors.white,
);
}
๐ฆ Null Safety #
This package is 100% null-safe and compatible with the latest Flutter versions.
๐ก Contribution #
Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.
๐ License #
This project is licensed under the MIT License โ see the LICENSE file for details.
๐ Support #
If you like this package, don't forget to give it a โญ on GitHub and share it with others!