guard 1.0.2 copy "guard: ^1.0.2" to clipboard
guard: ^1.0.2 copied to clipboard

discontinued
outdated

Evauluates the function wrapping the body with try/catch and returns default value if error was raised

guard #

lesnitsky.dev GitHub stars Twitter Follow

Evauluates the function wrapping the body with try/catch and returns default value if error was raised

Installation #

pubspec.yaml:

dependencies:
  guard: ^1.0.2

Example #

import 'package:guard/guard.dart';

class User {
  final String name;

  User(this.name);
}

void main() {
  final items = [];
  guard(() => items.first, null); // null

  User user;

  guard(() => Text(user.name), Text('Loading...')); // Loading...

  user = User('John Brown');

  guard(() => Text(user.name), Text('Loading...')); // John Brown
}

License #

MIT

7
likes
0
pub points
5%
popularity

Publisher

verified publisherlesnitsky.dev

Evauluates the function wrapping the body with try/catch and returns default value if error was raised

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on guard