Here's how to use it to hide sensitive info when the app goes to the background. 🧵
How to set it up?
- add the WidgetsBindingObserver *mixin* to one of your classes (generally a State subclass)
- register the observer inside initState (and dispose it when done)
Then, just override the methods for the changes you want to keep track of.
In this case, we listen to app lifecycle changes and update a "foreground" flag via setState().
One useful application of this is to build a custom widget that hides sensitive user data any time the app is backgrounded.
This can be hooked up to the "builder" argument of MaterialApp.
That's it! You can now test this and check the logs when you background & foreground the app.
If you wanna learn more about WidgetsBindingObserver, the official documentation is your best friend:
If your users speak another language, you’ll need to localize your Flutter app 🗺
Here’s how to setup Flutter app localizations in just 5 minutes, using code generation.
Also covered: template vs non-template files and synthetic vs non-synthetic package. 👀
🧵
1️⃣ As a first step, we need to add the required packages to the pubspec.yaml file.
2️⃣ Create l10n.yaml at the root
✔️ arb-dir is the input folder where Flutter will look for the localized strings
✔️ output-dir is where the localizations classes will be generated
✔️ template-arb-file is the main template that contains a description for each localized message
What's the difference between errors and exceptions in Flutter?
→ Errors are programmer mistakes. They are fatal and we should not try to recover from them
→ Exceptions are failure conditions that are out of our control. We should handle them and recover gracefully
Thread 🧵
Errors are fatal and when they happen the program *cannot* recover normally.
→ we want to discover (and fix) them as early as possible in the development process
→ we should track them in production using a crash reporting solution, so that we can measure impact and severity