route_pilot

Creator: coderz1093

Last updated:

0 purchases

route_pilot Image
route_pilot Images
Add to Cart

Description:

route pilot

RoutePilot #





RoutePilot is a powerful Flutter package that simplifies navigation and URL handling in your Flutter applications. It provides an easy-to-use interface for navigating between screens, launching URLs, and handling various system intents like making phone calls or sending emails.
Table of Contents #

Features
Installation
Usage

Setup
Navigation
Passing Arguments
URL Launching
System Intents


API Reference

RoutePilot Class
PilotPage Class
Transition Enum


Configuration

iOS Configuration
Android Configuration


Example
License

Features #

Simple and intuitive navigation API
Custom page transitions
URL launching (browser, in-app browser, WebView)
Phone call initiation
SMS sending
Email composition
Argument passing between routes

Installation #
Add route_pilot to your pubspec.yaml file:
dependencies:
route_pilot: ^0.0.3
copied to clipboard
Then run:
flutter pub get
copied to clipboard
Usage #
Setup #
To use RoutePilot, set up your MaterialApp with the navigatorKey and onGenerateRoute:
import 'package:flutter/material.dart';
import 'package:route_pilot/route_pilot.dart';
import 'package:your_app/routes/pilot_pages.dart';
import 'package:your_app/routes/pilot_routes.dart';

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

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

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RoutePilot Demo',
navigatorKey: routePilot.navigatorKey,
onGenerateRoute: (settings) {
final page = PilotPages.onGenerateRoute(settings);
return page.createRoute(context);
},
initialRoute: PilotRoutes.Home,
);
}
}
copied to clipboard
Define your routes:
abstract class PilotRoutes {
static const String Home = '/';
static const String ScreenOne = '/screen_one';
static const String ScreenTwo = '/screen_two';
static const String ScreenThree = '/screen_three';
static const String ScreenFour = '/screen_four';
}
copied to clipboard
Set up your PilotPages:
import 'package:flutter/material.dart';
import 'package:route_pilot/route_pilot.dart';
import 'package:your_app/screens/home_screen.dart';
import 'package:your_app/screens/screen_one.dart';
// Import other screens...

class PilotPages {
static PilotPage onGenerateRoute(RouteSettings settings) {
switch (settings.name) {
case PilotRoutes.Home:
return PilotPage(
name: PilotRoutes.Home,
page: (context) => HomeScreen(),
transition: Transition.ios,
);
case PilotRoutes.ScreenOne:
return PilotPage(
name: PilotRoutes.ScreenOne,
page: (context) => ScreenOne(),
transition: Transition.ios,
);
// Define other routes...
default:
return PilotPage(
name: 'error',
page: (context) => ErrorPage(),
);
}
}
}
copied to clipboard
Navigation #
Navigate between screens:
// Navigate to a named route
routePilot.toNamed('/screen_one');

// Navigate back
routePilot.back();

// Replace the current route
routePilot.off('/screen_two');

// Remove all existing routes and navigate
routePilot.offAll('/home');
copied to clipboard
Passing Arguments #
Pass arguments when navigating:
routePilot.toNamed('/screen_three', arguments: {'name': 'John Doe', 'age': 25});
copied to clipboard
Retrieve arguments in the destination screen:
final name = routePilot.arg<String>('name');
final age = routePilot.arg<int>('age');
copied to clipboard
URL Launching #
Launch URLs using RoutePilot:
// Launch in default browser
routePilot.launchInBrowser(Uri.parse('https://flutter.dev'));

// Launch in in-app browser
routePilot.launchInAppBrowser(Uri.parse('https://dart.dev'));

// Launch in WebView
routePilot.launchInAppWebView(Uri.parse('https://pub.dev'));
copied to clipboard
System Intents #
Trigger system intents:
// Make a phone call
routePilot.makePhoneCall('123-456-7890');

