hasan_utils 2.1.0 copy "hasan_utils: ^2.1.0" to clipboard
hasan_utils: ^2.1.0 copied to clipboard

A set of commonly used utilities for faster Flutter development.

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 via ImagePickerHelper.options(maxWidth:, maxHeight:, imageQuality:) with per-call arguments taking precedence; translation keys pickers.image.title and pickers.image.errors.unknown, overridable via ImagePickerHelper.translationKeys(title:, error:)
  • New LoadingOverlay.show()/hide()/isShown: full-screen loading overlay with an optional context; customize overlayColor, indicator, text, textStyle and blockBack globally via LoadingOverlay.options(...) or per call; the user's back button is ignored while shown (on by default), while programmatic Navigation.goBack() still works
  • New FileUtils.load() with the synchronous FileUtils.storagePath, FileUtils.privateStoragePath, FileUtils.tempPath and FileUtils.databasesPath
  • New context.isRtl extension and ColorUtils.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, then AppInfo.version, AppInfo.buildNumber, AppInfo.package, AppInfo.forApi() and AppInfo.shortAppVersion
  • New push notification engine: extend PushNotificationsBase and declare topics, localizedTopics, targets, handlers (PushActionHandler) and alertBehavior (PushAlertBehavior); delta-synced topic subscriptions with automatic language re-sync, deviceToken with onTokenChanged, foreground/tapped dispatch via handleMessage and a background-isolate lane via dispatchBackground
  • New Navigation.popBlockers: back-button vetoes for routes pushed via Navigation, used by LoadingOverlay
  • New ScreenInsets: safe-area insets without a context (ScreenInsets.top/bottom/left/right) plus the withSafeBottom() EdgeInsets extension; set ScreenInsets.value = MediaQuery.paddingOf(context) in MaterialApp.builder

2.0.0 - 2026-08-31 #

  • Breaking: Navigation methods take the screen first and an optional named context: Navigation.navigate(Screen()), Navigation.navigate(Screen(), context: context), Navigation.reset(Screen()), Navigation.goBack(), Navigation.closeDrawer(). Without a context they use Navigation.navigatorKey, which must be passed to MaterialApp.navigatorKey (see NavigationScope). Navigation.openDrawer(context) still requires the Scaffold context
  • Breaking: Navigation.goBack() and Navigation.closeDrawer() return void, remove await from their calls
  • Breaking: Alert.show(title, text, {context, buttonTitle, onPressed}) and Alert.confirm(title, text, onPositive, {context, ...}): context is an optional named argument that defaults to the navigator's context
  • Breaking: Api.get/post/patch/delete(url, {context, ...}): context is 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) and errors.title (Api error alert) instead of the top-level ok, cancel and error. Keep the old keys with Alert.translationKeys(ok: 'ok', cancel: 'cancel') and Api.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() from fast_localization 2.0.0)
  • New Navigation.context, Navigation.contextOf(context), Navigation.resetNavigatorKey(), Navigation.route(screen) and Navigation.goBack(result: value)
  • New Alert.translationKeys(ok:, cancel:, close:) and Api.translationKeys(errorTitle:). close is the single button of Alert.show() and defaults to ok
  • New Toast.show(text) with per-call and global options via Toast.options(length:, gravity:, backgroundColor:, textColor:, fontSize:); own ToastLength/ToastGravity enums (Android supports two lengths only; gravity is ignored by Android 11+ for native toasts)
  • New InternetChecker: connectivity status singleton (ChangeNotifier) built on connectivity_plus with init(), isConnected, subscribe/unsubscribe and listen(context), moved from the apps (the subscripe/unsubscripe typos 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_ui instead of package:flutter/material.dart, so it requires Flutter 3.44+ / Dart 3.12+ and an app built on material_ui (dart fix --apply --code=migrate_design_widgets); no MaterialUiCompatibilityBridge needed
  • Breaking: requires fast_localization 2.0.0
  • Breaking: Api.get/post/patch/delete return Future<void> instead of dynamic; the response only flows through onSuccess, so await works as before but the result can no longer be assigned to a value
  • Breaking: removed the unused version parameter from LocalPersistence and JsonPersistence; both constructors are now const
  • Fixed Api.authorizationHeader throwing type 'Null' is not a subtype of type 'String' when no authorization is set; it returns an empty map instead
  • Validate.message/Validate.lengths types renamed to ValidateMessages/ValidateLengths internally; they are accessible only through Validate.message and Validate.lengths
  • Persistence is a mixin class, so class User with ChangeNotifier, Persistence keeps working under Dart 3
  • Upgrade guide: MIGRATION.md

1.2.4 - 2026-02-27 #

  • Api: Only send FormData body when params is provided and non-empty

1.2.3 - 2026-02-19 #

  • Api: Added httpClientAdapter to Api.options()

1.2.2 - 2025-01-18 #

  • Persistence: get() now falls back to engine.data defaults 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 timeout to Api.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 List in params

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 authorizationHeader to get authorization's header ({'Authorization': '...'})

0.4.4 - 2020-11-18 #

  • FileDownloader: Fully asynchronize start()

0.4.3 - 2020-11-18 #

  • FileDownloader: Make start() return Future

0.4.2 - 2020-10-25 #

  • Storage: Added setInt(), setDouble(), setBool()

0.4.1 - 2020-10-21 #

  • Api: Ensure onFinish() is called after onSuccess()

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 FormatException that is thrown when an Api request expects JSON output but response returns string instead.

0.1.0 - 2020-08-26 #

  • Initial release.