fluiver 1.0.0 copy "fluiver: ^1.0.0" to clipboard
fluiver: ^1.0.0 copied to clipboard

outdated

A dependency free, expressive extensions and helpers package focused on productivity.

fluiver #

A comprehensive package includes expressive extensions, common helpers and should have widgets.

The expressiveness the emulation of IDE behaviors rather than merely minimizing code verbosity, distinguishing itself from the typical approach of many packages in this regard.

Extensions #

BuildContext #

double screenWidth => MediaQuery.of(context).size.width
double screenHeight => MediaQuery.of(context).size.height

bool isPlatformDark => MediaQuery.of(context).platformBrightness == Brightness.dark
bool isPlatformLight => MediaQuery.of(context).platformBrightness == Brightness.light

bool isThemeDark => Theme.of(context).brightness == Brightness.dark
bool isThemeLight => Theme.of(context).brightness == Brightness.light

bool isOrientationPortrait => MediaQuery.of(context).orientation == Orientation.portrait
bool isOrientationLandscape => MediaQuery.of(context).orientation == Orientation.landscape

double topViewPadding => MediaQuery.of(context).viewPadding.top
double bottomViewPadding => MediaQuery.of(context).viewPadding.bottom
double bottomViewInset => MediaQuery.of(context).viewInsets.bottom

bool isLTR => Directionality.of(context) == TextDirection.ltr
bool isRTL => Directionality.of(context) == TextDirection.rtl

ColorScheme

Color {$type}Color => Theme.of(context).colorScheme.{$type}Color!

Examples:

Color primaryColor => Theme.of(context).colorScheme.primaryColor
Color tertiaryColor => Theme.of(context).colorScheme.tertiaryColor
Color onErrorColor => Theme.of(context).colorScheme.onErrorColor

TextTheme

TextStyle {$type}TextStyle => Theme.of(context).textTheme.{$type}!

Examples:

TextStyle headlineLargeTextStyle => Theme.of(context).textTheme.headlineLarge!
TextStyle bodyLargeTextStyle => Theme.of(context).textTheme.bodyLarge!
TextStyle labelMediumTextStyle => Theme.of(context).textTheme.labelMedium!

BorderRadius

add(double value)
myBorderRadius + BorderRadius.add$type$(double value);
Implementations

[addAll addLeft addTop addRight addBottom addTopLeft addTopRight addBottomRight addBottomLeft]

EdgeInsets

Add(double value)
myEdgeInsets + EdgeInsets.add$type$($type$: value);
Implementations

[addAll addLeft addTop addRight addBottom]

Set(double value)
myEdgeInsets.copyWith($type$: value);
Implementations

[setLeft setTop setRight setBottom setHorizontal setVertical]

Only
EdgeInsets.only($type$: value);
Implementations

[setLeft setTop setRight setBottom setHorizontal setVertical]

TextStyle

Color
TextStyle get withColor{$type} => textStyle.copyWith(color: {$type});

Example:

TextStyle get withColorWhite38 => textStyle.copyWith(color: Colors.white38);
TextStyle get withColorWhite   => textStyle.copyWith(color: Colors.white);
TextStyle get withColorBlack70 => textStyle.copyWith(color: Colors.black70);
ThemeColor
TextStyle get with{$type}Color => textStyle.copyWith(color: Theme.of(context).colorScheme.{$type});

Example:

TextStyle get withPrimaryColor(BuildContext context)   => textStyle.copyWith(color: Theme.of(context).colorScheme.primary);
TextStyle get withSecondaryColor(BuildContext context) => textStyle.copyWith(color: Theme.of(context).colorScheme.secondary);
TextStyle get withErrorColor(BuildContext context)     => textStyle.copyWith(color: Theme.of(context).colorScheme.error);
FontWeight
TextStyle get withWeight100 => textStyle.copyWith(fontWeight: FontWeight.w100);

Example:

