u

The only package you need.

A batteries-included Flutter plugin — a curated set of UI components, utilities, extension methods, a typed API layer, and native platform features, behind a single import.

pub package platform license

import "package:u/utilities.dart";

That one line brings in Flutter's material library plus every component, utility, extension, enum, API service, and native feature below. No barrel juggling, no dozens of small imports.


Why u?

  • One import, everything. UI kit, formatters, date/Jalali tools, storage, navigation, an API layer, and native features — all re-exported from package:u/utilities.dart.
  • Consistent, themed UI. UText*, UButton, UTextField, UScaffold, UCard, UColumn, URow, and 40+ more components that read from your ThemeData and stay visually coherent.
  • Context-free helpers. UToast, UNavigator, and ULoading work from anywhere — no BuildContext needed.
  • A typed network layer. UServices.<area>.<method>(...) with success / error / exception callbacks, automatic token handling, and JWT refresh.
  • Persian / Iran first-class. Jalali dates, Persian ⇄ Latin digits, Rial/Toman money formatting, phone-operator detection, national-code validation, license-plate input.
  • Native platform features. Screenshot / screen-recording prevention (ScreenGuard) with a clean, extensible plugin-folder convention for adding more.

Platform support

Feature area Android iOS Web macOS Windows Linux
UI / utils / extensions ✅ ✅ ✅ ✅ ✅ ✅
API layer (UServices) ✅ ✅ ✅ ✅ ✅ ✅
ScreenGuard ✅ ✅ ⬜ ✅ ✅ ⬜
AR (UArScene, …) ✅ ✅ ✅ ⬜ ⬜ ⬜
3D viewer (U3DViewer) ✅ ✅ ✅ ⬜ ⬜ ⬜

⬜ = safe no-op (no OS API to prevent capture).

Install

dependencies:
  u:
    git:
      url: https://github.com/SinaMN75/U_flutter.git

Requires Flutter ≥ 3.44.8 and Dart SDK ≥ 3.12.2.

Quick start

import "package:u/utilities.dart";

void main() {
  // Point the API layer at your backend (only if you use UServices).
  U.baseUrl = "https://api.example.com";
  U.apiKey = "YOUR_API_KEY";
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) => MaterialApp(
    // Lets UToast / UNavigator / ULoading work without a BuildContext.
    navigatorKey: navigatorKey,
    // u widgets read localized strings via U.s — register the delegate.
    localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
      S.delegate,
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
    supportedLocales: S.delegate.supportedLocales,
    home: const HomePage(),
  );
}

What's inside

Text — UText*

A widget per Material 3 type-scale role: UTextDisplayLarge/Medium/Small, UTextHeadline*, UTextTitle*, UTextBody*, UTextLabel*, plus UAnimatedCounter. The string is positional; styling (color, weight, maxLines, decoration…) is named.

UTextTitleLarge("Welcome", fontWeight: FontWeight.w700);
UTextBodyMedium("Body text", color: Theme.of(context).colorScheme.onSurfaceVariant);

Buttons — UButton

Every style via UButtonType (elevated, text, outlined, icon, fab, cupertino, custom), with icons, gradients, loading/disabled states, and a built-in tap counter. Also UButtonSubmitCancel, UPressable, USendAgainCountDown.

UButton(title: "Save", isLoading: saving, onTap: save);

Inputs

UTextField, UTextFieldPhoneNumber, UTextFieldDatePicker, UTextFieldAutoComplete(Async), UDropDownField, UCountryProvincePicker, UOtpField, UPlateField (Iranian plate), UChipChoice, USegmentedControl, USlider, URichTextEditor, USignaturePad, and UJalaliDatePicker.show(type: ...) for the Jalali calendar in three flavours (classic, material, spinner), and UValidators (email, phone, length, national code, …) for validator:.

Layout & scaffolding

UScaffold, UContainer, UColumn, URow (Column/Row with spacing + decoration built in), UCard, UGlassCard, UHeaderCard, UListView, UListTile, UTabBar, USideMenu, UEmptyState, UErrorRetry.

Feedback — context-free

