flutter_extend 0.2.0 copy "flutter_extend: ^0.2.0" to clipboard
flutter_extend: ^0.2.0 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 Ultimate Cheat Code for Flutter Developers #

FLUTTER EXTEND

Pub Version Pub Points License Stars


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 **


โšก Why Use This? #

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()

โš’๏ธ Installation #

  1. Summon Flutter Extend into your project by adding this to your pubspec.yaml:
dependencies:
  flutter_extend: ^0.0.6
  1. Run this spell in your terminal:
flutter pub get
  1. 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! #

๐Ÿ”ฅ The "Wow" Features (New!) #

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.

๐ŸŽจ 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 #

We love our community! Big thanks to these wizards:

๐Ÿ›  Found something cool to add? **Please read our Contribution Guidelines before making a pull request. #

๐Ÿ 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. ๐Ÿš€๐Ÿ’™

Made with ๐Ÿ’™ by KenStarry

16
likes
0
points
363
downloads

Publisher

unverified uploader

Weekly Downloads

Simple, Efficient Flutter Extensions! Supercharge your Flutter development with a collection of easy-to-use, lightweight, and practical extension methods.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_animate, intl

More

Packages that depend on flutter_extend