hasan_utils 2.3.0
hasan_utils: ^2.3.0 copied to clipboard
A set of commonly used utilities for faster Flutter development.
2.3.0 - 2026-11-10 #
- Require firebase_messaging 16.7.0 (with firebase_core 4.15.0 and firebase_auth 6.7.0): earlier 16.x can leave an iOS app on the UIScene lifecycle without an APNs/FCM token on a fresh install. Apps also call
FLTFirebaseMessagingPlugin.configureNotificationCenterDelegate()inAppDelegatebeforesuper.application(...). - Add
Api.onUnauthorized: called with the server's message when a signed-in request answers 401 (a revoked or suspended session), so the app can sign out in one place; the request's own error handling is skipped. - Add
OtpVerifier.canResend:falsewhen the server says the provider can't send another code (canResendin theotp/{slug}/sendresponse, e.g. a tester's fixed code); screens then hide the countdown and the resend button. It staystruewhen the server doesn't send the field. - Fix: a wrong code no longer restarts the resend countdown.
SystemOtpVerifier.confirmCodeclearsresendAfter, which only a send reply sets. - Fix:
ImagePickerHelper.pickno longer shows the invalid-image alert on a double tap: while a pick runs (the picker is open or the platform is still resizing the image), another call opens nothing and doesn't call itsonPicked. The platform's "picker already open" answers (already_active,multiple_request) are not shown as errors. AddImagePickerHelper.isPickingandImagePickerHelper.picking(aValueListenable<bool>, e.g. for a spinner on a photo tile). - Fix:
Launcheropens a link once on a double tap: calls while a link is opening, or withinLauncher.repeatDelay(1 second) after, are ignored and get the same result;onFailureruns once. - Fix:
PushNotificationsBase.initcalled again while it is still starting no longer registers the listeners twice; the later call waits for the running start.
2.2.0 - 2026-09-25 #
- Add
Launcherfor external links (https, mailto, tel, sms), with an app-owned failure message. - Add
TextInputController, a text controller that returns trimmed input. - Add the OTP verifiers (
OtpVerifier,SystemOtpVerifier,WhatsAppOtpVerifier,FcmOtpVerifier,OtpVerificationProvider); wording stays in the app throughOtpConfig. - Add
PushNotificationsBase.onInitialized()- runs once at the end of the first successfulinit(), for one-time work like registering the device token. - Re-export
RemoteMessageso apps can write the FCM background entry point without depending onfirebase_messaging.
2.1.0 - 2026-09-02 #
- New
ImagePickerHelper.pick(onPicked:): camera or gallery image picker (source: ImagePickerSource.camera, gallery by default) with an error alert; global defaults viaImagePickerHelper.options(maxWidth:, maxHeight:, imageQuality:)with per-call arguments taking precedence; translation keyspickers.image.titleandpickers.image.errors.unknown, overridable viaImagePickerHelper.translationKeys(title:, error:) - New
LoadingOverlay.show()/hide()/isShown: full-screen loading overlay with an optional context; customizeoverlayColor,indicator,text,textStyleandblockBackglobally viaLoadingOverlay.options(...)or per call; the user's back button is ignored while shown (on by default), while programmaticNavigation.goBack()still works - New
FileUtils.load()with the synchronousFileUtils.storagePath,FileUtils.privateStoragePath,FileUtils.tempPathandFileUtils.databasesPath - New
context.isRtlextension andColorUtils.fromHex(hex, fallback)supporting all CSS hex forms (#RGB,#RGBA,#RRGGBB,#RRGGBBAA, alpha last, hash optional) - New
AppInfo: app version info via package_info_plus;await AppInfo.load()once at startup, thenAppInfo.version,AppInfo.buildNumber,AppInfo.package,AppInfo.forApi()andAppInfo.shortAppVersion - New push notification engine: extend
PushNotificationsBaseand declaretopics,localizedTopics,targets,handlers(PushActionHandler) andalertBehavior(PushAlertBehavior); delta-synced topic subscriptions with automatic language re-sync,deviceTokenwithonTokenChanged, foreground/tapped dispatch viahandleMessageand a background-isolate lane viadispatchBackground - New
Navigation.popBlockers: back-button vetoes for routes pushed viaNavigation, used byLoadingOverlay - New
ScreenInsets: safe-area insets without a context (ScreenInsets.top/bottom/left/right) plus thewithSafeBottom()EdgeInsetsextension; setScreenInsets.value = MediaQuery.paddingOf(context)inMaterialApp.builder
2.0.0 - 2026-08-31 #
- Breaking:
Navigationmethods take the screen first and an optional namedcontext:Navigation.navigate(Screen()),Navigation.navigate(Screen(), context: context),Navigation.reset(Screen()),Navigation.goBack(),Navigation.closeDrawer(). Without a context they useNavigation.navigatorKey, which must be passed toMaterialApp.navigatorKey(seeNavigationScope).Navigation.openDrawer(context)still requires theScaffoldcontext - Breaking:
Navigation.goBack()andNavigation.closeDrawer()returnvoid, removeawaitfrom their calls - Breaking:
Alert.show(title, text, {context, buttonTitle, onPressed})andAlert.confirm(title, text, onPositive, {context, ...}):contextis an optional named argument that defaults to the navigator's context - Breaking:
Api.get/post/patch/delete(url, {context, ...}):contextis an optional named argument; the error alert uses the navigator's context when none is given and is skipped when there is no navigator - Breaking: default translation keys are
actions.ok,actions.cancel(Alert) anderrors.title(Apierror alert) instead of the top-levelok,cancelanderror. Keep the old keys withAlert.translationKeys(ok: 'ok', cancel: 'cancel')andApi.translationKeys(errorTitle: 'error') - New
NavigationScope(builder: (context) => MaterialApp(navigatorKey: Navigation.navigatorKey, ...)): creates a fresh navigator key every time the app is mounted, required when the whole app is rebuilt (e.g.LocalizationApp.reload()fromfast_localization2.0.0) - New
Navigation.context,Navigation.contextOf(context),Navigation.resetNavigatorKey(),Navigation.route(screen)andNavigation.goBack(result: value) - New
Alert.translationKeys(ok:, cancel:, close:)andApi.translationKeys(errorTitle:).closeis the single button ofAlert.show()and defaults took - New
Toast.show(text)with per-call and global options viaToast.options(length:, gravity:, backgroundColor:, textColor:, fontSize:); ownToastLength/ToastGravityenums (Android supports two lengths only; gravity is ignored by Android 11+ for native toasts) - New
InternetChecker: connectivity status singleton (ChangeNotifier) built onconnectivity_pluswithinit(),isConnected,subscribe/unsubscribeandlisten(context), moved from the apps (thesubscripe/unsubscripetypos are fixed) - New migration tool:
dart run hasan_utils:migrate_v2 lib [--dry-run] [--drop-context] [--force]rewrites 1.x call sites - Breaking: uses
package:material_uiinstead ofpackage:flutter/material.dart, so it requires Flutter 3.44+ / Dart 3.12+ and an app built onmaterial_ui(dart fix --apply --code=migrate_design_widgets); noMaterialUiCompatibilityBridgeneeded - Breaking: requires
fast_localization2.0.0 - Breaking:
Api.get/post/patch/deletereturnFuture<void>instead ofdynamic; the response only flows throughonSuccess, soawaitworks as before but the result can no longer be assigned to a value - Breaking: removed the unused
versionparameter fromLocalPersistenceandJsonPersistence; both constructors are nowconst - Fixed
Api.authorizationHeaderthrowingtype 'Null' is not a subtype of type 'String'when no authorization is set; it returns an empty map instead Validate.message/Validate.lengthstypes renamed toValidateMessages/ValidateLengthsinternally; they are accessible only throughValidate.messageandValidate.lengthsPersistenceis amixin class, soclass User with ChangeNotifier, Persistencekeeps working under Dart 3- Upgrade guide: MIGRATION.md
1.2.4 - 2026-02-27 #
- Api: Only send
FormDatabody whenparamsis provided and non-empty
1.2.3 - 2026-02-19 #
- Api: Added
httpClientAdaptertoApi.options()
1.2.2 - 2025-01-18 #
- Persistence:
get()now falls back toengine.datadefaults when a key doesn't exist in saved data
1.2.1 - 2025-12-08 #
- Api: Support onError: (ApiErrorException) {} in addition to the default () {}
- Api: Enhance error JSON parsing in onError
- Api: Support a new error JSON format {"error": {"message": "Complex"}} in addition to {"error": "Simple"}.
1.2.0 - 2025-01-09 #
- Upgrade Dio package from v4 to v5
1.1.2 - 2023-08-31 #
- Api: Accept and force API response to be a JSON list or object.
- Upgrade packages
1.1.1 - 2023-04-04 #
- Api: Added
timeouttoApi.options()
1.1.0 - 2021-12-29 #
- Api: Added interceptors to
Api.options() - Upgraded dependencies
1.0.3 - 2021-10-21 #
- Storage: Added
repload()
1.0.2 - 2021-10-17 #
- Api: Fixed sending
Listinparams
1.0.1 - 2021-04-04 #
- Navigation: Add
replace()
1.0.0 - 2021-04-01 #
- Null safety support
0.4.5 - 2020-11-30 #
- Api: Add
authorizationHeaderto get authorization's header ({'Authorization': '...'})
0.4.4 - 2020-11-18 #
- FileDownloader: Fully asynchronize
start()
0.4.3 - 2020-11-18 #
- FileDownloader: Make
start()returnFuture
0.4.2 - 2020-10-25 #
- Storage: Added
setInt(),setDouble(),setBool()
0.4.1 - 2020-10-21 #
- Api: Ensure
onFinish()is called afteronSuccess()
0.4.0 - 2020-09-29 #
- Api: Upload MultiPart files.
0.3.0 - 2020-09-17 #
- Updated dependencies.
- Fixed Api debug error response.
0.2.0 - 2020-08-30 #
- Fixed
FormatExceptionthat is thrown when anApirequest expects JSON output but response returns string instead.
0.1.0 - 2020-08-26 #
- Initial release.