UToast.success/error/warning/info, UNavigator.confirmAsync/inputDialog/bottomSheet/dialog, ULoading.show/dismiss, UProgressLinear/Circular, RatingBar.

Media, files & viz

UImage (network/asset/file/memory), CachedNetworkImage, UImageViewer, UFilePicker, UScanner (QR/barcode), UBarcode, UPdfViewer, UHtmlView, UWebView, UCreditCard, UCartesianChart, UGauge, percent indicators, UJsonViewer, UMap, UChat, UProcessView (multi-step form engine), WidgetToImage.

Formatters & extensions

Call directly on values:

1500000.rial();                 // "1,500,000 ﷼"
1500000.toman();                // Toman formatting
1250000.toKMB();                // "1.25M"
1234567.separate3By3();         // "1,234,567"
"2026-08-01".toPersianNumber(); // Persian digits
DateTime.now().toJalaliDate();  // Jalali date
someDate.toTimeAgo();           // "3 hours ago"

Widget sugar makes layouts fluent:

myWidget.pAll(16).onTap(onPress).card();   // Padding → tappable → card
row.rtl();                                  // right-to-left subtree

There are also rich String, int/double, Iterable, Map, DateTime, and TextEditingController extensions.

API layer — UServices

One shape for every call: UServices.<area>.<method>(p:, onOk:, onError:, onException:).

await UServices.auth.login(
  p: ULoginParams(email: email, password: password),
  onOk: (UResponse<ULoginResponse> r) => UNavigator.push(const HomePage()),
  onError: (UEmptyResponse e) => UToast.error(message: e.message ?? "Login failed"),
  onException: (String e) => UToast.error(message: e),
);

31 service areas: auth, user, product, content, category, comment, follow, media, wallet, ipg, txn, merchant, terminal, bankAccount, moadi, inquiry, chargeInternet, sim, vehicle, parking, hotel, ticket, notification, pn, blog, address, accounting, appSettings, dashboard, process, fileManager — each with matching *Params / *Response models. Payment/IPG flows included.

ScreenGuard — native screenshot / recording prevention

await ScreenGuard.enable();   // block capture
await ScreenGuard.disable();  // allow again

ScreenGuard.onScreenshot = () => log("screenshot taken");
ScreenGuard.onScreenRecording = (bool active) => setState(() => recording = active);

Implemented natively per platform: FLAG_SECURE (Android), secure-field + detection callbacks (iOS), NSWindow.sharingType = .none (macOS), WDA_EXCLUDEFROMCAPTURE (Windows). Linux and web are safe no-ops.

Each native feature lives in a self-contained folder with its own method channel u/<feature>, so adding another native capability is a well-defined, repeatable change.

AR & 3D — UArScene, U3DViewer, UArGeoView, …

No pub packages: ARCore + a built-in OpenGL ES 3 glTF renderer on Android, ARKit + RealityKit on iOS, WebXR + a built-in WebGL2 renderer on the web. Setup per platform is documented at the top of lib/components/u_ar.dart (Android needs implementation("com.google.ar:core:1.45.0") in the app).

// Place products on floors, tables or walls; move / rotate / scale, photo and video.
UArExperiences.place(items: <UArPlaceable>[
  UArPlaceable(id: "sofa", title: "Sofa", source: UArSource.url("https://…/sofa.glb"), iosSource: UArSource.url("https://…/sofa.usdz")),
]);

// 3D product viewer with hotspots and a "View in AR" button (no permission needed).
U3DViewer(source: UArSource.asset("assets/chair.glb"));

// Shop / landmark cards around the user (visual positioning or GPS + compass).
UArExperiences.places(places: <UArPlace>[UArPlace(id: "cafe", latitude: 35.7, longitude: 51.4, title: "Cafe")]);

// Also: UArMeasure, UArFaceTryOn, UArImageTrigger, UArCodeView, UAr.scanRoom, UAr.captureObject,
// UAr.openNativeViewer — or drive everything yourself with UArController + UArView.

Downloads & storage — UDownloadManager, UFileStorage

