maybe 0.4.0 copy "maybe: ^0.4.0" to clipboard
maybe: ^0.4.0 copied to clipboard

An helper for ensuring that values are checked before they are used.

example/main.dart

import 'package:maybe/maybe.dart';

class Update {
  final Maybe<String> title;
  final Maybe<String> description;
  Update({this.title, this.description});
}

void main(args) {
  // Update for the title, none for description
  var update =
      Update(title: Maybe.some("new title"), description: Maybe.nothing());

  // No update for title
  when(update.title, some: (v) {
    print("Updating title $v");
  });

  // if is also possible
  if(isNothing(update.title)) {
    print("No description");
  }

  // Fallback value
  print(some(update.description, "default description"));
}
0
likes
35
pub points
56%
popularity

Publisher

unverified uploader

An helper for ensuring that values are checked before they are used.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on maybe