

Stop writing boilerplate. Start writing magic. flutter_extend supercharges your development with intuitive
extensions for Widgets, Context, Data Generation, Animations, and more.
Get Started โข Documentation โข **Examples
**
Because you have better things to do than writing MediaQuery.of(context).size.width for the 100th time.
| The Old Way (Boring ๐ด) |
The Flutter Extend Way (Magic โจ) |
MediaQuery.of(context).size.width |
context.screenWidth |
Navigator.push(context, MaterialPageRoute(...)) |
context.push(NextPage()) |
Padding(padding: EdgeInsets.all(8), child: ...) |
myWidget.padding() |
| Googling "Lorem Ipsum generator" |
30.loremWords |
| Manually writing animation controllers |
myWidget.fadeIn().moveY() |
- 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).
| Feature |
Code Example |
Output |
| User Avatars |
user_123'.avatar(style: DiceBearStyle.adventurer) |
Generates a consistent, unique avatar URL using DiceBear API. |
| Placeholder Images |
300.placeholderImage(grayscale: true) |
A 300x300 grayscale image URL from Lorem Picsum. |
| Lorem Ipsum |
20.loremWords / 3.loremParagraphs |
"Lorem ipsum dolor sit amet..." |
| Mock UUIDs |
ExtendGenerator.uuid |
a1b2c3d4-e5f6... |
| Random Colors |
ExtendGenerator.randomColor |
A random opaque Color. |
| Credit Cards |
ExtendGenerator.randomCreditCard() |
A valid mock Visa/Mastercard number. |
๐๏ธ 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.
๐ง 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 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!
๐ก 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. ๐ผโก
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 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.
๐ 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 (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โฆ if I ever stop procrastinating.)
(Coming soon... currently summoning the code wizards for this one. ๐งโโ๏ธโจ)
We love our community! Big thanks to these wizards:
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. ๐๐
Made with ๐ by KenStarry