coodoo-io / coo_extensions

coo(l) extensions! A set of commonly used Dart/Flutter extension to ease development.
MIT License
0 stars 0 forks source link

coo_extensions

coo(l) extensions! A set of commonly used Dart/Flutter extensions to ease development.

Installation

To use this package, add coo_extensions as a dependency in your pubspec.yaml file.

dependencies:
  coo_extensions: ^0.1.1

Then, run flutter pub get to install the package.

Usage

String Extensions

Example:

import 'package:coo_extensions/string.extension.dart';

void main() {
  String? str = 'Hello World';

  // Check if the string is null or empty
  print(str.isNullOrEmpty); // Output: false

  // Obscure the string
  print(str.obscureText()); // Output: ***** *****
}

DateTime Extensions

Example:

import 'package:coo_extensions/date_time.extension.dart';

void main() {
  DateTime now = DateTime.now();

  // Check if the DateTime object is today
  print(now.isToday); // Output: true
}

BuildContext Extensions

Example:

import 'package:coo_extensions/build_context.extension.dart';

void main() {
  // Check if the app is in light mode
  print(context.isLightMode); // Output: true
}

Number Extensions

Example:

import 'package:coo_extensions/number.extension.dart';

void main() {
  num? number = 5;

  // Check if the number is between 0 and 10
  print(number.isBetween(0, 10)); // Output: true
}

Form Extensions

Example:

import 'package:flutter/material.dart';
import 'package:coo_extensions/form.extension.dart';

void main() {
  GlobalKey<FormState> formKey = GlobalKey<FormState>();

  // Check if the form is valid
  print(formKey.isValid); // Output: true or false
}

Contribution

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This package is licensed under the MIT License. See the LICENSE file for details.