flutter_pro_tools 2.0.2 copy "flutter_pro_tools: ^2.0.2" to clipboard
flutter_pro_tools: ^2.0.2 copied to clipboard

is a Flutter package that provides a collection of utilities and tools to help streamline your development process.

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';

Examples #

Using navigation and snackBar keys #

add navigatorKey and snackBarKey to material app to use navigation and show snack message

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: FlutterProTools.navigatorKey,
      scaffoldMessengerKey: FlutterProTools.snackBarKey,
      home: MyHomePage(),
    );
  }
}

Pushes a new page onto the navigation stack.

FlutterProTools.navigationPush(YourPage());

Replaces the current page with a new page.

FlutterProTools.navigationReplace(YourPage());

Navigate to a new page, and then remove all the previous navigation stack.

FlutterProTools.navigationRemoveAllPreviousPages(YourPage());

Showing a snack bar #

Display a simple snackBar for notifications:

FlutterProTools.showSnackBar(message: 'Hello, this is a snackBar!');

Showing a warning snack bar #

Display a warning snackBar

FlutterProTools.showWarningSnackBar(message: 'Warning! Something might be wrong.');

Showing a bar modal bottom sheet #

Show a customizable bar modal bottom sheet

FlutterProTools.showBarModal(
  page: MyCustomPage(),
  enableDrag: true,
  isDismissible: true,
);

Showing a modal bottom sheet #

Show a modal bottom sheet

FlutterProTools.showMaterialModel(
const MyCustomPage(),
);

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();
  }
}

Saving and retrieving local data #

Save and retrieve data locally using SharedPreferences:

// Save data locally
await FlutterProTools.saveLocalData(key: 'username', value: 'JohnDoe');

// Retrieve local data
String? username = await FlutterProTools.getLocalData(key: 'username');

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!'),
      ),
    );
  }
}

Set portrait device #

Sets the device orientation to portrait only:

FlutterProTools.setPortraitDevice();

translate #

please add riverpod in pubspec.yaml

dependencies:
  flutter_riverpod: ^2.5.1

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(),
    );
  }
}

then make this directory:

Project Directory Structure #

project
├── assets
│ ├── lang
│ │ ├── en.json
│ │ └── ar.json

Language JSON Files #

add those json file to your project:

assets/lang/ar.json #

{
  "connection_error": "فشل إتصال بالإنترنت",
  "connection_error_content": "أنت غير متصل حاليًا، يرجى التحقق من الاتصال والمحاولة مرة أخرى",
  "ok": "موافق",
  "home": "الرئيسية",
  "send_data_to_socket": "إرسال البيانات إلى السوكيت",
  "send_ack_data_to_socket": "إرسال بيانات Ack إلى السوكيت",
  "navigate_to_new_page": "انتقل إلى الصفحة الجديدة",
  "show_loading_dialog": "عرض مربع حوار التحميل",
  "loading_completed": "اكتمل التحميل",
  "perform_get_request": "أداء طلب GET",
  "no_data": "لا توجد بيانات",
  "save_and_retrieve_local_data": "حفظ واسترجاع البيانات المحلية",
  "saved_username": "اسم المستخدم المحفوظ",
  "change_language": "تغيير اللغة",
  "go_to_login_page": "اذهب إلى صفحة تسجيل الدخول",
  "remove_local_data": "إزالة البيانات المحلية",
  "loading_please_wait": "يتم العمل يرجى الإنتظار",
  "open_camera": "فتح الكميرا",
  "image_picker": "اختر صورة",
  "no_image_selected": "لا توجد صورة",
  "over_512k": "لقد اخترت صورة أصغر من 512kb يرجى اختيار صورة أصغر",
  "open_bar_model": "فتح نافذة من الأسفل",
  "open_material_model": "فتح صفحة جديدة من الأسفل"
}

assets/lang/en.json #

{
  "connection_error": "Internet connection failed.",
  "connection_error_content": "You are currently offline please check your connection and try again",
  "ok": "OK",
  "home": "Home",
  "send_data_to_socket": "Send data to socket",
  "send_ack_data_to_socket": "Send Ack data to socket",
  "navigate_to_new_page": "Navigate to New Page",
  "show_loading_dialog": "Show Loading Dialog",
  "loading_completed": "Loading Completed",
  "perform_get_request": "Perform GET Request",
  "no_data": "No data",
  "save_and_retrieve_local_data": "Save and Retrieve Local Data",
  "saved_username": "Saved username",
  "change_language": "Change language",
  "go_to_login_page": "Go to login page",
  "remove_local_data": "Remove local data",
  "loading_please_wait": "Loading please wait",
  "open_camera": "Open camera",
  "image_picker": "Image picker",
  "no_image_selected": "No Image Selected",
  "over_512k": "your image is over than 512 kb please select smaller one",
  "open_bar_model": "Open bar model",
  "open_material_model": "Open material model"
}

You need it add this in each page you need to translate:

ref.watch(languageStatus);

