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

outdated

http get or post with timeout ( default 60 seconds )

req #

try call a async function , return value same as the function , on exception print error and ignore

use #

import 'package:req/init.dart';

Future<int> test1() async {
  await Future.delayed(Duration(seconds: 1));
  throw Exception('test error');
}

Future<int> test2() async {
  await Future.delayed(Duration(seconds: 1));
  return 1;
}

void main() async {
  print('await sleep 1 seconds');
  var r = await tryCatch(() => test1());
  print(r); //null
  print(await tryCatch(() => test2())); //1
  print('done');
}

1
likes
0
pub points
16%
popularity

Publisher

verified publisherrmw.link

http get or post with timeout ( default 60 seconds )

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on req