req 1.0.0 req: ^1.0.0 copied to clipboard
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');
}