master_utility 0.0.14 copy "master_utility: ^0.0.14" to clipboard
master_utility: ^0.0.14 copied to clipboard

All-in-one utility solution with Size, Navigation, Image Picker, Date Time, Auto Size Text, Toast, Email, Log, Dialog, Cache Image, Validation, API and Shared Preferences.

Master Utility Package #

A package that enables you to use a comprehensive set of utilities in a single package with customization. It includes features like Done Keyboard View For Android and IOS, Size Helper, Navigation Helper, Image Picker Helper, Date Time Helper, Auto Size Text Helper, Toast Helper, Email Dispose, Log Helper, Dialog Helper, Cache Network Image Helper, Validation Helper, Api Helper, Shared Preference Helper,image cropper helper, Debounce helper, Read more Text Helper, duble click redundant Helper and Permission handler with custom type Helper.

Support #

- Android
- iOS
copied to clipboard

How to add this package to your project add this dependencies inside your pubspec.yaml file #

dependencies:
   master_utility :
copied to clipboard

Import Package #

import 'package:master_utility/master_utility.dart';

Uses #

For use this package

MasterUtilityMaterialApp()
Use this as a MaterialApp();
copied to clipboard

This package contains the below points as of now. We can improve and add new points as per requirements in the future #

Done Keyboard View For Android and IOS #

You need to add the below line into FocusNode, which you can manage with Custom Text Filed. You have the option to hide the done keyboard, and you can enable the previous and next buttons to focus on the next and previous fields.
copied to clipboard

focusNode: showDoneKeyboard
  ? (focusNode..addListener(() {
        final hasFocus = focusNode.hasFocus;
        if (hasFocus) {
        KeyboardOverlay.showOverlay(
            context: context,
            isNextButton: isNextButton,
            isPrevious: isPrevious,
            isShowButton: (isNextButton || isPrevious),
              );
            } else {
              KeyboardOverlay.removeOverlay();
            }
          })
  ): focusNode,
copied to clipboard

AppTextField(
    focusNode: focusNode,
    label: "TextField to View Done Keyboard",
    showDoneKeyboard: true, // by default done view is false
),
copied to clipboard

NavigationHelper.navigatePop();

NavigationHelper.navigatePush(route: routeName());

NavigationHelper.navigatePushReplacement(route: routeName());

NavigationHelper.navigatePushRemoveUntil(route: routeName());
copied to clipboard

Sizer helper #

add below line inside your first widget build method

SizeHelper.setMediaQuerySize();

Container(
    width: 0.03.w,    //It will take a 30% of screen width
    height:0.03.h,     //It will take a 30% of screen height
),

Padding(
    padding: EdgeInsets.symmetric(vertical: 0.05.h, horizontal: 0.05.w),
    child: Container(),
);

Text('Sizer Helper',style: TextStyle(fontSize: 5.5.fs));
copied to clipboard

Image picker helper #

To use In [IOS] add this code in project_directory/ios/Runner/info.plist

`<key>`NSCameraUsageDescription `</key>`
    `<string>`Upload image from camera for screen background `</string>`
    `<key>`NSMicrophoneUsageDescription `</key>`
    `<string>`Post videos to profile `</string>`
    `<key>`NSPhotoLibraryUsageDescription `</key>`
    `<string>`Upload images for screen background `</string>`
copied to clipboard
  • Multimedia picker

    • Take Photo

    • Photo from Gallery

    • Take a Video

    • Video from Gallery

    • Document

      final result = await ImagePickerHelper.multiMediaPicker();

  • Custom media picker

    final result = await ImagePickerHelper.customMediaPicker( pickerActionType:PickerActionType.camera);

    use below enum for custom media picker PickerActionType.camera PickerActionType.gallery, PickerActionType.video, PickerActionType.cameraVideo, PickerActionType.document,

Date time helper #

we have extension for on dateTime.

DateTime.now().toCustomFormatter(formatter:DateTimeFormatter.HOUR_MINUTE)
copied to clipboard

Auto size text helper #

