handy 1.0.6 copy "handy: ^1.0.6" to clipboard
handy: ^1.0.6 copied to clipboard

outdated

A collection of handy utilities that I found useful while writing my own programs.

This package is a collection of otherwise unrelated utilities that proved to be helpful to while creating Dart programs and Flutter apps.

Features #

Among the utilities implemented as of now, here are some of the notable ones:

  • Get the name of the enum without the preceding enum type name.
  • A cleaner class that performs cleanup on objects that need it.
  • A range class the encapsulates minimum and maximum values.
  • Generate inclusive random numbers between any range.
  • A Cache class that caches outputs for inputs.
  • <, <=, >, >= operators on the DateTime class.
  • Truncate values from a DateTime instance.

Usage #

Here's some example usage of this package.

import 'package:handy/handy.dart';

enum HelloWorld {
  hello,
  world,
  exclamationPoint
}

void main() {
  print(HelloWorld.exclamationPoint.toShortString()); // exclamationPoint
  print(HelloWorld.world.toShortString()); // world

  Range<int> oneTen = Range<int>(1, 10);

  DateTime now = DateTime.now(); // 2022-03-02 12:01:24.684

  print(now.rightTruncate(TimePrecision.hour)); // 2022-03-02 00:00:00.000

  print(oneTen.random()); // *3
  print(oneTen.randomDouble()); // *7.633

  print(oneTen.clamp(0.9)); // 1
  print(oneTen.clamp(100)); // 10
}
2
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A collection of handy utilities that I found useful while writing my own programs.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on handy