I am using Firebase Performance Monitoring for my Flutter app. I am using this package
dio: ^4.0.6
firebase_core: ^1.20.0
firebase_performance: ^0.8.2+1
I want to monitor the performance of network request custom URL for specific endpoints used in my app like this
It has been more than 24 hours already, but it is still collecting data, no data appears on the dashboard like the image above. what went wrong in here?
I believe I have put the correct URL, for example, my real URL is like this
https://api.myCompany.id/api/blueray/customer/profile
so I put specific custom URL in the firebase performance dashboard like this
api.myCompany.id/api/blueray/customer/profile
if I change the filter to 'All Network Request' like the image below, there is no record from our own backend/endpoint, it seems it only records the requests for some Google services.
am I missing something? I expect the data will automatically be collected by just installing that package above. do I need write some codes to populate the dashboard with data? or do I need to add native code?
I just add that package to my pubspec.yaml and run pub get, thats it
I want to get data from firebase to my flutter app. I created a collection at firebase but don't know how to use it on flutter. Already I've done the setup process between flutter and firebase and also added necessary dependencies. but now I need help to get data from firebase. collection name '0xethocity' ;
Here's the documentation, try to implement it by yourself. Let us know if you get stuck.
https://firebase.google.com/docs/flutter/setup?platform=ios
I'm developing a Flutter App, and one of the steps I need to take is to implement a way for user to increase/decrease the size of the text. For that, I'm thinking about making a slider in the settings page, which is quite straight-forward, but I don't know how to create a global value, change it (so it can't be a constant) and use it everywhere.
Any help is much is much appreciated !
You can store persistent data using shared_preferences or get_storage.
You can use the Hive framework to store the data locally on the device - https://docs.hivedb.dev/#/
First install Hive as a dependency and import it. Initialize Hive using Hive.initFlutter() (in the hive_flutter package).
Open a box using Hive.openBox("boxName"). Store the box as a variable - var box = Hive.box("boxName").
Add data into the box using box.put("key", "value").
Then you can access the data from anywhere you want by calling Hive.get("key").
I'm trying to make a visualizer using flutter and this dependency. But I'm unable to fetch the sessionId. How do I proceed?
You should look at this : github.com/iamSahdeep/FlutterVisualizers
It gives a full example of the lib
In Android, if I have the information I want to persist across sessions I know I can use SharedPreferences or create a SQLite database or even write a file to the device and read it in later.
Is there a way to save and restore data like this just using Flutter? Or would I need to write device-specific code for Android and iOS like in the services example?
There are a few options:
Read and write files: https://flutter.io/reading-writing-files/
SQLite via a Flutter plugin: https://github.com/tekartik/sqflite
SQLCipher via a Flutter plugin: https://github.com/drydart/flutter_sqlcipher
SharedPreferences via a Flutter plugin: https://github.com/flutter/plugins/tree/master/packages/shared_preferences
Localstore via a Flutter plugin: https://pub.dev/packages/localstore
If you are in a situation where you wanna save a small value that you wanna refer later. then you should store your data as key-value data using shared_preferences
Storing key-value data on disk
but if you want to store large data you should go with SQLITE
How to get Started with SQLITE in Flutter
however you can always use firebase database which is available offline
how to add firebase to your flutter project
Firebase for Flutter Codelab from google
Since we are talking about local storage you can always read and write files to the disk
Reading and Writing Files
Other solutions :
Simple Embedded Application Store database
A Flutter plugin to store data in secure storage
A late answer but I hope it will help anyone visiting here later too😁..
I will provide categories to save and their respective best methods...
Shared Preferences
Use this when storing simple values on storage e.g Color theme, app language, last scroll position(in reading apps).. these are simple settings that you would want to persist when the app restarts..
You could, however, use this to store large things(Lists, Maps, Images) but that would require serialization and deserialization.. To learn more on this deserialization and serialization go here.
Files
This helps a lot when you have data that is defined more by you for example log files, image files and maybe you want to export csv files.. I heard that this type of persistence can be washed by storage cleaners once disk runs out of space.. Am not sure as i have never seen it..
This also can store almost anything but with the help of serialization and deserialization..
Saving to a database
This is enormously helpful in data which is a bit complex. And I think this doesn't get washed up by disc cleaners as it is stored in AppData(for android)..
In this, your data is stored in an SQLite database. Its plugin is SQFLite.
Kinds of data that you might wanna put in here are like everything that can be represented by a database.
You can use shared preferences from flutter's official plugins.
https://github.com/flutter/plugins/tree/master/packages/shared_preferences
It uses Shared Preferences for Android, NSUserDefaults for iOS.
If you need to store just simple values like API token or login data (not passwords!), here is what I used:
import 'package:shared_preferences/shared_preferences.dart';
asyncFunc() async { // Async func to handle Futures easier; or use Future.then
SharedPreferences prefs = await SharedPreferences.getInstance();
}
...
// Set
prefs.setString('apiToken', token);
// Get
String token = prefs.getString('apiToken');
// Remove
prefs.remove('apiToken');
Don't forget to add shared_preferences dependency in your pubspec.yaml (preserve spacing format):
dependencies:
shared_preferences: any
You can use Localstorage
flutter pub add localstorage
1- Add dependency to pubspec.yaml (Change the version based on the last)
dependencies:
...
localstorage: ^4.0.0+1
2- Then run the following command
flutter packages get
3- import the localstorage :
import 'package:localstorage/localstorage.dart';
4- create an instance
class MainApp extends StatelessWidget {
final LocalStorage storage = new LocalStorage('localstorage_app');
...
}
Add item to lcoalstorage :
void addItemsToLocalStorage() {
storage.setItem('name', 'Abolfazl');
storage.setItem('family', 'Roshanzamir');
final info = json.encode({'name': 'Darush', 'family': 'Roshanzami'});
storage.setItem('info', info);
}
Get an item from lcoalstorage:
void getitemFromLocalStorage() {
final name = storage.getItem('name'); // Abolfazl
final family = storage.getItem('family'); // Roshanzamir
Map<String, dynamic> info = json.decode(storage.getItem('info'));
final info_name=info['name'];
final info_family=info['family'];
}
Delete an item from localstorage :
void removeItemFromLocalStorage() {
storage.deleteItem('name');
storage.deleteItem('family');
storage.deleteItem('info');
}
There are a few options:
Moor: Persistence library for Dart
https://pub.dev/packages/moor_flutter
Read and Write file
https://flutter.io/reading-writing-files/
Shared preferences plugin for flutter
https://pub.dev/packages/shared_preferences
SQlite for flutter
https://pub.dev/packages/sqflite
I was looking for the same, simple local storage but also with a reasonable level of security. The two solutions I've found that make the most sense are flutter_secure_storage (as mentioned by Raouf) for the small stuff, and hive for larger datasets.
I think If you are going to store large amount of data in local storage you can use sqflite library. It is very easy to setup and I have personally used for some test project and it works fine.
https://github.com/tekartik/sqflite
This a tutorial - https://proandroiddev.com/flutter-bookshelf-app-part-2-personal-notes-and-database-integration-a3b47a84c57
If you want to store data in cloud you can use firebase. It is solid service provide by google.
https://firebase.google.com/docs/flutter/setup
Hive (https://pub.dev/packages/hive) is very fast and flexible solution. But if you have experience with SQL; you can use SqfLite packages (https://pub.dev/packages/sqflite)