Widget AutoText AutoText({
    Key? key,
    Key? textKey,
    TextStyle? style,
    StrutStyle? strutStyle,
    double? minFontSize,
    double? maxFontSize,
    List`<double>`? presetFontSizes,
    AutoSizeGroup? group,
    TextAlign? textAlign,
    TextDirection? textDirection,
    Locale? locale,
    bool? softWrap,
    bool wrapWords = true,
    TextOverflow? overflow,
    Widget? overflowReplacement,
    double? textScaleFactor,
    int? maxLines,
    String? semanticsLabel,
    required String text,
    TextSpan? textSpan,
})
copied to clipboard

Toast helper #

Method : 1

showToast({required String message})

Method : 2

void showCustomToast({
        required String message,
        Color? backgroundColor,
        Color? textColor,
        double? fontSize,
        ToastGravity? gravity,
    })
copied to clipboard

Email Dispose helper #

void getEmailDisposeHelper() async {
    final EmailDisposerResModel? result = await EmailDisposeHelper.emailDisposerChecker(email: “fredrik.eilesartsen@yopmail.com”);
    LogHelper.logInfo(“Is Email Disposable? : ${result?.disposable}“);
}
copied to clipboard

Log helper #

LogHelper.logInfo("add log here");

LogHelper.logSuccess("add log here");

LogHelper.logWarning("add log here");

LogHelper.logError("add log here");
copied to clipboard

Dialog Helper #

Show Action Sheet

final PickerActionType? actionType = await DialogHelper.showActionSheet`<PickerActionType>`(
    actions: const [
        SheetAction(key: PickerActionType.camera, label: AppStrings.camera),
        SheetAction(key: PickerActionType.gallery, label: AppStrings.gallery),
    ],
);
copied to clipboard

Show Dialog

void _showDialogBox() {
    return DialogHelper.showCustomAlertDialog(
       barrierDismissible: false,
       builder: (BuildContext context, widget) {
       return WillPopScope(
        onWillPop: () async => false,
        child: AlertDialog(
          title: const Text(AppStrings.noInternet),
          content: const Text(AppStrings.checkYourInternet),
          contentPadding: EdgeInsets.all(AppPadding.p15),
          titlePadding: EdgeInsets.all(AppPadding.p15),
          actions: [
            AppButton(
              width: AppWidth.w140,
              title: AppStrings.tryAgain,
            )
           ],
          ),
         );
    });
}
copied to clipboard

Cache network Image Helper #

AppNetworkImage(
    url: imageUrl,
    errorWidget: (p0, p1, p2) =>
        Icon(Icons.error),
),
copied to clipboard

Validation helper #

validator: (v) => ValidationHelper.validateEmail(v),
copied to clipboard

Api Helper #

First of all, you want to add the below line to the main method.

dioClient.setConfiguration(APIEndpoints.baseUrl);
copied to clipboard

FOR GET API CALL

Future`<void>` getApiCall() async {
    final request = APIRequest(
        url: url,
        methodType: MethodType.GET,
    );

final response =
        await APIService().GetApiResponse(request, apiResponse: (dynamic data) {
        return Data.fromJson(data);
    });
    if (response.hasError) {
        ToastHelper.showCustomToast(
        backgroundColor: Colors.red,
        message: response.message.toString());
    } else {
        _newData = response.data;
    }
}
copied to clipboard

FOR POST API CALL

final request = APIRequest(
   url: url,
   methodType: MethodType.POST,
   params: reqParam,
);
copied to clipboard

FOR PUT API CALL

final request = APIRequest(
   url: url,
   methodType: MethodType.PUT,
   params: reqParam,
);
copied to clipboard

FOR DELETE API CALL

final request = APIRequest(
   url: url,
   methodType: MethodType.DELETE,
);
copied to clipboard

Shared Preference Helper #

First of all, you want to add the below line to the main method.

Parameters:

  • encryptionKey: A required string parameter used as the key(32 character) for encrypting and decrypting stored data.

    await PreferenceHelper.init(encryptionKey: 'your-encryption-key');

This initialization method must be called before any other methods in the PreferenceHelper class to ensure that the shared preferences instance and encryption key are properly set.

For String SET and GET

await PreferenceHelper().setStringPrefValue(key: key, value: value);

String getValue = await PreferenceHelper().getStringPrefValue(key: key);
copied to clipboard

For bool SET and GET

await PreferenceHelper().setBoolPrefValue(key: key, value: value);

bool getValue = await PreferenceHelper().getBoolPrefValue(key: key);
copied to clipboard

For int SET and GET