// Send an SMS
routePilot.sendSms('123-456-7890', body: 'Hello from Flutter!');

// Send an email
routePilot.sendEmail(
'example@example.com',
subject: 'Test Email',
body: 'This is a test email sent from a Flutter app.',
);
copied to clipboard
API Reference #
RoutePilot Class #
The main class for navigation and URL handling.
Methods:

to(Widget page, {dynamic arguments})
toNamed(String routeName, {dynamic arguments})
back()
offAll(String routeName, {dynamic arguments})
off(String routeName, {dynamic arguments})
launchInBrowser(Uri url)
launchInAppBrowser(Uri url)
launchInAppWebView(Uri url)
launchInAppWithCustomHeaders(Uri url, Map<String, String> headers)
launchInAppWithoutJavaScript(Uri url)
launchInAppWithoutDomStorage(Uri url)
launchUniversalLinkIOS(Uri url)
makePhoneCall(String phoneNumber)
sendSms(String phoneNumber, {String? body})
sendEmail(String email, {String? subject, String? body})
canLaunchUrl(Uri url)

PilotPage Class #
A custom implementation of the Page class for more control over transitions.
Properties:

page: The function that builds the content of the page.
name: The name of the route.
fullscreenDialog: Whether the route is a full-screen dialog.
transitionDuration: The duration of the transition animation.
transition: The type of transition animation to use.
maintainState: Whether to maintain the state of the route when it's inactive.
opaque: Whether the route is opaque.
parameters: Optional parameters to pass to the route.
arguments: Optional arguments to pass to the route.

Transition Enum #
Defines the types of transitions available:

fadeIn
rightToLeft
leftToRight
topToBottom
bottomToTop
scale
rotate
size
ios

Configuration #
iOS Configuration #
Add any URL schemes passed to canLaunchUrl as LSApplicationQueriesSchemes entries in your Info.plist file:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>sms</string>
<string>tel</string>
</array>
copied to clipboard
Android Configuration #
Add any URL schemes passed to canLaunchUrl as <queries> entries in your AndroidManifest.xml:
<queries>
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<!-- If your application checks for inAppBrowserView launch mode support -->
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
copied to clipboard
Example #
Here's a simple example of how to use RoutePilot in a Flutter app:
import 'package:flutter/material.dart';
import 'package:route_pilot/route_pilot.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: routePilot.navigatorKey,
onGenerateRoute: (settings) {
final page = PilotPages.onGenerateRoute(settings);
return page.createRoute(context);
},
home: HomeScreen(),
);
}
}

class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('RoutePilot Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: Text('Go to ScreenOne'),
onPressed: () => routePilot.toNamed('/screen_one'),
),
ElevatedButton(
child: Text('Launch URL in Browser'),
onPressed: () => routePilot.launchInBrowser(Uri.parse('https://flutter.dev')),
),
ElevatedButton(
child: Text('Make Phone Call'),
onPressed: () => routePilot.makePhoneCall('123-456-7890'),
),
],
),
),
);
}
}

class PilotPages {
static PilotPage onGenerateRoute(RouteSettings settings) {
switch (settings.name) {
case '/':
return PilotPage(
name: '/',
page: (context) => HomeScreen(),
);
case '/screen_one':
return PilotPage(
name: '/screen_one',
page: (context) => ScreenOne(),
transition: Transition.fadeIn,
);
default:
return PilotPage(
name: 'error',
page: (context) => Scaffold(body: Center(child: Text('Page not found'))),
);
}
}
}

class ScreenOne extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Screen One')),
body: Center(
child: Text('This is Screen One'),
),
);
}
}
copied to clipboard
License #
This project is licensed under the MIT License. See the LICENSE file for details.
About the Author #
This project is maintained by Eldho Paulose.

GitHub: eldhopaulose
Website: Eldho Paulose

Feel free to reach out for any questions or suggestions regarding this project!

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.

Related Products

More From This Creator