try_catch_error 1.0.0 copy "try_catch_error: ^1.0.0" to clipboard
try_catch_error: ^1.0.0 copied to clipboard

With the help this package you can pass a future function inside a try catch block in one line.

A simple package for try catch error handling.

Features #

  • you can pass future function in try catch block in single line.

Getting started #

import 'package:try_catch_error/try_catch_error.dart';

Usage #

Future futureFunction() async {
  final res = await Future.delayed(const Duration(seconds: 2), () {
    // throw "some error";
    return [1, 2, 3];
  });
  return res;
}

void main() async {
  final res = await tryCatch(futureFunction: futureFunction);
  if (res["data"] != null) {
    print(res["data"]);
  } else {
    print(res["catch"]);
  }
}
0
likes
140
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

With the help this package you can pass a future function inside a try catch block in one line.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on try_catch_error