In my flutter app, I am storing a list of quotes locally with SQFlite database. I want to create a scheduled local notification to display a different quote every day without opening the app (the quote to display should update in the background).
Please suggest a way to implement this.
I couldn't use a background execution plugin (like the work manager plugin) to make it working with the flutter_local_notifications plugin.
So, following this issue, I forked the local_notifications repository and customized it for my special use case. I saved the quote id with SharedPreferences on the Dart side and I write a custom function with native code for android to update this id every time the notification is displayed with the native SharedPreferences package for android (following this). Also, I read the quote with this id from the local SQL database (that is created on the Dart side) with the android native SQLite libraries. I didn't implement the ios part since my app isn't intended to work for ios yet.
After that, I commit the changes and pushed it to github and added this line to my flutter project dependencies:
dependencies:
git:
url: git://github.com/team324/flutter_local_notifications.git
path: flutter_local_notifications/
so I can make further changes and update the repository on github and write
flutter pub upgrade
in the terminal to update the local customized plugin.
Related
I have a current Flutter project which is linked to a Firebase project and is reading and writing from a Realtime Database. My issue is that I have used the wrong project and now want to switch my Flutter app to use a different Project's Realtime Database. Is it possible to switch the Firebase project my app is currently linked to and if so how do I go about doing that?
Thanks
The FlutterFire CLI is a great tool for quickly configuring Firebase resources for Flutter projects and it could be used to switch the Firebase project to which the configuration files in your Flutter project are pointed.
First you could want to set up the FlutterFire CLI by following the instructions on the Firebase site:
Install the Firebase CLI.
Log into Firebase using the Google account under which you have the new Firebase project you want to switch to set up by running the following command: firebase login
Install the FlutterFire CLI by running the following command from any directory: dart pub global activate flutterfire_cli
Then, after getting the FlutterFire CLI set up, it would probably be a good idea to make sure your current Firebase configuration is backed up some how, either using version control or manually.
Finally, to switch your Flutter configuration to a different Firebase project, run flutterfire configure and follow the steps in the workflow, making sure to select the new Firebase project.
I get this error in my Flutter Project,
C:\src\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in source_code... 34.3s
This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
The plugin firebase_core requires your app to be migrated to the Android embedding v2. Follow the steps on https://flutter.dev/go/android-project-migration and re-run this command.
Process finished with exit code 1
Flutter Embedding Error
Since Flutter 1.12 the way how Flutter plugins communicate with the native Android side has been improved. Allowing plugins to better integrate with the native Android lifecycle.
Some plugins support both the new and the old structure, however many plugins (like firebase_core) dropped support for the legacy structure to ensure optimal integration with the Android system.
Apps created using Flutter 1.12 and higher automatically generate the correct Android integration logic, however Flutter applications created with an earlier version of Flutter need to be manually migrated. There are two options to fix this for your app:
The easiest solution is to delete the android folder in your project and let Flutter (using Flutter 1.12 or higher) recreate it for you by running the following command in the root folder of the Flutter project: flutter create --platform=android . (don't forget the . at the end of the command). You should only do this if you haven't made any custom changes to the Android code and of course make sure to make a backup first.
The more safe option is to manually migrate the Android project using the instructions provided on the GitHub Wiki page mentioned in the error message.
When following the instructions on the GitHub Wiki page make sure to keep an eye on all the details. Personally I forgot to update the <application android:name="MyApp" to the recommended <application android:name="${applicationName}" which resulted in the same error you are reporting.
What helped me was to create a new "dummy" application with the latest version of Flutter (for example flutter create --platforms=android test_app) and compare the files in the Android folder with the files of my current App and make changes where necessary.
I want to use huawei_push kit in my flutter app but Google Play Store rejected my app because of PendingIntent issues (security rules). I want to use the same source code for Google Play Store and Huawei App Gallery. I was thinking of:
building APK based on flavor (huawei push kit dependencies won't be used in built APK),
using different pubspec.yaml files to avoid huawei push kit dependencies in the whole project.
Question:
How can I use huawei_push kit just for Huawei App Gallery still using the same source code for different stores?
Update:
The problem has been reported to R&D Team. And it's expected to be fixed in the next version.
At the same time, we provide a workaround solution. You may refer to this before next version release.(The Flutter plug-in is open source, so you can modify it directly)
Here's how to modify:
1.Open the pubspec.xml file in the root directory and find the plug-in.Like following:
dependencies:
flutter:
sdk: flutter
huawei_location: 5.0.0+301
You need to find the cache directory of the Flutter, for example:
Find the plug-in directory, for example:
If the plug-in points to a directory, for example:
dependencies:
huawei_location:
path: {library path}
directly access the directory.
2.Modify the build.gradle file in the android directory to modify the SDK version on which the file depends.
For example:
implementation 'com.huawei.hms:location:5.1.0.303'
P.S. The PendingIntent issue has been resolved in Push kit 5.3.0.304. So you can directly use this version.
After the modification, run the following command to trigger compilation:
flutter run
I want to show notifications on windows using Flutter. But I'm unable to do so.
I've tried packages like deskkop_notifications and flutter_local_notifications. But none seems to work. I've tried Cloud Firestore too but it doesn't support windows.
Also, I've read online that it doesn't matter which platform you use, the project will work fine. But that doesn't seem true for me.
Reference
Is there any way to do so? If not, then is there any other way to capture the user's attention? (when the app is running)
Something like this -
(Source - Google)
Extra - I am not talking of any specific kind of notification (like push notification), any type of notification will do.
Currently push notifications on Windows desktop don‘t seem to be possible. Your reference is about flutter push notification on the web. For windows desktop there currently aren’t any packages on pub dev. If Notification is a key feature of your App. You could make a WebApp first, and wait for a package which supports Windows desktop notifications…
Edit: There is a flutter_local_notifications package which supports local notifications on Android, iOS, MacOS and Linux.
There are packages available on pub that support desktop notifications.
try M_toast package
I've found this code for flutter home automation application.
but it was wrote in an older version of flutter, which i tried many times to start it but i couldn't make it,
last best thing that i have ever came to was that i could could mergrated the application to Android X and the application was starting but when i try to sign up a new mail inside it it says,
Error fetching data.
It dosen't use Firebase to store email it just uses a SQL package.
if any one can help to git the code and upgrade it for me to use it i will be very thankful :D.
Here is the link,
https://github.com/mlinarevicMateo/home-automation-flutter
The app is dependant on a webservice to run. Check lib/utils/network_util.dart. So you won't be able to get it run unless you write a new backend.
As the project was created in an older version of flutter you might be missing some latest flutter modules you can add those to your existing project by running this command within your project directory.
flutter create .