mplix 0.0.4
mplix: ^0.0.4 copied to clipboard
A collection of useful Flutter and Dart extensions to simplify common tasks.
๐งฉ Mplix #
[Mplix Banner]Mplix is a handy Flutter extension package that enhances your Flutter development experience with powerful, readable, and reusable extensions for String, DateTime, BuildContext, Color, Iterable, Widget, and more โ including emoji replacement and utility methods.
๐ Make your Flutter code cleaner, shorter, and more expressive!
โจ Features #
- โ
Stringextensions โ capitalize, title case, convert to number, sentence case, emoji replacements - โ
DateTimeandDurationextensions โ formatted output, comparison helpers - โ
BuildContextextensions โ screen metrics, theme, snackbar, dialog, navigation, clipboard - โ
Widgetextensions โ tap handling, padding, spacing - โ
Colorextension โ convert to HEX - โ
Iterableextensions โmapIndexed - โ
Emojisupport โ:pizza: โ ๐,:india: โ ๐ฎ๐ณ, and more! - โ
Utility โ
log()for debug printing with optional tags
๐ Getting Started #
- Add this to your
pubspec.yaml:
dependencies:
mplix: ^1.0.0
๐ฆ Usage #
๐ String Extensions #
'flutter dev'.capitalize(); // Flutter dev
'flutter is cool'.toTitleCase(); // Flutter Is Cool
'hello world. this is flutter.'.capitalizeSentences(); // Hello world. This is flutter.
'123'.toInt(); // 123
'12.34'.toDouble(); // 12.34
'Flutter โค๏ธ :pizza: from :india:'.withEmojis(); // Flutter โค๏ธ ๐ from ๐ฎ๐ณ\
๐ DateTime Extensions #
final now = DateTime.now();
now.format(); // 22 Jun 2025
now.short; // 22/06/25
now.time; // 08:30 AM
now.fullDateTime; // 22 Jun 2025, 08:30 AM
now.isToday; // true or false
now.isSameDate(DateTime(2025, 6, 22)); // true
โณ Duration Extension #
Duration(seconds: 75).formatted; // 01:15
๐งฑ BuildContext Extensions #
context.width; // Screen width
context.height; // Screen height
context.theme; // ThemeData
context.textTheme.headlineSmall; // Text style access
context.colorScheme.primary; // Color access
context.divider; // Divider widget
context.spacing(20); // SizedBox(height: 20)
context.showSnackbar("Hello!"); // Show snackbar
context.copyToClipboard("Copied!", successMessage: "Text copied"); // Copy to clipboard
context.showLoader(message: "Loading..."); // Show loader
context.hideLoader(); // Hide loader
๐ Navigation Extensions #
context.push(MyNewPage()); // Push a new page
context.pushReplacement(MyOtherPage()); // Replace current page
context.pop(); // Go back
await context.withLoadingDialog(
someAsyncFunction(),
message: "Processing..."
); // Show loader while future runs
๐ฆ Iterable Extension #
['apple', 'banana', 'grape'].mapIndexed((i, val) => '$i: $val');
// Output: ['0: apple', '1: banana', '2: grape']
๐จ Color Extension #
Colors.blue.toHex(); // #FF2196F3
Colors.green.toHex(leadingHashSign: false); // FF4CAF50
๐งฉ Widget Extensions #
Text('Click Me').onTap(() => print('Tapped!')); // Tap handler
Container().paddingAll(8); // Padding on all sides
Text('Custom').paddingOnly(left: 12, top: 8); // Specific side padding
Text('Symmetric').paddingSymmetric(horizontal: 16); // Horizontal/Vertical
๐ Spacing & EdgeInsets Extensions #
16.spacingY(); // SizedBox(height: 16)
8.spacingX(); // SizedBox(width: 8)
12.0.toAll; // EdgeInsets.all(12)
10.0.toSymmetric; // EdgeInsets.symmetric(horizontal: 10, vertical: 10)
๐ Emoji Replacement #
'I love :pizza: and :fries:'.withEmojis(); // I love ๐ and ๐
'Greetings from :india:'.withEmojis(); // Greetings from ๐ฎ๐ณ
๐ Clipboard Utility #
context.copyToClipboard('Secret Key', successMessage: 'Copied to clipboard!');
๐ง Debug Logging #
'Something went wrong'.log(); // Logs to debug console
'Page Loaded'.log(tag: 'INIT'); // [INIT] Page Loaded
๐ More Coming Soon... #
Weโre continuously improving Mplix โ more utility extensions, emoji packs, and integration widgets are on the way!