Using Flutter Stable 3.3.5 and dart 2.18.2 and logger 1.3.0, using the following code below, I’m able to see in logcat for Android the state change and printed response, but on iOS in xcode console I see nothing at all. It would appear that logger 1.3.0 does not output for xcode.
Does anyone know why the logger 1.3.0 package doesn’t output in the xcode console, only the print statements appear.
import 'package: log_printer.dart';
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final logger = getLogger('Lifecycle change');
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.resumed:
print:("resume");
logger.v("resume");
break;
case AppLifecycleState.inactive:
print"inactive");
logger.v("inactive");
break;
case AppLifecycleState.paused:
print("paused");
logger.v("paused");
break;
case AppLifecycleState.detached:
print("detached");
logger.v("detached");
break;
}
}
}
2
Answers
The issue was found to be with how xcode's console output handles the print statements from the logger 1.3.0 package, or rather does not. It was working in logcat as expected but failed to be displayed in the console for xcode.
I hope that if someone else should come across this problem with logger 1.3.0, it will help them in their troubleshooting endeavors.
so did you do it widgetbindingobserver ?