A set of utilities for improve your code readability and development.
Overview
Usage
Examples
Contributions
The goal of this library is offer utilities that will improve our code readability and improve our productivity on our development.
First import the library
import 'package:extendable/extendable.dart';
Now you can use all extensions available in this library!
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 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