Is it safe to still use print() in dart (flutter 2.5.1), if not what command should I use to print errors?
if (query != null) {
_query.addAll(query);
}
return await dio.get(_url, queryParameters: _query);
} on DioError catch (e) {
print('DioError:$e');
}
CodePudding user response:
What you are getting is just a warning. You should throw
errors instead of printing it.
if (query != null) {
_query.addAll(query);
}
return await dio.get(_url, queryParameters: _query);
} on DioError catch (e) {
throw Exception(e);
}
CodePudding user response:
If you're inside a widget ,
Use debugPrint('data')
, because it'll only show data in debug mode and will not run in release mode. So, it'll save you a lot of time.
Otherwise , you can also use log('data')
, it'll show whole response in logging pattern in console.