One engine for every kind of download on all six platforms: silent fetches, a persistent IDM-style queue with segmented (multi-connection) transfers, pause/resume across restarts, checksums, mirrors, speed limits, wifi-only rules and scheduling.

// Silent, in memory.
final Uint8List bytes = await UDownloadManager.instance.fetchBytes(url);

// Into the user's Downloads (MediaStore / Files app / ~/Downloads / the browser).
await UDownloadManager.instance.download(url);

// Encrypted while downloading — plaintext never touches the disk.
await UDownloadManager.instance.enqueue(UDownloadRequest(url: url, destination: const UDownloadDestination.vault("lesson-1")));

// Hidden source: resolve an id to a (signed, short-lived) URL per attempt; the URL is never stored.
UDownloadManager.instance.urlResolver = (UDownloadTask task) async => (await api.signedUrl(task.request.sourceId!)).url;
await UDownloadManager.instance.enqueue(const UDownloadRequest(sourceId: "file-42", connections: 8));

// OS-owned: keeps going after the app is killed (DownloadManager / background URLSession / BITS).
await UDownloadManager.instance.enqueue(UDownloadRequest(url: url, useSystemDownloader: true));

// UI
UNavigator.push(const UDownloadManagerPage());
UDownloadButton(request: UDownloadRequest(url: url));

UFileStorage stores keyed files in four buckets — support (private, persistent), cache (size-capped LRU), vault (encrypted at rest, per-file keys, master key in Keystore / Keychain / Credential Manager / Secret Service / WebCrypto) and temp — with expiry, MIME types, checksums, streaming and ranged reads. On the web everything lives in IndexedDB.

Host-app setup:

  • iOS — to show downloads in the Files app, add UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace (both true) to Info.plist.
  • macOS — sandboxed apps need com.apple.security.files.downloads.read-write (Downloads) and com.apple.security.files.user-selected.read-write ("save as") entitlements, plus com.apple.security.network.client.
  • Android — nothing to add: the plugin declares the dataSync foreground service, the FileProvider and WRITE_EXTERNAL_STORAGE (API ≤ 28 only). Ask for POST_NOTIFICATIONS on Android 13+ if you want the progress notification to be visible.
  • Linux — install libsecret-1-dev at build time to keep the vault key in the Secret Service; without it the key falls back to a private file.
  • Web — cross-origin downloads need CORS, and segmented downloads need Access-Control-Expose-Headers: Content-Range, Accept-Ranges, ETag.

u_admin

A complete GetX-based admin panel bundled with the plugin (login, dashboards, blog, CMS, file manager, hotel/dorm suite, parking, payments, wallet, users, logs, push, settings). Reuse the pages (UAdminSplashPage, UAdminLoginPage, …) instead of rebuilding admin screens.

Complete API reference

Everything below is exported from the single package:u/utilities.dart import.

Components — Text

UTextDisplayLarge · UTextDisplayMedium · UTextDisplaySmall · UTextHeadlineLarge · UTextHeadlineMedium · UTextHeadlineSmall · UTextTitleLarge · UTextTitleMedium · UTextTitleSmall · UTextBodyLarge · UTextBodyMedium · UTextBodySmall · UTextLabelLarge · UTextLabelMedium · UTextLabelSmall · UAnimatedCounter

Components — Buttons & inputs

UButton · UButtonSubmitCancel · UPressable · USendAgainCountDown · UTextField · UDropDownField · UTextFieldDatePicker · UTextFieldAutoComplete · UTextFieldAutoCompleteAsync · UTextFieldPhoneNumber · UOtpField · UPlateField · UChipChoice · USegmentedControl · USlider · UCategorySelector · UCountryProvincePicker · UCurrencyInputFormatter · URichTextEditor · USignaturePad

Components — Layout & navigation

UScaffold · UContainer · UColumn · URow · UCard · UGlassCard · UHeaderCard · UListView · UListTile · UDefaultTabBar · UIconTextHorizontal · UIconTextVertical · UIconBackground · UImageBackground · UIconPrimary · UEmptyState · UErrorRetry · UAnimationCard · USideMenu (USideMenuController, USideMenuTheme, UMenuItem, UMenuGroup, UMenuHeader) · UTabBar (UTab, UTabBarTheme)

