handy_extensions 0.0.2 handy_extensions: ^0.0.2 copied to clipboard
Handy extensions for flutter
HandyExtensions #
Handy Extension is just a simple library with extensions to the core libraries to make them more handy and quicker to use.
I don't know how "deadly" this is but I just use it anyway.
Extensions On: #
Getting started #
Add as a dependency #
dependencies:
handy_extensions: ^0.0.2
Usage #
BuildContext #
Navigate To A Page
context.goTo(page: const Home());
Navigate To A Page Replacing The Current Page
context.goTo(page: const Home(), replace: true);
Go Back To The Previous Page
context.goBack();
Navigate To A Page And Remove History
context.goToRefresh(page: const Login());
Notify The User Using A SnackBar
context.notify(message: 'Hello World', isError: false); // You can pass the isError argument or leave it, it will default to false
Get Screen Size (based on MediaQuery)
// Height
context.height;
// Width
context.width;
double #
Makes use of this package money_formatter
Get Your Double Formatted As Money using the money property
10.money.symbolOnLeft; // => $ 10.00 (String)
1000.money.compactSymbolOnLeft; // => $ 1K (String)
Get comparison methods on your double using the compare property
10.compare.isEqual(10); // => true (bool)
Available methods for comparison:
Iteration #
firstWhereOrNull
List<String> list = ['a', 'b', 'c'];
String? character = list.firstWhereOrNull( (String item) => item == 'a'); // => 'a' (String) or null (null)
String #
Country Emoji
String country = 'ZW';
String emoji = country.countryEmoji; // => πΏπΌ (String)
Title Case
String title = 'hello world';
String titleCase = title.titleCase; // => Hello world
Heading Case
String heading = 'hello world';
String headingCase = heading.headingCase; // => Hello World
Additional information #
You can add in more extensions of your own -> share with the rest of the world.