flutter_extend 0.1.2

SDKflutter
Platformandroidioswindowslinuxmacos

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!

FLUTTER EXTEND

Pub Version License Stars

🚀 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

  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!

🎨 Color Extensions – For When You Need to Make Things Pretty

🖍️ Global Color Extensions (Click to open)
ExtensionDescriptionExample
.getLighterShade(percent)Turns red into diet red (10% lighter)!Colors.red.getLighterShade(10)
.isDarkChecks if the color is dark. 🌑Colors.red.isDark
.isLightChecks if the color is light. 🌞Colors.red.isLight
.luminanceComputes 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
ExtensionDescription
context.hideKeyboard()Hides the keyboard when needed. ⌨️
context.safeSetState(callback)Performs safe setState operations. 🏷️
📱 MediaQuery Context Extensions
ExtensionDescription
context.isDarkModeDetects if your app has gone full Sith mode. 🌑
context.screenSizeRetrieves the full screen size. 📏
context.screenHeightMeasures how tall your app stands. 📏
context.screenWidthMeasures the width, because size matters. 📐
context.themeRetrieves the whole theme like a style guru. 👔
context.safePaddingRetrieves the safe padding from MediaQuery. 🛏️
context.orientationGets the screen orientation. 🔄
context.brightnessChecks platform brightness. 🌌
context.isKeyboardVisibleDetects if the keyboard is on screen. ⌨️
context.isLandscapeDetects if the device is in landscape mode. 🎢
context.isPortraitDetects if the device is in portrait mode. 🌆
↗️ Navigator Context Extensions
ExtensionDescription
context.navigateTo(page)Simplifies navigation to a new screen. 🚀
context.popScreen()Pops the current screen from the stack. ⏏️
💻 Platform Context Extensions
ExtensionDescription
context.isIOSChecks if the platform is iOS. 🌐
context.isAndroidChecks if the platform is Android. 📱
context.isWindowsChecks if the platform is Windows. 🖥️
context.isMacOSChecks if the platform is macOS. 💻
context.isLinuxChecks if the platform is Linux. 🐟
context.isFuchsiaChecks if the platform is Fuchsia. 🛶
🖍️ Theme Context Extensions
ExtensionDescription
context.themeRetrieves the whole theme like a style guru. 👔
context.textThemeRetrieves the text theme of the app. 🖊️
context.colorSchemeRetrieves the color scheme of the app. 🌐
context.iconThemeRetrieves 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)
ExtensionWhat 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)
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.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)
ExtensionWhat 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)
ExtensionWhat 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)
ExtensionWhat 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)
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.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
ExtensionExampleOutput
.days5.daysDuration(days: 5)
.hours5.hoursDuration(hours: 5)
.minutes5.minutesDuration(minutes: 5)
.seconds5.secondsDuration(seconds: 5)
.milliSeconds5.milliSecondsDuration(milliSeconds: 5)
.microSeconds5.microSecondsDuration(microSeconds: 5)
💰 Number Currency Extensions
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.isEmailValid()"badEmail.com".isEmailValid()false
.isPasswordValid()"weak12".isPasswordValid()false
.isValidURL()"weirdurl//".isValidURL()false
🌍 Global String Extensions (Click to open)
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.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
ExtensionExampleOutput
.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)
ExtensionExampleOutput
clickableMouseText('Click me').clickableMouse(onTap: () { print('Clicked'); })A text widget that shows a mouse pointer on hover and prints 'Clicked' on tap.
expandedText('Expanded').expanded()A text widget wrapped with an Expanded widget.
flexibeText('Flexible').flexibe()A text widget wrapped with a Flexible widget.
paddingText('Padded').padding(padding: EdgeInsets.all(16))A text widget with 16 pixels of padding on all sides.
alignText('Aligned').align(alignment: Alignment.centerRight)A text widget aligned to the center right of its parent.
clipImage.network('url').clip(borderRadius: BorderRadius.circular(8))An image widget clipped with an 8-pixel border radius.
removeScrollbarListView().removeScrollbar(context)A ListView without a scrollbar.
addScrollbarListView().addScrollbar(context)A ListView with a scrollbar.
visibilityText('Visible').visibility(visible: false)A text widget that is not visible.
invinsibleText('Invisible').invinsible()A text widget that is not visible.
visibleText('Visible').visible()A text widget that is visible.
addSelectionAreaText('Selectable').addSelectionArea()A text widget that can be selected.
centerText('Centered').center()A text widget centered within its parent.
🛠️ Scaffold Extensions (Click to open)
ExtensionExampleOutput
.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)
ExtensionExampleOutput
.addHyperLinksText('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! 🎉

KenStarry
KenStarry(Owner)
Enos Okello
Enos Okello
Mohammed Hisham
Mohammed Hisham

👥 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).


🔗 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. 🚀💙