Components — Feedback & indicators

UProgressLinear · UProgressCircular · CircularPercentIndicator · LinearPercentIndicator · RatingBar · RatingBarIndicator · BadgeWidget · UProgress

Components — Media & files

UImage · UImageNetwork · UImageAsset · UImageFile · UImageMemory · CachedNetworkImage · UImageViewer · BetterImageViewer · ImageGalleryViewer · UFilePicker · UScanner (UScannerPage) · UBarcode · UPdfViewer · UHtmlView · UWebView · WidgetToImage

Components — Data viz & motion

UCartesianChart · UGauge (UGaugeRange, UGaugeAnnotation) · UJsonViewer · UNumberPagination · UMap · UChat · FlipCard · ReadMoreText · ScrollingText · CreditCardWidget (CreditCardForm, CreditCardModel, CardBrandDetector) · JalaliDatePickerDialog · UJalaliDatePicker (UJalaliDatePickerType) · UJalaliDatePickerMaterial · UJalaliDatePickerSpinner

Components — Process engine

UProcessView · UProcessController · UProcessFields · UProcessStepsIndicator · UProcessTextField · UProcessImagePickerField · UProcessESignField · UProcessVisualAuthField · UProcessStyle

Utilities (abstract/static classes)

Class Purpose
U App root config: baseUrl, apiKey, user, contents, categories, tabs, s (l10n)
UServices Entry point to all 31 API service areas
UHttpClient Low-level HTTP: send, upload, multipart, progress
UDownloadManager Segmented, resumable downloads to memory, storage, the vault, Downloads, a path or "save as"
ULocalStorage / UFileStorage Key-value + bucketed file storage (support, LRU cache, encrypted vault, temp)
UNavigator push/off/offAll, dialog, alert, confirm(Async), inputDialog, bottomSheet, datePicker, colorPicker, timePicker, overlays
UToast success/error/warning/info, snackBar, banner, toast
ULoading Global blocking spinner: show, dismiss, isShowing
UValidators required, email, phone, minLength/maxLength/exactLength, iranianNationalCode, url, password, complexPassword, match, pattern, numberRange
UEncryption AES/Salsa20/Fernet, base64/hex, md5/sha1/sha256/384/512, HMAC, key/iv gen
PersianTools National-code/card validation, bank lookup, Sheba, number↔words, digit conversion, phone details
UPhoneNumberUtils normalizePhone, operator/SIM detection
Jalali / Gregorian / DateFormatter Shamsi ⇄ Gregorian conversion and formatting
ULaunch launchURL, call, sms, WhatsApp/Telegram/Instagram/maps/email
UShare Share text/link/files/bytes/widget image
UClipboard set, getText
ULocation getUserLocation (geolocator)
UNetwork hasWifi/Cellular/Vpn/Ethernet/Bluetooth/NetworkConnection
UNotification Local notifications
UCrashlytics Error reporting
UApp Orientation/size/form-factor helpers, theme + locale switch
UUUID uuidV1/V4/V5/V6/V7/V8
UConstants Shared constants, loremPicsum
UUpdateDialog Force/soft update flow
UDebouncer Debounce callbacks

Extensions (available globally after import)

On Highlights
Widget pAll/pSymmetric/pOnly, onTap/onTapInk/onLongPress/onDoubleTap, expanded/fit, ltr/rtl, scale/rotate/translate/position, safeArea/form/scrollable, card/container, showMenus, full alignAt* family
String / String? money (rial/toman), Jalali (toJalaliDate/DateTime), toPersianNumber/toLatinNumber, separateNumbers3By3, isNullOrEmpty/isNumeric, toInt/toDouble, maxLength, getDay/Month/Year, toTimeAgo
int / double (+ nullable) rial/toman/rialToToman, separate3By3, toKMB, toStringAsSmartRound, secondsToTimeLeft, month names
num toBKMG
Iterable<T> / Iterable<T>? mapIndexed, forEachIndexed, firstOrDefault, containsAll/Any, isNullOrEmpty, addAndReturn, insertAndReturn, takeIfPossible
Map<K,V> add(k, v) (chainable request-body builder)
DateTime formatDate, toJalali(Date/DateTime), toTimeAgo, utcNow
TextEditingController numString/numInt/numDouble, valueOrNull, isNullOrEmpty
Uint8List toBase64/toBase64Url

