extendable

A set of utilities for improve your code readability and development.

style: effective dart Build

Topics

Overview
Usage
Examples
Contributions

Overview

The goal of this library is offer utilities that will improve our code readability and improve our productivity on our development.

Usage

First import the library

import 'package:extendable/extendable.dart';

Now you can use all extensions available in this library!

Examples

Let's suppose we need to compare if some object is null or not, we generally to this way

  String string;

  if (string  == null) {
    /// code
  }

  if (string  != null) {
    /// code
  }

But, how we can improve this? That's when the library comes to help.

  import 'package:extendable/extendable.dart';

  String string;

  if (string.isNull) {
    /// code
  }

  if (string.isNotNull) {
    /// code
  }

Much better, huh?

But, we offer some improvements on native functionalities of native libraries, for example the first method of a List. If we do this in a empty or null list:

  List list;
  List list2 = [];

  final first = list.first // NoSuchMethodError: The getter 'first' was called on null.

  final first2 = list2.first // Bad state: No element

With one of the functionalities on the ListUtil extension, you can do this way:

  import 'package:extendable/extendable.dart';
  
  List list;
  List list2;

  List list;

  final first = list.firstOrNull // Will get null

  final first2 = list2.firstOrNull // Will get null

Contributions

Contributions are welcomed!

  • Add your method to a existing util or create a new one for different libraries.

  • Write tests for it.

  • Write documentation for it.

  • Make a pull request to the main branch

Libraries

extendable
list
number
object
string