await PreferenceHelper().setIntPrefValue(key: key, value: value);

int getValue = await PreferenceHelper().getIntPrefValue(key: key);
copied to clipboard

For double SET and GET

await PreferenceHelper().setDoublePrefValue(key: key, value: value);

double getValue = await PreferenceHelper().getDoublePrefValue(key: key);
copied to clipboard

For remove single value and clear all from Shared Preference

await PreferenceHelper().removePrefValue(key: key);

String getValue = await PreferenceHelper().clearAll();
copied to clipboard

Note : Use PreferenceHelper instead of PreferenceServiceHelper

image cropper Helper #

croppedImage = await ImageCropperHelper.cropImage(imagePath: fileResult.path);

LogHelper.logInfo("croppedImage result $croppedImage");
copied to clipboard

Read more and less more text Helper #

ReadMoreTextHelper(
    'Flutter is Google’s mobile UI open source framework to build high-quality native (super fast) interfaces for iOS and Android apps with the unified codebase.',
    trimLines: 2,
    colorClickableText: Colors.blue,
    trimMode: TrimMode.Line,
    trimCollapsedText: 'Show more',
    trimExpandedText: 'Show less',
    moreStyle: TextStyle(
    fontSize: 14, fontWeight: FontWeight.bold),
),
copied to clipboard

Debounce Timer with milliseconds option Helper #

final debouncer = DebouncerHelper();

debouncer.run(() {
    /// add your code here
});
copied to clipboard

double clicked redundant Helper #

ElevatedButton(
    onPressed: () {
        DoubleClickReduntHelper.handleDoubleClick();
        ToastHelper.showToast(message: "Default Toast");
    },
    child: const Text("Show Default Toast"),
)
copied to clipboard

Permission Handler Helper #

PermissionHandlerService.handlePermissions(
    type: PermissionType.PHOTO,

/// You can pass custom Dialog
    permissionDeniedDialog: () {
       return showDialog(
            context: context,
            builder: (context) {
             return const AlertDialog(title: Text("Custom Dialog"));
                        },
                    );
                },
        callBack: () async {
             final fileResult = await ImagePickerHelper.customMediaPicker(
                                pickerActionType: PickerActionType.gallery,
                              );
            LogHelper.logInfo("result $fileResult");
            if (fileResult != null) {
                croppedImage.value =await ImageCropperHelper.cropImage(imagePath: fileResult.path);

LogHelper.logInfo("croppedImage result $croppedImage");
                              }
            },
    )
copied to clipboard

img

Using the Encryption Extension #

This extension provides tools to encrypt map data using RSA and AES encryption algorithms. Below is a quick guide on how to utilize this functionality in your project:

  1. Load the Public Key: Ensure you load the public key before using the encryption methods. Call EncryptionService.loadPublicKey() to load the key from preferences.
  2. Encrypt Data: Extend a Map object with the MapEncryption extension and call the encrypted() method to encrypt its contents. This method generates a random secret key and IV, encrypts the map data with AES, and then encrypts the secret key with RSA.
  3. Access Encrypted Data: The encrypted() method returns a map containing:
    • encryptedData: The AES-encrypted map data in base64 format.
    • encryptedKey: The RSA-encrypted secret key in base64 format.
    • iv: The IV used for AES encryption in base64 format.

Example usage:

await EncryptionService.loadPublicKey(); Map<String, dynamic> myMap = {'key': 'value'}; Map<String, dynamic> encryptedMap = myMap.encrypted(); print(encryptedMap);

By following these steps, you can securely encrypt your map data using the provided extension.

41
likes
140
points
211
downloads

Publisher

verified publisherwebelight.co.in

Weekly Downloads

2024.10.03 - 2025.04.17

All-in-one utility solution with Size, Navigation, Image Picker, Date Time, Auto Size Text, Toast, Email, Log, Dialog, Cache Image, Validation, API and Shared Preferences.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

adaptive_dialog, auto_size_text, cached_network_image, device_info_plus, dio, dio_http_formatter, encrypt, file_picker, flutter, flutter_cache_manager, fluttertoast, image_cropper, image_picker, image_picker_platform_interface, import_sorter, intl, jailbreak_root_detection, mixpanel_flutter, permission_handler, pointycastle, shared_preferences

More

Packages that depend on master_utility