flutter_extend 0.1.2
flutter_extend: ^0.1.2 copied to clipboard
Simple, Efficient Flutter Extensions! Supercharge your Flutter development with a collection of easy-to-use, lightweight, and practical extension methods.
๐ฉ Flutter Extend โ The Magical Extensions Toolbox! #
๐ Welcome to the ultimate Flutter cheat code! This package brings you a collection of mind-blowing extensions that'll make your development experience smoother than a buttered-up otter sliding down a rainbow. ๐โจ
๐ Why Should You Care? #
Because Flutter Extend makes your life easier, that's why! Instead of writing boring repetitive code, let these extensions do the heavy lifting while you sip on your coffee โ (or energy drink, we donโt judge).
๐ Save time โ Fewer lines of code, more time for memes.
๐ Write cleaner code โ Your future self will thank you.
๐ง Look like a coding wizard โ Impress your teammates.
โ๏ธ Installation โ Get Started Faster than a Cheetah on Roller Skates #
- Summon Flutter Extend into your project by adding this to your
pubspec.yaml
:
dependencies:
flutter_extend: ^0.0.6
- Run this spell in your terminal:
flutter pub get
- Import the package and start your journey to developer enlightenment:
import 'package:flutter_extend/flutter_extend.dart';
BOOM. ๐ฅ Youโre now 10x more powerful (results may vary).
๐คฏ Behold, The Extensions That Will Blow Your Mind! #
๐จ Color Extensions โ For When You Need to Make Things Pretty #
๐๏ธ Global Color Extensions (Click to open)
Extension | Description | Example |
---|---|---|
.getLighterShade(percent) |
Turns red into diet red (10% lighter)! | Colors.red.getLighterShade(10) |
.isDark |
Checks if the color is dark. ๐ | Colors.red.isDark |
.isLight |
Checks if the color is light. ๐ | Colors.red.isLight |
.luminance |
Computes the luminance to determine brightness. ๐ | Colors.red.luminance |
.toHex() |
Converts red into that fancy #FF0000 format. | Colors.red.toHex() |
๐ฅ No more googling โFlutter color to hexโ like a caveman.
๐ Context Extensions โ Your Appโs Sixth Sense #
๐ง Global Context Extensions
Extension | Description |
---|---|
context.hideKeyboard() |
Hides the keyboard when needed. โจ๏ธ |
context.safeSetState(callback) |
Performs safe setState operations. ๐ท๏ธ |
๐ฑ MediaQuery Context Extensions
Extension | Description |
---|---|
context.isDarkMode |
Detects if your app has gone full Sith mode. ๐ |
context.screenSize |
Retrieves the full screen size. ๐ |
context.screenHeight |
Measures how tall your app stands. ๐ |
context.screenWidth |
Measures the width, because size matters. ๐ |
context.theme |
Retrieves the whole theme like a style guru. ๐ |
context.safePadding |
Retrieves the safe padding from MediaQuery. ๐๏ธ |
context.orientation |
Gets the screen orientation. ๐ |
context.brightness |
Checks platform brightness. ๐ |
context.isKeyboardVisible |
Detects if the keyboard is on screen. โจ๏ธ |
context.isLandscape |
Detects if the device is in landscape mode. ๐ข |
context.isPortrait |
Detects if the device is in portrait mode. ๐ |
โ๏ธ Navigator Context Extensions
Extension | Description |
---|---|
context.navigateTo(page) |
Simplifies navigation to a new screen. ๐ |
context.popScreen() |
Pops the current screen from the stack. โ๏ธ |
๐ป Platform Context Extensions
Extension | Description |
---|---|
context.isIOS |
Checks if the platform is iOS. ๐ |
context.isAndroid |
Checks if the platform is Android. ๐ฑ |
context.isWindows |
Checks if the platform is Windows. ๐ฅ๏ธ |
context.isMacOS |
Checks if the platform is macOS. ๐ป |
context.isLinux |
Checks if the platform is Linux. ๐ |
context.isFuchsia |
Checks if the platform is Fuchsia. ๐ถ |
๐๏ธ Theme Context Extensions
Extension | Description |
---|---|
context.theme |
Retrieves the whole theme like a style guru. ๐ |
context.textTheme |
Retrieves the text theme of the app. ๐๏ธ |
context.colorScheme |
Retrieves the color scheme of the app. ๐ |
context.iconTheme |
Retrieves the icon theme data. ๐ |
๐ก These context extensions always know whatโs up (literally).
๐ DateTime Extensions โ Manipulate Time Like Doctor Strange #
โณ DateTime Comparison Extensions (Click to open)
Extension | What It Does |
---|---|
.isToday() |
Is todayโฆ today? ๐ค |
.isPast() |
Confirms if your date is ancient. ๐ |
.isFuture() |
Predicts the futureโฆ kinda. ๐ฎ |
.isYesterday() |
Checks if it was Laundry Day. |
.isTomorrow() |
Future You says hello. ๐ |
๐๏ธ DateTime Formatting Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.timeAgo() |
DateTime(2024, 1, 1).timeAgo() | "1 year ago" |
.timeUntil() |
DateTime(2026, 1, 1).timeUntil() | "in 1 year" |
.monthName() |
DateTime(2024, 1, 1).monthName() | "January" |
.monthNameShort() |
DateTime(2024, 1, 1).monthNameShort() | "Jan" |
.dayName() |
DateTime(2024, 1, 1).dayName() | "Monday" |
.dayNameShort() |
DateTime(2024, 1, 1).dayNameShort() | "Mon" |
.slashedDate() |
DateTime(2024, 1, 1).slashedDate() | "01/01/2024" |
.weekNumber() |
DateTime(2024, 1, 1).weekNumber() | 1 |
๐ ๏ธ DateTime Manipulation Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.addDays(days) |
DateTime(2025, 1, 1).addDays(5) | DateTime(2025, 1, 6) |
.subtractDays(days) |
DateTime(2025, 1, 1).subtractDays(5) | DateTime(2024, 12, 27) |
.addMonths(months) |
DateTime(2025, 1, 1).addMonths(5) | DateTime(2025, 6, 1) |
.subtractMonths(months) |
DateTime(2025, 1, 1).subtractMonths(5) | DateTime(2024, 8, 1) |
.addYears(years) |
DateTime(2025, 1, 1).addYears(5) | DateTime(2030, 1, 1) |
.subtractYears(years) |
DateTime(2025, 1, 1).subtractYears(5) | DateTime(2020, 1, 1) |
.addBusinessDays(days) |
DateTime(2025, 1, 1).addBusinessDays(5) | DateTime(2025, 1, 8) |
๐ Master time manipulation and become the Flutter Time Lord!
๐ File Extensions โ Handle Files Like a Pro! #
๐ File Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.fileFormattedSize() |
File('path').fileFormattedSize() |
500 MB |
.filePath() |
File('path').filePath() |
/emulated/0/storage... |
.fileExtension() |
File('path').fileExtension() |
pdf, jpg, etc. |
.fileNameWithoutExtension() |
File('path').fileNameWithoutExtension() |
myAwesomeFile |
๐๏ธ Stop wrestling with file paths like itโs 1999!
๐ Future Extensions โ Async Like a Boss! #
๐ก Tired of waiting for your Futures like they're stuck in dial-up internet? Say hello to instant gratification! These extensions turn async from a patience test into a speedrun to successโno more unnecessary delays, retries, or timeout meltdowns!
๐ฐ๏ธ Future Extensions (Click to reveal the magic)
Extension | What It Does (In Normal-Person Terms) | Example |
---|---|---|
.wrapInCompleter() |
Turns your Future into a Completer like a pro. | myFuture.wrapInCompleter() |
.isComplete() |
Checks if a Future is donezo or still playing hard to get. | myFuture.isComplete() |
.retry(retries, delay) |
Gives your Future extra lives (great for network calls). | myFuture.retry(3, delay: Duration(seconds: 2)) |
.timeoutWithFallback(timeout, fallbackValue) |
Stops waiting after a timeout and gives a backup plan. | myFuture.timeoutWithFallback(Duration(seconds: 5), fallbackData) |
.runAfterDelay(delay) |
Hits snooze before running the Future. | myFuture.runAfterDelay(Duration(seconds: 2)) |
๐ Future Iterable Extensions (Click to reveal the magic)
Extension | What It Does (In Normal-Person Terms) | Example |
---|---|---|
.runWithLimit(limit) |
Runs multiple Futures at once, but limits how many run simultaneously. | myFutures.runWithLimit(3) |
.runWithLimitOrdered(limit) |
Runs multiple Futures in order, with limited concurrent executions. | myFutures.runWithLimitOrdered(2) |
๐ String Future Extensions (Click to reveal the magic)
Extension | What It Does (In Normal-Person Terms) | Example |
---|---|---|
.copyToClipboard() |
Copies a string to the clipboard like a sneaky ninja. | await 'Hello, world!'.copyToClipboard() |
๐ฅ Wave goodbye to async chaos and say hello to Future-powered hyperspeed! No more waiting in the async DMV lineโyour code is now on rollerblades. ๐ผโก
๐ฆ Generator Extensions โ Auto-Magic String Generation! #
NB: String generator methods should be used on Empty Strings for the best results.
๐ String Generator Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.generateLoremIpsum(wordCount) |
"".generateLoremIpsum(wordCount: 5) |
Lorem ipsum dolor sit amet |
.generateUUID(length) |
"".generateUUID(length: 10) |
Random UUID |
.generateClipboardContents(textIfNull) |
"".generateClipboardContents() |
Returns a String clipboard contents |
.generateRandomString(length) |
"".generateRandomString(10) |
Random 10-character string |
๐ Because manually typing random text is so last year!
๐ List Extensions โ Sorting, Chunking, and More! #
๐ List Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.firstOrNull() |
["hello", "world", "awesome"].firstOrNull() | hello |
.lastOrNull() |
["hello", "world", "awesome"].lastOrNull() | awesome |
.sortBy() |
["Urus", "BMW", "Aston Martin", "Ferari", "Lambo"].sortBy((car) => car) | ["Aston Martin", "BMW", "Ferari", "Lambo", "Urus"] |
.sortByAndReturnSorted() |
["Urus", "BMW", "Aston Martin", "Ferari", "Lambo"].sortByAndReturnSorted((car) => car) | ["Aston Martin", "BMW", "Ferari", "Lambo", "Urus"] |
.shuffled() |
["Urus", "BMW", "Aston Martin", "Ferari", "Lambo"].shuffled() | ["Ferari", "Aston Martin", "BMW", "Lambo", "Urus"] |
.chunked(size) |
["Urus", "BMW", "Aston Martin", "Ferari", "Lambo"].chunked(2) | [['Urus', 'BMW'], ['Aston Martin', 'Ferari'], ['Lambo']] |
๐ Because sorting lists manually is for mere mortals!
๐ข Number Extensions โ Math is Hard, Letโs Make It Easy #
๐ Number Duration Extensions
Extension | Example | Output |
---|---|---|
.days |
5.days |
Duration(days: 5) |
.hours |
5.hours |
Duration(hours: 5) |
.minutes |
5.minutes |
Duration(minutes: 5) |
.seconds |
5.seconds |
Duration(seconds: 5) |
.milliSeconds |
5.milliSeconds |
Duration(milliSeconds: 5) |
.microSeconds |
5.microSeconds |
Duration(microSeconds: 5) |
๐ฐ Number Currency Extensions
Extension | Example | Output |
---|---|---|
.toCurrency() |
100000.toCurrency() |
KES 100,000 |
.toAbbreviated() |
100000.toAbbreviated() |
100K |
๐ง Because numbers should work for you, not the other way around.
๐ค String Extensions โ Tame Your Text Like a Pro! #
๐ Validation String Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.isEmailValid() |
"badEmail.com".isEmailValid() |
false |
.isPasswordValid() |
"weak12".isPasswordValid() |
false |
.isValidURL() |
"weirdurl//".isValidURL() |
false |
๐ Global String Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.capitalizeFirstLetter() |
"hello".capitalizeFirstLetter() |
Hello |
.capitalizeFirstLetterOfEachWord() |
"hello world".capitalizeFirstLetterOfEachWord() |
Hello World |
.getLastNCharacters(n) |
"hello".getLastNCharacters(2) |
lo |
.mask(visibleCount) |
"helloworld".mask() |
he******ld |
.reverse() |
"hello".reverse() |
olleh |
.truncateName() |
"Ken Starry".truncateName() |
Ken S. |
๐ต๏ธ Regex String Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.extractDigits() |
"abc123".extractDigits() |
"123" |
.removeAllDigits() |
"abc123".removeAllDigits() |
"abc" |
.removeAllWordsStartingWithNumber() |
"1abc 2def ghi".removeAllWordsStartingWithNumber() |
"ghi" |
.isDigitsOnly() |
"12345".isDigitsOnly() |
true |
.isTextOnly() |
"abc".isTextOnly() |
true |
.removeAllWhiteSpaces() |
"a b c".removeAllWhiteSpaces() |
"abc" |
.getWords() |
"Hello world!".getWords() |
["Hello", "world"] |
๐ข String Formatter Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.capitalizeFirstLetter() |
'hello'.capitalizeFirstLetter() |
'Hello' |
.toTitleCase() |
'hello world'.toTitleCase() |
'Hello World' |
.toCamelCase() |
'hello_world'.toCamelCase() |
'helloWorld' |
.toSlug() |
'Hello World!'.toSlug() |
'hello-world' |
.toOrdinal() |
'23'.toOrdinal() |
'23rd' |
.toBase64() |
'Hello'.toBase64() |
'SGVsbG8=' |
.fromBase64() |
'SGVsbG8='.fromBase64() |
'Hello' |
๐ฐ String Currency Extensions
Extension | Example | Output |
---|---|---|
.thousandNumberFormat |
'100000'.thousandNumberFormat |
'100,000' |
.cleanNumbers |
'100,000'.cleanNumbers |
'100000' |
๐ Say goodbye to messy text handling forever!
๐ผ๏ธ Widget Extensions โ Supercharge Your Widgets! #
๐งฉ Widget Extensions (Click to open)
Extension | Example | Output |
---|---|---|
clickableMouse |
Text('Click me').clickableMouse(onTap: () { print('Clicked'); }) |
A text widget that shows a mouse pointer on hover and prints 'Clicked' on tap. |
expanded |
Text('Expanded').expanded() |
A text widget wrapped with an Expanded widget. |
flexibe |
Text('Flexible').flexibe() |
A text widget wrapped with a Flexible widget. |
padding |
Text('Padded').padding(padding: EdgeInsets.all(16)) |
A text widget with 16 pixels of padding on all sides. |
align |
Text('Aligned').align(alignment: Alignment.centerRight) |
A text widget aligned to the center right of its parent. |
clip |
Image.network('url').clip(borderRadius: BorderRadius.circular(8)) |
An image widget clipped with an 8-pixel border radius. |
removeScrollbar |
ListView().removeScrollbar(context) |
A ListView without a scrollbar. |
addScrollbar |
ListView().addScrollbar(context) |
A ListView with a scrollbar. |
visibility |
Text('Visible').visibility(visible: false) |
A text widget that is not visible. |
invinsible |
Text('Invisible').invinsible() |
A text widget that is not visible. |
visible |
Text('Visible').visible() |
A text widget that is visible. |
addSelectionArea |
Text('Selectable').addSelectionArea() |
A text widget that can be selected. |
center |
Text('Centered').center() |
A text widget centered within its parent. |
๐ ๏ธ Scaffold Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.addAnnotatedRegion() |
Scaffold().addAnnotatedRegion(statusBarColor: Colors.red, statusBarBrightness: Brightness.dark, navigationBarColor: Colors.blue, navigationBarBrightness: Brightness.light) |
A Scaffold widget with customized status bar and navigation bar colors and brightness. |
๐ Text Extensions (Click to open)
Extension | Example | Output |
---|---|---|
.addHyperLinks |
Text('Click here for more info').addHyperLinks(hyperLinkTexts: ['here'], onHyperlinkClicked: (word) => {}) |
A Text widget with the word "here" as a hyperlink that triggers the onHyperlinkClicked function. |
๐๏ธ Make your widgets do more with less code!
โณ Coming Soon โ The Future is Bright! #
๐ฆ Animation Extensions โ Because Motion is Magic! #
(Coming soonโฆ if I ever stop procrastinating.)
๐ญ Widget Generators โ The Magic is Brewing! โ๐ฎ #
(Coming soon... currently summoning the code wizards for this one. ๐งโโ๏ธโจ)
๐ค Contributors #
A huge shoutout to the amazing people who have contributed to making Flutter Extend even more awesome! ๐
๐ฅ Want to Contribute? #
๐ Found something cool to add? Please read our Contribution Guidelines before making a pull request.
๐พ Join the Fun! We love developers who break things (and then fix them).
๐ Useful Links โ Because Youโll Need โEm #
๐ Package on pub.dev
๐ GitHub Repo
๐ Flutter Documentation
๐ Dart Documentation
Examples #
๐ Enough talk, time for action! Want to see these extensions in action? Head over to our **examples directory ** directory and witness the magic firsthand! โจ ๐ See. Try. Enjoy. Repeat.
(Warning: May cause extreme excitement and spontaneous coding sprees.) ๐
๐ License โ Go Wild! #
This package is licensed under MIT, meaning you can use it, modify it, and show it off to your friends. ๐
๐ Thatโs it, folks! Now go forth and write Flutter code like an absolute legend. ๐๐