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

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

Flutter Helper Utils Logo

Flutter Helper Utils #

Flutter Helper Utils is a comprehensive package aimed to augment Dart and Flutter's core functionalities. With a rich set of extensions and helper methods, this package boosts productivity and simplifies coding in Flutter projects.

Getting Started #

To get started, add the package to your pubspec.yaml:

dependencies:
  flutter_helper_utils: 1.5.5

Table of Contents #

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 - Checks if the Boolean value is true, considering null safety.
  • isFalse - Checks if the Boolean value is false or null.
  • val - Returns the Boolean value or false if it is null.
  • binary - Returns 1 if the Boolean is true and 0 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 #

Helper Methods #

ConvertObject: #

When dealing with data from APIs, we frequently encounter Map<String, dynamic> types. Parsing these dynamic types into your models can often result in type casting issues. The ConvertObject class aims to simplify this process, making it more reliable and efficient. For example

let's say we have Map<String, dynamic> from API response, and want to get the map['colors'] as List<String>

the value will actually be dynamic and casting this value into a list will result in List

final strList = ConvertObject.toList<String>(map['colors']);
// or using the global method.
final strList = toList<String>(map['colors']);

More Details here

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 on the repository.

License #

flutter_helper_utils is available under the BSD 3-Clause License.

Buy Me A Coffee

30
likes
0
pub points
80%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, intl

More

Packages that depend on flutter_helper_utils