Last updated:
0 purchases
flutter pro tools
flutter pro tools #
flutter_pro_tools is a comprehensive utility package designed to enhance your Flutter development
experience. It provides a variety of tools and widgets, including navigation helpers, localization
support, snackBar utilities, modal bottom sheets, Firebase integration, local data storage,
responsive text, and socket connection management.
Features #
Navigation Helpers: Simplify navigation with global keys and custom route animations.
Localization Support: Easily translate and localize text within your app.
SnackBar Utilities: Quickly display customizable snackBars for notifications and warnings.
Modal Bottom Sheets: Show customizable modal bottom sheets with various configurations.
Firebase Integration: Initialize Firebase, handle notifications, and manage Firebase
messaging.
Local Data Storage: Save and retrieve local data using SharedPreferences.
Responsive Text: Text widgets that adapt to different screen sizes.
Socket Connection: Efficiently manage socket connections.
API Requests: Simplify making HTTP requests (GET, POST, DELETE, PUT) with error handling and
logging.
Image Handling: Choose and crop images with specified settings.
Geolocation: Detect and handle user location with permission checks.
Camera Capture Utility: Captures an image using the device's camera, crops the image, and
ensures it does not exceed the specified file size.
Usage #
Importing the Package
In any Dart file where you want to use the utilities from flutter_pro_tools, import the package:
import 'package:flutter_pro_tools/main.dart';
copied to clipboard
Examples #
Using navigation and snackBar keys #
Add navigatorKey and snackBarKey to material app to use navigation and show snack message
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: FlutterProTools.navigatorKey,
scaffoldMessengerKey: FlutterProTools.snackBarKey,
home: MyHomePage(),
);
}
}
copied to clipboard
Navigation push #
Pushes a new page onto the navigation stack.
function() async {
FlutterProTools.navigationPush(YourPage());
}
copied to clipboard
Navigation replace #
Replaces the current page with a new page.
function() async {
FlutterProTools.navigationReplace(YourPage());
}
copied to clipboard
Navigation and remove all the previous routes #
Navigate to a new page, and then remove all the previous navigation stack.
function() async {
FlutterProTools.navigationRemoveAllPreviousPages(YourPage());
}
copied to clipboard
Showing a snack bar #
Display a simple snackBar for notifications:
function() async {
FlutterProTools.showSnackBar(message: 'Hello, this is a snackBar!');
}
copied to clipboard
Showing a warning snack bar #
Display a warning snackBar
function() async {
FlutterProTools.showWarningSnackBar(message: 'Warning! Something might be wrong.');
}
copied to clipboard
Showing a bar modal bottom sheet #
Show a customizable bar modal bottom sheet
function() async {
FlutterProTools.showBarModal(
page: MyCustomPage(),
enableDrag: true,
isDismissible: true,
);
}
copied to clipboard
Showing a modal bottom sheet #
Show a modal bottom sheet
function() async {
FlutterProTools.showMaterialModel(
const MyCustomPage(),
);
}
copied to clipboard
Firebase initialization #
Initialize Firebase and request notification permissions:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// add firebase project config
FlutterProTools.setFirebaseProjectConfig(
apiKey: 'your_api_key',
appId: 'your_app_id',
messagingSenderId: 'your_messaging_sender_id',
projectId: 'your_project_id',
);
if (!kIsWeb) {
// ask user for firebase permission and generate new token then send it to server
await getFirebasePermissionAndToken(onValue: onValue);
// init firebase background and all other firebase settings
await FlutterProTools.initFlutterNotifications();
// Listens for incoming Firebase Cloud Messaging (FCM) messages and shows a notification
firebaseMessaging(function: (message) {
// Handle FCM message.
});
}
}
copied to clipboard
Saving and retrieving local data #
Save data and retrieve in you app locally
// Save data locally
function() async {
FlutterProTools.saveLocalDataAsInteger(
key: 'userAge', value: 30); // Save a integer locally using SharedPreferences:
await FlutterProTools.saveLocalDataAsBoolean(
key: 'isLoggedIn', value: true); // Saves a boolean to local storage.
await FlutterProTools.saveLocalData(
key: "username", value: "JohnDoe");
String? username =
await FlutterProTools.getLocalData(key: "username");
await FlutterProTools.getLocalData(key: 'username'); // Retrieves a string from local storage.
FlutterProTools.removeLocalData(
key: 'username'); // Removes a key-value pair from local storage.
await FlutterProTools.getLocalDataAsBoolean(
key: 'isLoggedIn'); // Retrieves a boolean from local storage.
await FlutterProTools.getLocalDataAsInteger(
key: 'userAge'); // Retrieves an integer from local storage.
FlutterProTools.showAlertDialog(
title: "Local Storage",
content: ResponsiveText(
"${FlutterProTools.translate("saved_username")}: $username",
),
);
}
copied to clipboard
Responsive text widget #
Use the ResponsiveText widget to automatically adjust text size based on screen size:
import 'package:flutter/material.dart';
import 'package:flutter_pro_tools/main.dart';
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: ResponsiveText('Home Page'),
),
body: Center(
child: ResponsiveText('This text is responsive!'),
),
);
}
}
copied to clipboard
Set portrait device #
Sets the device orientation to portrait only:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterProTools.setPortraitDevice();
runApp(
const ProviderScope(
child: MyApp(),
),
);
}
copied to clipboard
Read current value #
Reads the current value from the specified ChangeNotifierProvider
function(){
FlutterProTools.readStatus(providerVal);
}
copied to clipboard
Recall API #
Re-calls the given API by refreshing the provided Refreshable provider.
function(){
FlutterProTools.recallAPI(provider);
}
copied to clipboard
Check for app update #
Checks if a new version of the app is available by comparing the current
platform version with the provided app version.
function() async{
await FlutterProTools.checkForUpdate(appVersion: "1.2.3");
}
copied to clipboard
Translate #
Please add riverpod package in pubspec.yaml
dependencies:
flutter_riverpod: ^2.5.1
copied to clipboard
Then add this functions:
class MyApp extends ConsumerWidget {
const MyApp({super.key, required this.page});
// This widget is the root of your application.
@override
Widget build(BuildContext context, WidgetRef ref) {
var state = ref.watch(languageStatus);
return MaterialApp(
locale: state.currentLocal,
supportedLocales: AppLocale.supportedLocale(),
localeResolutionCallback: AppLocale.localeResolutionCallback,
localizationsDelegates: AppLocale.localizationsDelegates(),
);
}
}
copied to clipboard
Run this command to add translate file and directory:
dart run flutter_pro_tools:init_data
copied to clipboard
You need it add this in each page you need to translate:
class MyApp extends ConsumerWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context, WidgetRef ref) {
var state = ref.watch(languageStatus); // this line
return MaterialApp(
home: const HomePage(),
locale: state.locale,
);
}
}
copied to clipboard
Translates a key into the current locale's language
String translatedText = FlutterProTools.translate('hello');
copied to clipboard
To change application language (supported only arabic and english):
function() {
FlutterProTools.getCurrentLanguage == "en"
? languageState.changeLanguage('ar')
: languageState.changeLanguage('en');
}
copied to clipboard
To change the current language from outside the page (e.g: controller):
changeLanguage() {
FlutterProTools.changeLanguage('ar');
}
copied to clipboard
Get current language #
To get current app language
function() async {
String language = FlutterProTools.getCurrentLanguage;
}
copied to clipboard
Close page #
Closes the current modal or bar modal.
function() {
FlutterProTools.closePage();
}
copied to clipboard
Close keyboard #
Closes the keyboard if it is open.
function() {
FlutterProTools.closeKeyboard();
}
copied to clipboard
Get request #
Notice that the response in this plugin handle to return as Map<String, dynamic>
Performs a GET HTTP request.
function() {
FlutterProTools.getRequest(
url: "https://jsonplaceholder.typicode.com/posts/1",
response: (data) =>
FlutterProTools.showAlertDialog(
title: "GET Request",
content: ResponsiveText(
data.body,
),
),
);
}
copied to clipboard
Send request #
Performs a POST HTTP request.
function() {
FlutterProTools.sendRequest(
url: 'https://api.example.com/data',
data: {name: "name example"},
File ? file : file,
String ? jsonFileKeyName : jsonFileKeyName,
authorization: 'Bearer token',
response: (http.Response response) {
print(response.body);
},
);
}
copied to clipboard
Delete request #
Performs a DELETE HTTP request.
function() {
FlutterProTools.deleteRequest(
url: 'https://api.example.com/data',
authorization: 'Bearer token',
response: (http.Response response) {
print(response.body);
},
);
}
copied to clipboard
Update request #
Performs a PUT HTTP request.
function() {
FlutterProTools.updateRequest(
url: 'https://api.example.com/data',
data: {name: "name example"},
File ? file : file,
String ? jsonFileKeyName : jsonFileKeyName,
authorization: 'Bearer token',
response: (http.Response response) {
print(response.body);
},
);
}
copied to clipboard
Show material model #
Shows a material bottom sheet modal.
function() {
FlutterProTools.showMaterialModel(
const ModelPage(),
);
}
copied to clipboard
Show alert dialog #
Shows an alert dialog.
function() {
FlutterProTools.showAlertDialog(
content: Text('This is an alert dialog.'),
title: 'Alert',
);
}
copied to clipboard
Show error alert dialog #
Shows an error alert dialog and executes a function when "OK" is pressed.
function() {
FlutterProTools.showErrorAlertDialog(() {
print('Retry action');
});
}
copied to clipboard
Save local data as integer #
Saves an integer to local storage
Show notification #
Shows a notification with a title and body.
function() {
FlutterProTools.showNotification(
title: 'Notification Title',
body: 'This is the body of the notification.',
otherData: {
"title": "Payload title",
"body": "Payload body",
},
function: (data) {
FlutterProTools.logFile(message: data.payload!);
});
}
copied to clipboard
LaunchURL #
Navigate to external url
function() {
FlutterProTools.launchURL("https://google.com", () => print(ok));
}
copied to clipboard
Loading progress dialog #
Show loading dialog during request processing
function() {
FlutterProTools.showLoadingDialog();
}
copied to clipboard
Close loading dialog #
Close loading dialog when request ended
function() {
FlutterProTools.dismissLoadingDialog();
}
copied to clipboard
Log file #
To show log inside your app
function() {
FlutterProTools.logFile(message: "this is log file", name: "log file");
}
copied to clipboard
Pretty log file #
To show log inside your app with Map data type
function() {
FlutterProTools.prettyLogFile(message: data);
}
copied to clipboard
Get date formated #
get the date formated in form yyyy-MM-dd
function() {
FlutterProTools.getDate(date);
}
copied to clipboard
Get random number #
get random number length :
function() {
print(FlutterProTools.getInteger(6));
}
copied to clipboard
Image handling #
Choose and crop images with specified settings.
function() async {
Map<String, dynamic> result = await FlutterProTools.chooseImage();
}
copied to clipboard
Geolocation #
Detect the user's current location.
function() async {
var result = await FlutterProTools.detectMyLocation();
}
copied to clipboard
Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
copied to clipboard
Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 34:
android {
compileSdkVersion 34
...
}
copied to clipboard
Add the following to your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
copied to clipboard
Add the following if you want to receive you position in background to your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
copied to clipboard
Image cropper #
Choose and crop images with specified settings.
function() async {
XFile result = await FlutterProTools.cropImage();
}
copied to clipboard
Add in AndroidManifest.xml
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
copied to clipboard
Camera capture #
Captures an image using the device's camera, crops the image.
function() async {
Map<String, dynamic> result = await FlutterProTools.cameraCapture();
}
copied to clipboard
License #
This project is licensed under a Custom App Usage License. You are permitted to use this software as
part of your application, but you are not allowed to copy, modify, merge, publish, distribute,
sublicense, or sell copies of the software, or permit others to do so.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.