hdr_utils 0.0.1 copy "hdr_utils: ^0.0.1" to clipboard
hdr_utils: ^0.0.1 copied to clipboard

A collection of utility functions and extensions for Flutter.

GitHub Issues

❤️ Show some love and support the project #

Star the Repository #

If you find this package useful, please star the repository on GitHub to show your support! ⭐


📱 Platform Support #

Android iOS Web
✔️ ✔️ ✔️

📦 Installation #

Add this package to pubspec.yaml as follows:

$ flutter pub add hdr_utils

Import package:

import 'package:hdr_utils/hdr_utils.dart';

📋 Contents #


🧩 Widgets #

HdrTextField #

A highly polished Material 3 text field with built-in validation displays, borders, custom padding, and automatic tap-outside keyboard unfocus.

HdrTextField(
  controller: emailController,
  labelText: "Email Address",
  hintText: "Enter your email",
  prefixIcon: Icon(Icons.email_outlined),
  keyboardType: TextInputType.emailAddress,
  validator: (val) => ValidatorUtils.validateEmailAddress(val),
);

HdrImagePickerBuilder #

Renders local image bytes (via XFile) or cached network URLs under customizable dimensions and shapes.

HdrImagePickerBuilder(
  localImage: selectedImageFile,
  imageUrl: "https://example.com/avatar.png",
  width: 120,
  height: 120,
  shape: CircleBorder(),
  placeholderBuilder: (context) => Icon(Icons.person, size: 40),
  onTap: () {
    // Trigger image picker
  },
);

HdrCustomShimmer #

Wraps any custom widget child and applies a smooth loading shimmer gradient.

HdrCustomShimmer(
  child: Card(
    child: ListTile(title: Text("Loading title")),
  ),
);

HdrSkeletonShimmer #

Outputs simple rectangular or circular colored block placeholders to build skeleton screen loading layouts.

// Rectangular skeleton block
HdrSkeletonShimmer(width: 140, height: 16),

// Circular skeleton block
HdrSkeletonShimmer.circular(size: 60),

🛠️ Utilities #

ValidatorUtils #

Group of reusable text field validators with default English messages and custom error overrides.

// Validation checks
ValidatorUtils.validateFullName(name);
ValidatorUtils.validateEmailAddress(email, invalidError: "Invalid email syntax.");
ValidatorUtils.validatePhoneNumber(phone, 10, 10);
ValidatorUtils.validatePassword(password, isNewPasswordValidation: true);
ValidatorUtils.validateConfirmPassword(confirmPass, password);

DialogUtils #

Industry-standard alert, confirmation, and loader overlay modals built with rounded card styling and blurred backgrounds.

// 1. Show alert dialog
await DialogUtils.showAlert(
  context: context,
  title: "Welcome",
  message: "Alert information message.",
);

// 2. Show confirm dialog (returns Future<bool>)
bool confirmed = await DialogUtils.showConfirm(
  context: context,
  title: "Delete item?",
  message: "This action cannot be undone.",
);

// 3. Show loading spinner overlay (returns a dismissal callback)
final dismiss = DialogUtils.showLoading(context: context, message: "Uploading package...");
await Future.delayed(Duration(seconds: 3));
dismiss(); // Call to close modal

ImagePickerUtils #

Static wrappers around the device camera and gallery image picking actions.

XFile? galleryImage = await ImagePickerUtils.pickImageFromGallery();
XFile? cameraImage = await ImagePickerUtils.pickImageFromCamera();

LoggerUtils #

ANSI-colored log printer to debug console with optional path directory file storage.

// Print colored console logs
LoggerUtils.info("Info log message");
LoggerUtils.debug("Debug testing message");
LoggerUtils.success("Database sync successful!");
LoggerUtils.error("Network request failed.");

// Optional local file logger initialization (no-op on Web)
await LoggerUtils.init();

RegExpUtils #

Collection of matching regular expressions.

RegExpUtils.emailPatternRegExp
RegExpUtils.passwordPatternRegExp
RegExpUtils.numberRegExp

⚡ Extensions #

BuildContext Extensions #

// Access MediaQuery dimensions
double screenWidth = context.width;
double screenHeight = context.height;

// Access Theme colors
ThemeData theme = context.theme;
ColorScheme colors = context.colorScheme;

// Keyboard manager
context.hideKeyboard();

DateTime Extensions #

// Formatting dates
String formatted = DateTime.now().toLocalString("yyyy-MM-dd");

// Time Ago labels
String timeAgo = DateTime.now().subtract(Duration(minutes: 5)).timeAgoLabel; // "5 min ago"

List & Iterable Extensions #

// Group items by key
Map<String, List<User>> grouped = users.groupBy((user) => user.role);

// Safe access
User? first = users.firstOrNull;

Number & Double Extensions #

// localized amount format
String currency = 12500.5.formattedAmount(); // "12,500.50"

// Compact Instagram notation
String followers = 1500000.compactFormat; // "1.5M"

Color Extensions #

// Quick opacity applications
Color shaded = Colors.blue.applyOpacity(0.5);

String Extensions #

// Check format suffixes
bool isSvg = "icon.svg".isSvg;
bool isImage = "image.png".isImage;

// Email masking
String obscured = "developer.harshit@example.com".obscureEmail(); // "dev*****************@example.com"

// Capitalization
String title = "flutter".capitalize; // "Flutter"

🐛 Features and Bugs #

Please file feature requests and bugs at the GitHub Issue Tracker.

📧 Suggestions & Contributions #

If you have any suggestions, feature ideas, or feedback, feel free to reach out via email: 👉 harshitrajput396450@gmail.com


⭐ If you like the package, a star to the repository will mean a lot. #

Thank you ❤️ #

2
likes
150
points
42
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A collection of utility functions and extensions for Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

cached_network_image, flutter, image_picker, intl, path_provider, shimmer

More

Packages that depend on hdr_utils