Translates a key into the current locale's language

String translatedText = FlutterProTools.translate('hello');

To change application language (supported only arabic and english):

var languageState = ref.watch(languageStatus);
languageState.changeLocale('ar');

To change the current language from outside the page:

FlutterProTools.readStatusLanguage.changeLocale('ar');

Close page #

Closes the current modal or bar modal.

FlutterProTools.closePage();

Close keyboard #

Closes the keyboard if it is open.

FlutterProTools.closeKeyboard();

Get request #

  • notice that the response in this plugin handle to return as Map<String, dynamic> Performs a GET HTTP request.
FlutterProTools.getRequest(
  url: 'https://api.example.com/data',
  data: { name: "name" }
  authorization: 'Bearer token',
  response: (http.Response response) {
    print(response.body);
  },
);

Send request #

Performs a POST HTTP request.

FlutterProTools.sendRequest(
  url: 'https://api.example.com/data',
  data: {name: "name example"},
  File? file,
  String? jsonFileKeyName,
  authorization: 'Bearer token',
  response: (http.Response response) {
    print(response.body);
  },
);

Delete request #

Performs a DELETE HTTP request.

FlutterProTools.deleteRequest(
  url: 'https://api.example.com/data',
  authorization: 'Bearer token',
  response: (http.Response response) {
    print(response.body);
  },
);

Update request #

Performs a PUT HTTP request.

FlutterProTools.updateRequest(
  url: 'https://api.example.com/data',
  data: {name: "name example"},
  File? file,
  String? jsonFileKeyName,
  authorization: 'Bearer token',
  response: (http.Response response) {
    print(response.body);
  },
);

Show material model #

Shows a material bottom sheet modal.

FlutterProTools.showMaterialModel(MyModalPage());

Show alert dialog #

Shows an alert dialog.

FlutterProTools.showAlertDialog(
content: Text('This is an alert dialog.'),
title: 'Alert',
);

Show error alert dialog #

Shows an error alert dialog and executes a function when "OK" is pressed.

FlutterProTools.showErrorAlertDialog(() {
  print('Retry action');
});

Save local data #

Saves a string to local storage.

FlutterProTools.saveLocalData(key: 'username', value: 'JohnDoe');

Save local data as integer #

Saves an integer to local storage

FlutterProTools.saveLocalDataAsInteger(key: 'userAge', value: 30);

Save local data as boolean #

Saves a boolean to local storage.

FlutterProTools.saveLocalDataAsBoolean(key: 'isLoggedIn', value: true);

Get local data #

Retrieves a string from local storage.

await FlutterProTools.getLocalData(key: 'username');

Remove local data #

Removes a key-value pair from local storage.

FlutterProTools.removeLocalData(key: 'username');

Get local data as boolean #

Retrieves a boolean from local storage.

await FlutterProTools.getLocalDataAsBoolean(key: 'isLoggedIn');

Get local data as integer #

Retrieves an integer from local storage.

await FlutterProTools.getLocalDataAsInteger(key: 'userAge');

Show notification #

Shows a notification with a title and body.

FlutterProTools.showNotification('Notification Title', 'This is the body of the notification.');

launchURL #

Navigate to external url

FlutterProTools.launchURL(String url, Function()? function);

Loading progress dialog #

Show loading dialog during request processing

FlutterProTools.showLoadingDialog();

Close loading dialog #

Close loading dialog when request ended

FlutterProTools.dismissLoadingDialog();

Log file #

To show log inside your app

FlutterProTools.logFile(message, name);

Get date formated #

get the date formated in form yyyy-MM-dd

FlutterProTools.getDate(date)

get random number #

get random number length :

FlutterProTools.getInteger(6);

Image handling #

Choose and crop images with specified settings.

Map<String, dynamic> result = await FlutterProTools.chooseImage();

Geolocation #

Detect the user's current location.

var result = await FlutterProTools.detectMyLocation();

Add the following to your "gradle.properties" file:

android.useAndroidX=true
android.enableJetifier=true

Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 34:

android {
  compileSdkVersion 34

  ...
}

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" />

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" />

Image cropper #

Choose and crop images with specified settings.

XFile result = await FlutterProTools.cropImage();

Add in AndroidManifest.xml

<activity
    android:name="com.yalantis.ucrop.UCropActivity"
    android:screenOrientation="portrait"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

Camera capture #

Captures an image using the device's camera, crops the image.

Map<String, dynamic> result = await FlutterProTools.cameraCapture();

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.

2
likes
0
points
263
downloads

Publisher

unverified uploader

Weekly Downloads

is a Flutter package that provides a collection of utilities and tools to help streamline your development process.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

firebase_core, firebase_messaging, flutter, flutter_local_notifications, flutter_localizations, flutter_riverpod, fluttertoast, geolocator, http, image_cropper, image_picker, intl, modal_bottom_sheet, riverpod_context, shared_preferences, socket_io_client, url_launcher

More

Packages that depend on flutter_pro_tools