API services (UServices.<area>)

auth · user · product · content · category · comment · follow · media · wallet · ipg · txn · merchant · terminal · bankAccount · moadi · inquiry · chargeInternet · sim · vehicle · parking · hotel · ticket · notification · pn · blog · address · accounting · appSettings · dashboard · process · fileManager

Example

A full multi-page gallery app lives in example/ demonstrating every area above, each with a live widget and the exact code that produced it.

cd example
flutter run          # mobile
flutter run -d chrome
flutter run -d macos

Conventions

Projects using u follow a few house rules (enforced by analysis_options.yaml): theme colors only (no hard-coded Colors.*), double quotes, explicit types, const/final where possible, and localized strings via U.s for anything user-facing.

License

MIT © SinaMN75

Libraries

components/badges
components/cached_image
components/chip_choice
components/container
components/count_down_timer
components/doc/u_doc
components/doc/u_epub
components/doc/u_jbig2
components/doc/u_pdf
components/doc/u_pdf_edit
components/doc/u_pdf_render
components/file_picker
components/flip_card
components/image
components/json_viewer
components/map
components/media/u_media
components/media/u_media_web
components/number_pagination
components/percent_indicator
components/persian_date_picker
components/process/u_process
components/rating_bar
components/readmore
components/scrolling_text
components/segmented_control
components/u_ar
components/u_barcode
components/u_button
components/u_camera
components/u_charts
components/u_content_bento_page
components/u_credit_card
components/u_download_manager_page
components/u_drop_down
components/u_epub_reader
components/u_gauges
components/u_general_widgets
components/u_gold
components/u_html_view
components/u_image_cropper
components/u_image_viewer
components/u_jalali_date_picker
components/u_music_player
components/u_numeric_keyboard
components/u_otp_field
components/u_pdf_editor
components/u_pdf_tools
components/u_pdf_viewer
components/u_plate_field
components/u_progress
components/u_rich_text_editor
components/u_scanner
components/u_side_menu
components/u_signature_pad
components/u_slider
components/u_storage_manager_page
components/u_tab_bar
components/u_text
components/u_text_field
components/u_text_field_formatter
components/u_video_player
components/u_webview
components/widget_to_image
data/data
enums
init
iso8583/bit_set
iso8583/card
iso8583/component_packager
iso8583/cp1256
iso8583/field_packagers
iso8583/frame_reader
iso8583/host_config
iso8583/host_config_codec
iso8583/host_context
iso8583/interpreter
iso8583/iso_buffer
iso8583/iso_component
iso8583/iso_msg
iso8583/iso_trace
iso8583/iso_transport
iso8583/iso_util
iso8583/mac_component
iso8583/msg_packager
iso8583/multiplexer
iso8583/oss_acq_header
iso8583/oss_acq_packager
iso8583/oss_acq_tlv_packager
iso8583/oss_frame_codec
iso8583/oss_tags
iso8583/padder
iso8583/pan_util
iso8583/prefixer
iso8583/security_module
iso8583/socket_transport
iso8583/tlv_list
iso8583/tlv_msg
iso8583/u_iso
iso8583/u_iso_client
iso8583/value_packager
l10n/app_localizations
l10n/app_localizations_en
l10n/app_localizations_fa
models/u_business_category
models/u_country_city
plugins/ar/u_ar_platform
plugins/ar/u_ar_web
plugins/camera/u_camera_platform
plugins/camera/u_camera_web
plugins/camera/u_code_decoder
plugins/files/u_files_channel
plugins/screen_guard
u_admin/pages/analytics/u_admin_financial_ops_dashboard_page
u_admin/pages/barcode/u_admin_barcode_generator_page
u_admin/pages/blog/u_admin_blog_page
u_admin/pages/contents/u_admin_contents_page
u_admin/pages/crypto/u_admin_crypto_tester_page
u_admin/pages/db_admin/u_admin_db_admin_page
u_admin/pages/file_manager/u_admin_file_manager_page
u_admin/pages/gold/u_admin_gold_page
u_admin/pages/hotel/contracts/u_admin_contract_page
u_admin/pages/hotel/dashboard/u_admin_hotel_dashboard_page
u_admin/pages/hotel/dorm_beds/u_admin_dorm_bed_page
u_admin/pages/hotel/dorm_rooms/u_admin_dorm_rooms_page
u_admin/pages/hotel/dorms/u_admin_dorms_page
u_admin/pages/hotel/hotel_room/u_admin_hotel_room_page
u_admin/pages/hotel/hotels/u_admin_hotel_page
u_admin/pages/hotel/invoices/u_admin_invoice_page
u_admin/pages/hotel/reservations/u_admin_reservation_page
u_admin/pages/hotel/reviews/u_admin_review_page
u_admin/pages/hotel/users/u_admin_user_create_update_controller
u_admin/pages/hotel/users/u_admin_user_create_update_page
u_admin/pages/hotel/users/u_admin_users_page
u_admin/pages/hotel/users/user_detail/u_admin_hotel_user_detail_page
u_admin/pages/hotel/visibility/u_admin_place_visibility_page
u_admin/pages/login/u_admin_login_page
u_admin/pages/logs/u_admin_api_log_page
u_admin/pages/parking/u_admin_parking_page
u_admin/pages/parking/u_admin_parking_plate_flag_page
u_admin/pages/parking/u_admin_parking_report_page
u_admin/pages/parking/u_admin_parking_shift_page
u_admin/pages/parking/u_admin_parking_staff_page
u_admin/pages/parking/u_admin_parking_subscription_page
u_admin/pages/parking/u_admin_parking_tariff_page
u_admin/pages/payments/merchants/u_admin_merchants_page
u_admin/pages/payments/moadi/u_admin_moadis_page
u_admin/pages/payments/users/u_admin_payment_user_create_update_controller
u_admin/pages/payments/users/u_admin_payment_user_create_update_page
u_admin/pages/payments/users/u_admin_users_page
u_admin/pages/payments/users/user_detail/u_admin_admin_user_detail_page
u_admin/pages/pn/u_admin_pn_tester_page
u_admin/pages/settings/u_admin_admin_settings_page
u_admin/pages/settings/u_admin_app_settings_page
u_admin/pages/u_admin_switch_page
u_admin/pages/wallet/u_admin_accounting_page
u_admin/pages/wallet/u_admin_transactions_page
u_admin/pages/wallet/u_admin_wallet_page
u_admin/u_admin
utilities
utils/extensions/context_extension
utils/extensions/date_extension
utils/extensions/iterable_extension
utils/extensions/map_extension
utils/extensions/number_extension
utils/extensions/string_extension
utils/extensions/widget_extension
utils/files/u_crypto_stream
utils/files/u_download_manager
utils/files/u_download_models
utils/files/u_download_platform
utils/files/u_download_platform_io
utils/files/u_download_platform_web
utils/files/u_file_storage
utils/files/u_storage_backend
utils/files/u_storage_backend_io
utils/files/u_storage_backend_web
utils/files/u_vault
utils/u_app
utils/u_app_state
utils/u_audio
utils/u_auth
utils/u_camera_utils
utils/u_clipboard
utils/u_constants
utils/u_convert
utils/u_crashlytics
utils/u_encrypt
utils/u_file
utils/u_http_client
utils/u_launch
utils/u_loading
utils/u_local_storage
utils/u_location
utils/u_navigator
utils/u_network
utils/u_notification
utils/u_otp
utils/u_persian_tools
utils/u_phone_number_utils
utils/u_rx
utils/u_shamsi
utils/u_share
utils/u_timezone
utils/u_toast
utils/u_update_dialog
utils/u_utils
utils/web/u_web
utils/web/u_web_browser
utils/web/u_web_native