flutter_helper_utils 3.1.0 copy "flutter_helper_utils: ^3.1.0" to clipboard
flutter_helper_utils: ^3.1.0 copied to clipboard

The Flutter Helper Utils Package offers various extensions and helper methods that can make development more efficient.

Flutter Helper Utils

Make Flutter development easier with Flutter Helper Utils! This toolkit is packed with helper methods and extensions that boost your productivity and help you write less code and build apps faster.

Flutter Helper Utils Logo

Table of Contents #

Helper Methods #

Converting Objects: #

Convert objects to various types, such as int, double, bool, String, List, Set and Map, They are handy when working with data from APIs, where you often encounter dynamic types. They offer simple and flexible methods to perform accurate type conversions. Here is a sample:

Before: #

Map = {score: "12.4"};


int score = double.parse(map['key']).toInt();

Notice that we need to parse to double first then to int.

With Package: #


int score = toInt(map['key']);

More Details here

Extensions #

Our package provides a variety of extensions on Dart and Flutter's built-in types. Below are the categories of available extensions, sorted by their functionalities:

Core Data Types #

String Extensions #

Number Extensions #

Boolean Extensions #

  • isTrue & isFalse - Checks if the Boolean values considering null safety.
  • val - Returns the Boolean value or false if it is null.
  • binary - Returns 1 if the Boolean is true and zero if it is false or null.
  • binaryText - Returns '1' if the Boolean is true and '0' if it is false or null.

DateTime Extensions #

  • format & tryFormat - format a DateTime object as a string using a specified format (e.g. "yyyy-MM-dd"), while tryFormat attempts to do the same but returns null if unsuccessful.
  • tryToDateTime - Safely attempts to convert a string to a DateTime object. Returns null if the conversion fails.
  • toDateTime - Converts a string to a DateTime object. Throw an exception if the conversion fails.
  • dateFormat - Returns a DateFormat object based on the string format provided.
  • toDateWithFormat - Converts a string to a DateTime object using a specific format.
  • tryToDateWithFormat - Safely attempts to convert a string to a DateTime object using a specific format. Returns null if the conversion fails.
  • timestampToDate - Converts a timestamp string to a DateTime object.
  • toSmallMonthName & toFullMonthName - Convert an integer representing a month to its abbreviated name.
  • toSmallDayName & toFullDayName - Convert an integer representing a day of the week to its abbreviated name.
  • View All DateTime Extensions

Duration Extensions #

  • delayed - Utility to delay some code execution.
  • fromNow - Adds the Duration to the current DateTime and gives a future time.
  • ago - Subtracts the Duration from the current DateTime and gives a pastime.

UI & Design #

Color Extensions #

  • toHex - Converts a Color object to its hex string representation.
  • toColor - Converts a hex color string to a Color object.
  • isHexColor - Checks if the given string is a valid hexadecimal color string.

Flutter Extensions #

ThemeExtensions #

  • themeData - Quickly get the current ThemeData from the nearest Theme widget ancestor.
  • txtTheme - Effortlessly obtain the TextTheme for your context.
  • brightness - Determine the brightness setting of the app theme.
  • sysBrightness - Determine the brightness setting of the system.
  • isDark & isLight - Convenient boolean to quickly check if the current theme is light or dark.

MediaQueryExtensions #

FocusScopeExtensions #

Exceptions #

The ConvertObject class throws a ParsingException if there is an error while converting an object. This exception provides information about the type of the object and the method used for conversion.

Contributions #

Contributions to this package are welcome. If you have any suggestions, issues, or feature requests, please create a pull request in the repository.

License #

flutter_helper_utils is available under the BSD 3-Clause License.

Buy Me A Coffee

29
likes
140
pub points
76%
popularity

Publisher

unverified uploader

The Flutter Helper Utils Package offers various extensions and helper methods that can make development more efficient.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, intl

More

Packages that depend on flutter_helper_utils