Generated by the Very Good CLI 🤖
A set of useful extensions and widgets for Flutter and Dart that I use regularly and that I have been collecting through the projects that I have been doing, StackOverflow questions, posts, etc...
Add usefull extensions package to your pubspec.yaml file:
dependencies:
usefull_extensions:
Import the library into your .dart
file:
import 'package:usefull_extensions/usefull_extensions.dart';
usefull_extensions
offers different extensions, for Objects, Widgets, Strings, etc...
This extension allows us to add a separator between each element of a List
Usage: joinWithSeparator
[
const Text('CARLOS'),
const Text('MOBILE SOLUTIONS'),
].joinWithSeparator(); // You can also specify your own separator Widget
//.joinWithSeparator(const SizedBox(height: 10));
This extension allows us to add a padding to a whole List, by default excludes flex Widgets, such as Expanded
, Spacer
or Flexible
Usage: spaced
[
const Text('CARLOS'),
const Text('MOBILE SOLUTIONS'),
].spaced(); // You can also specify your own EdgeInsetsGeometry
//.spaced(padding: const EdgeInsets.all(10));
This extensions emits a log event of the current object, and returns the length of the output log
Usage: log
final testString = 'My String';
testString.log();
// Outputs -> 'My String' as a log event
This extension allows us to safely unwrap a string, returning -
by default if it's null
Usage: unwrappedString
null.unwrappedString(); // '-'
null.unwrappedString('🍰'); // '🍰'
'My test'.unwrappedString('?'); // My test
This set of extensions allows us to find an entry based on key, value, or both
Usage: where
, whereKey
and whereValue
<String, int>{'John': 20, 'Mary': 21, 'Peter': 20}
..where((key, value) => key.length > 4 && value >= 20) // {Peter: 22}
..whereKey((key) => key.length < 5) // {John: 20, Mary: 21}
..whereValue((value) => value.isEven); // {John: 20, Peter: 22}
This extensions allows us to safely capitalize or title-case a String
Usage: toCapitalized
and toTitleCase
'carlos g'.toCapitalized(); // Carlos g
'carlos g'.toTitleCase(); // Carlos G
usefull_extensions
offers different Widgets
A list of spacers, both vertically and horizontally
Usage: VerticalSpacer
, HorizontalSpacer
and VerticalSpacerWithText
[
// Vertical
VerticalSpacer.xSmall(),
VerticalSpacer.small(),
VerticalSpacer.normal(),
VerticalSpacer.semi(),
VerticalSpacer.mediumSmall(),
VerticalSpacer.medium(),
VerticalSpacer.medium20(),
VerticalSpacer.mediumLarge(),
VerticalSpacer.large(),
VerticalSpacer.xLarge(),
VerticalSpacer.xxLarge(),
VerticalSpacer.xxxLarge(),
// Horizontal
HorizontalSpacer.small(),
HorizontalSpacer.normal(),
HorizontalSpacer.semi(),
HorizontalSpacer.mediumSmall(),
HorizontalSpacer.medium(),
HorizontalSpacer.medium20(),
HorizontalSpacer.mediumLarge(),
HorizontalSpacer.large(),
HorizontalSpacer.xLarge(),
HorizontalSpacer.xxLarge(),
// Vertical with text
VerticalSpacerWithText(text: 'example text'),
]
This extensions allows us to access a themedata based on the current context
final theme = context.theme; // Current ThemeData