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.

example/handy_example.dart

import 'dart:async';

import 'package:handy/handy.dart';

enum TestEnum {
  grouping,
  singleTest,
}

void main() async {
  print(TestEnum.grouping.toShortString());

  print(DateTime.now().rightTruncate(TimePrecision.hour));

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

  print(oneTen.random());
  print(oneTen.randomDouble());

  print(oneTen.clamp(0.9));
  print(oneTen.clamp(100));

  print(randomBool());

  Timer handle =
      Timer.periodic(const Duration(milliseconds: 500), (Timer timer) {
    print(timer.tick);
  });

  Cleaner<Timer> cleaner = Cleaner<Timer>((Timer timer) {
    timer.cancel();
  });

  cleaner.add(handle);

  Future.delayed(const Duration(seconds: 2));

  cleaner.cleanup();
}
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