import 'dart:developer' as developer;
sem o uso do pacote Logger
press: () async {
try {
int.parse('abc');
controller.doLogin();
} on Exception catch (error, stackTrace) {
developer.log(
'Login',
name: 'APP',
error: error.toString(),
stackTrace: stackTrace,
time: DateTime.now(),
);
}
}
press: () async {
try {
// Debugar sem condicional
developer.debugger();
// Debugar com condicional
developer.debugger(
when: controller.cpf.text == '99999999999',
);
controller.doLogin();
} on Exception catch (error, stackTrace) {
developer.log(
'Login',
name: 'APP',
error: error.toString(),
stackTrace: stackTrace,
time: DateTime.now(),
);
}
}
press: () {
try {
developer.inspect(this);
developer.inspect(controller.cpf.text);
controller.doLogin();
} on Exception catch (error, stackTrace) {
developer.log(
'Login',
name: 'APP',
error: error.toString(),
stackTrace: stackTrace,
time: DateTime.now(),
);
}
}
Resultado:
<inspected variable>
String:"99999999999"
<inspected variable>
_formKey:LabeledGlobalKey ([LabeledGlobalKey<FormState>#e0edb])
_location:_Location (AuthView:app_pages.dart)
_scaffoldKey:LabeledGlobalKey ([LabeledGlobalKey<ScaffoldState>#33ff0])
key:null
tag:null
press: () {
try {
// Calcular o tempo de execução assincrona - inicio
developer.Timeline.startSync('login_timeline');
controller.doLogin();
} on Exception catch (error, stackTrace) {
developer.log(
'Login',
name: 'APP',
error: error.toString(),
stackTrace: stackTrace,
time: DateTime.now(),
);
}
// Calcular o tempo de execução assincrona - fim
developer.Timeline.finishSync();
}
E na pagina DevTools pesquisar no "Timeline Events" o nome 'login_timeline':
press: () async {
final timelineTask = developer.TimelineTask();
timelineTask.start('login_timeline_async');
try {
await Future.delayed(const Duration(seconds: 2));
developer.inspect('teste');
} on Exception catch (error, stackTrace) {
developer.log(
'Login',
name: 'Abastece Mais',
error: error.toString(),
stackTrace: stackTrace,
time: DateTime.now(),
);
}
timelineTask.finish();
},