To add a Check in Flutter when an App executes Resume from a background or terminated state, you can use the WidgetsBinding class’s addObserver method to listen for the LifecycleState changes. Here are some steps you can follow: Create a class that extends WidgetsBindingObserver: This is where you’ll put your resume logic. You can add…
Example of how to use the permission_handler package in Flutter
Here’s an example of how to use the permission_handler package in Flutter to check if the user has granted to the app the permissions it needs to function. Install permission_handler First, add the permission_handler package to your pubspec.yaml file: dependencies: flutter: sdk: flutter permission_handler: ^12.0.2 Then, run flutter pub get to install the package. Use…
When Files get Deleted with the Java API File.createTempFile
In the Java API, when you use the File.createTempFile() method, the temporary files created does not get automatically deleted when your program finishes or the file object goes out of scope. It is your responsibility to ensure the temporary file is deleted, either by explicitly calling the delete() method or by setting the file to…
How to Download a File with Dart and save it?
To Download a File in Dart with minimal memory usage, you can use the http package to stream the data directly to a file, avoiding loading the entire file into memory. Here’s an efficient way to download and save a file: Steps: Use the http package to make the request. Stream the response body directly…
IOException: Stream Closed – when having ResponseEntity – a file
The error java.io.IOException: Stream Closed indicates that the InputStream passed to the InputStreamResource has already been closed before it is read by the Spring framework to create the response. Use Case The use case where you may need to encounter this error is file download from Spring Boot App. Writing down bytes loaded in memory…
Mocking Dependencies with Mockito in Flutter
In Flutter development, mocking Dependencies is a crucial technique for isolating unit tests and ensuring that your codebase remains stable and efficient with the cross language library Mockito. Any developer with long enough experience has faced challenges of testing and maintaining complex software systems. In this article, we’ll explore the usage of Mockito in Flutter,…
How to format date and time to string in dart
You can use the intl package in Dart to format date and time variables and present them to your users in predefined pattern or in their local pattern. Here’s an example: First, add the intl package to your project by running the following command in your terminal: dart pub add intl Take into account the…
Flutter InkWell vs Button vs Material vs GestureDetector
There are several widgets to code Button behaviour in Flutter, besides the variations of Button, there are InkWell, Material & GestureDetector. 1. Material widgets Material: A widget that provides a material design background, but without actual behaviour MaterialButton: A button with a material design background with present ripple effect. // Material (Material) Material( elevation: 10,…
Internationalizing Flutter app with plain InheritedWidget
In this article I will be Implementing Internationalizing Flutter app from anywhere (within the app) with the help of arb files, plain InheritedWidget. I’ll be taking advantage and building on a previous article Flutter Localization with intl https://programtom.com/dev/2024/10/14/flutter-localization-with-intl/. MaterialApp fields Locale in a Flutter App is set through a locale field present in the Master…
shared_preferences is failing with Flutter 3.27
The update of Flutter to 3.27 is why it is good idea to have wrappers even for the components provided and developed by the Platform providers – in my case failing shared_preferences – especially when the provider is Google. Failing with issues There are several variations of issues: No implementation found for method getAll on…