TextStyle get withWeight100 => textStyle.copyWith(fontWeight: FontWeight.w100);
TextStyle get withWeight400 => textStyle.copyWith(fontWeight: FontWeight.w400);
TextStyle get withWeight700 => textStyle.copyWith(fontWeight: FontWeight.w700);
TextDecoration
with{$type} => textStyle.copyWith(decoration: TextDecoration.{$type});

Example:

withUnderline   => textStyle.copyWith(decoration: TextDecoration.underline);
withOverline    => textStyle.copyWith(decoration: TextDecoration.overline);
withLineThrough => textStyle.copyWith(decoration: TextDecoration.lineThrough);
Size
withSize(double size) => textStyle.copyWith(fontSize: size);

DateTime

TimeOfDay toTime(); /// Creates [TimeOfDay] from [DateTime]
DateTime truncateTime(); /// Sets '0' everything other than [year, month, day].
DateTime withTimeOfDay(TimeOfDay time); /// copies [hour, minute] from [time] and sets '0' everything smaller

DateTime addYears(int years);
DateTime addMonths(int months);
DateTime addWeeks(int weeks);
DateTime addDays(int days);
DateTime addHours(int hours);
DateTime addMinutes(int minutes);
DateTime addSeconds(int seconds);

bool get isToday;
bool get isTomorrow;
bool get isYesterday;

bool isWithinFromNow(Duration duration); /// Checks is difference between [DateTime.now()] and [DateTime] is smaller than [duration]

Map

bool any(bool Function(K key, V value) test); // Same as [Iterable.any]
bool every(bool Function(K key, V value) test); // Same as [Iterable.every]

MapEntry<K, V>? firstWhereOrNull(bool Function(K key, V value) test); // Same as [Iterable.firstWhereOrNull]
Map<K, V> where(bool Function(K key, V value) test); // Same as [Iterable.where]
Map<T, V> whereKeyType<T>(); // Same as [Iterable.whereType]
Map<K, T> whereValueType<T>(); // Same as [Iterable.whereType]

MapEntry<K, V>? entryOf(K k); // Similar to `[]` operator but returns [MapEntry]

Set

Set<E> subset(int start, [int? end]); // Creates a new sub [Set]

String

String capitalize();
String capitalizeAll({String separator = ' ', String? joiner});
/// Retrieves first letters of each word separated by [separator] and merge them with [joiner]
String initials({String separator = ' ', String joiner = ''});

Iterable

[1, 2, 3].to2D(2) // [[1, 2], [3]]
[[1, 2], [3]].from2D // [1, 2, 3]
[Foo(), Foo(), Foo()].widgetJoin(() => Divider()) // [Foo(), Divider(), Foo(), Divider(), Foo()]

IterableInt

int sum(); // sum of every element
double average(); // average value of iterable
Uint8List toBytes(); // Create a byte array from this

IterableDouble

double sum(); // sum of every element
double average(); // average value of iterable

IterableNum

T get lowest; // lower value in iterable
T get highest; /// highest value in iterable

Widgets #

FlexGrid #

A non-scrollable replacement for GridView where nested ScrollView. is a subject.

PaddedColumn #

A Column with Padding.

PaddedRow #

A Row with Padding.

ScrollViewColumn #

A Column inside SingleChildScrollView. Easy way to keep children alive.

Principles

Only commonly needed widgets and helpers implemented.

For extensions, few comparison will explain the motivation behind.

context.mediaQuery // BAD: hence, not implemented
MediaQuery.of(context) // GOOD: better fast read, more characteristic
// MediaQuery.of(context).viewInsets.bottom
context.mediaQuery.viewInsets.bottom // BAD: number of dots is same
context.bottomViewInset // GOOD: two dots less and decent readability
// Theme.of(context).textTheme.bodyMediumTextStyle!
context.bodyMedium // BAD: less expressive
context.bodyMediumTextStyle // GOOD: more expressive, better auto code-completion

Name

Name from Flutter + Quiver = Fluiver. Inspired from google/quiver-dart

5
likes
0
points
576
downloads

Publisher

verified publishermehmetesen.com

Weekly Downloads

A dependency free, expressive extensions and helpers package focused on productivity.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on fluiver