Everything that Every Project might need in a Single Package
To get started we need to initialize the package in main.dart
main.dart
Future<void> main() async {
await initUtilities();
runApp(
UMaterialApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
S.delegate,
],
supportedLocales: const <Locale>[Locale("en")],
locale: Locale(ULocalStorage.getString(UConstants.locale) ?? "en"),
lightTheme: AppThemes.lightTheme,
darkTheme: AppThemes.darkTheme,
home: const SplashPage(),
),
);
}
InitUtilities
Here you can pass some optional parameters to initUtilities
function
apiKey
: for adding ApiKey header to HttpInterceptor of the u package.
firebaseOptions
: for adding the firebase options.
safeDevice
: for having some security checks on Android and iOS safe_device
protectDataLeaking
and preventScreenShot
: screen protector for preventing user from getting
screenshots screen_protector
deviceOrientations
: for supporting different Device orientations.
UMaterialApp
UMaterialApp is a wrapper on top of GetMaterialApp
of Getx package with some default implementations.
for simplicity all the parameters are required, and everything about having dark/light theme, localizations, loading dialogs and... are handled.
Basic Utilities
UClipboard
setting and getting string data from Clipboard.
UClipboard.set("some text");
UClipboard.getText();
UFile
File Picker file_picker
UFile.showFilePicker(
allowCompression: true,
allowedExtensions: <String>["png", "jpg", "JPEG"],
allowMultiple: true,
dialogTitle: "Pick Some Awesome Image",
fileType: FileType.image,
...
action: (final List<FileData> files) {},
);
File Picker image_cropper
UFile.cropImage(
filePath: "filePath",
toolbarColor: Colors.purple,
cropAspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 2),
cropStyle: CropStyle.circle,
androidUiSettings: AndroidUiSettings(hideBottomControls: true),
action: (final FileData file) {},
);
http_interceptor
httpRequest(
url: "${AppConstants.baseUrlPractino}GetReportsByMobile/$nationalCode",
httpMethod: EHttpMethod.get,
action: (final Response<dynamic> response) {
if ((response.bodyString ?? "").length >= 50) action(LifeReportItemsResponse.fromJson('{"items": ${response.bodyString!}}'));
else action(null);
},
error: (final Response<dynamic> response) {},
cacheExpireDate: cacheExpireDate,
);
'ULaunch'
need to share text, image, widgets, or want to open someone's Telegram, whatsapp.
ULaunch.email("sina@email.com", "hello");
ULaunch.call("1234567890");
ULaunch.sms("1234567890", "some text");
ULaunch.launchInstagram("sinamn75");
ULaunch.launchTelegram("sinamn75");
ULaunch.launchWhatsApp("1234567890");
ULaunch.launchURL("https://sinamn75.com");
ULaunch.shareText("some text");
ULaunch.shareWidget(widget: const CircleAvatar());
ULaunch.launchMap(35.37651, 55.753325);
ULaunch.shareWithTelegram("some text");
ULaunch.shareWithWhatsapp("some text");
ULaunch.shareWithEmail("some text");
ULoading
A very simple loading dialog from anywhere. flutter_easyloading
ULoading.showLoading();
ULoading.dismissLoading();
ULoading.showError();
ULoading.isLoadingShow();
ULocalAuth
Authentication with biometric local_auth
final bool canAuthenticate = await ULocalAuth.canAuthenticate();
final List<BiometricType> availableBiometrics = await ULocalAuth.availableBiometrics();
await ULocalAuth.authenticate(
biometricOnly: true,
localizedReason: "just for fun",
sensitiveTransaction: true,
stickyAuth: true,
useErrorDialogs: true,
);
ULocalStorage
Easiest Local Storage management with shared_preferences
ULocalStorage.set("key1", "value");
ULocalStorage.set("key2", 1);
ULocalStorage.set("key3", 4.5);
ULocalStorage.set("key4", true);
final String? key1 = ULocalStorage.getString("key1");
final int? key2 = ULocalStorage.getInt("key2");
final double? key3 = ULocalStorage.getDouble("key3");
final bool? key4 = ULocalStorage.getBool("key4");
ULocation
Get User's location geolocator
final Position? position = await ULocation.getUserLocation();
UNavigator
Navigation Between Pages Without Context.
UNavigator.push(const ProfilePage());
UNavigator.off(const ProfilePage(), preventDuplicates: false);
UNavigator.offAll(const ProfilePage(), milliSecondDelay: 100, transition: Transition.fadeIn);
UNavigator.dialog(const ProfilePage());
UNavigator.dialogAlert(const ProfilePage());
UNavigator.back();
UNetwork
Check User's Connections.
bool hasBluetooth = await UNetwork.hasBluetooth();
bool hasCellular = await UNetwork.hasCellular();
bool hasEthernet = await UNetwork.hasEthernet();
bool hasWifi = await UNetwork.hasWifi();
bool hasVpn = await UNetwork.hasVpn();
bool hasNetworkConnection = await UNetwork.hasNetworkConnection();
UNotification
Easiest Way of Showing a Simple Notification.
UNotification.showNotification(
title: "title",
message: "message",
onNotificationTap: (NotificationResponse response) {
print(response.id);
print(response.actionId);
print(response.input);
print(response.payload);
},
);
UAppUtils
A Set of Utils About App and Device.
final String appBuildNumber = UApp.buildNumber;
final String appVersion = UApp.version;
final String appName = UApp.name;
final String appPackageName = UApp.packageName;
final bool isAndroid = UApp.isAndroid;
final bool isIos = UApp.isIos;
final bool isWeb = UApp.isWeb;
final bool isWindows = UApp.isWindows;
final bool isMacOs = UApp.isMacOs;
final bool isMobile = UApp.isMobile;
final bool isPwa = UApp.isPwa;
final bool isDesktopSize = UApp.isDesktopSize();
final bool isLandScape = UApp.isLandScape();
final bool isPortrait = UApp.isPortrait();
UApp.switchTheme(); // switch to dark if it's light, and light if it's dark
UApp.updateLocale(const Locale("fa"));
Extensions
A Set of Extensions Method for Making the Life Easier.
DateExtension
final DateTime dateTime = DateTime(2000);
final String dateTimeString = DateTime(2000).toIso8601String();
final Jalali jalali = dateTime.toJalali();
final Gregorian gregorian = jalali.toGregorian();
jalali.formatCompactDate();
jalali.formatFullDate();
jalali.formatMonthYear();
jalali.formatYear();
jalali.formatShortDate();
dateTimeString.toJalaliCompactDateString();
dateTimeString.toJalaliDateString();
dateTimeString.toJalaliDateTimeFull();
dateTimeString.getDay();
dateTimeString.getYear();
dateTimeString.getMinute();
Libraries
- components/badges
- components/barcode_qrcode
- components/bottom_sheet
- components/chart
- components/container
- components/cupertino_date_picker
- components/fdottedline
- components/flip_card
- components/flutter_tree
- components/form
- components/image
- components/link_previewer
- components/map
- components/otp_field
- components/pagination
- components/percent_indicator
- components/plus_minus
- components/rating_bar
- components/readmore
- components/scrolling_text
- components/webview
- data/data
- documents
- utilities
- utils/clipboard
- utils/constants
- utils/enums
- utils/extensions/date_extension
- utils/extensions/enums_extension
- utils/extensions/iterable_extension
- utils/extensions/number_extension
- utils/extensions/string_extension
- utils/extensions/text_extension
- utils/extensions/widget_extension
- utils/file
- utils/firebase
- utils/fonts
- utils/http_interceptor
- utils/init
- utils/launch
- utils/loading
- utils/local_auth
- utils/local_storage
- utils/location
- utils/multi_formatter/flutter_multi_formatter
- utils/multi_formatter/formatters/all_fiat_currencies
- utils/multi_formatter/formatters/credit_card_cvc_input_formatter
- utils/multi_formatter/formatters/credit_card_expiration_input_formatter
- utils/multi_formatter/formatters/credit_card_number_input_formatter
- utils/multi_formatter/formatters/currency_input_formatter
- utils/multi_formatter/formatters/formatter_extension_methods
- utils/multi_formatter/formatters/formatter_utils
- utils/multi_formatter/formatters/masked_input_formatter
- utils/multi_formatter/formatters/money_input_enums
- utils/multi_formatter/formatters/money_input_formatter
- utils/multi_formatter/formatters/phone_input_enums
- utils/multi_formatter/formatters/phone_input_formatter
- utils/multi_formatter/formatters/pos_input_formatter
- utils/network
- utils/notification
- utils/persian_date_picker/persian_datetime_picker
- utils/persian_date_picker/src/cupertino/date_picker
- utils/persian_date_picker/src/localizations/dari
- utils/persian_date_picker/src/localizations/default
- utils/persian_date_picker/src/localizations/pashto
- utils/persian_date_picker/src/localizations/persian
- utils/persian_date_picker/src/localizations/sorani
- utils/persian_date_picker/src/material/calendar_date_picker
- utils/persian_date_picker/src/material/date
- utils/persian_date_picker/src/material/date_picker
- utils/persian_date_picker/src/material/input_date_picker_form_field
- utils/persian_date_picker/src/material/restoration_properties
- utils/persian_tools/persian_tools
- utils/persian_tools/persian_tools_bank
- utils/persian_tools/persian_tools_number
- utils/persian_tools/persian_tools_phone_number
- utils/shamsi_date/shamsi_date
- utils/shamsi_date/src/date
- utils/shamsi_date/src/date_exception
- utils/shamsi_date/src/date_formatter
- utils/shamsi_date/src/gregorian/gregorian_date
- utils/shamsi_date/src/gregorian/gregorian_formatter
- utils/shamsi_date/src/jalali/jalali_date
- utils/shamsi_date/src/jalali/jalali_formatter
- utils/u_app_utils
- utils/utils
- utils/view_models