Reputation: 3221
I'm new to flutter and i really want to know, is there a way to connect to a database server (for instance mysql) in flutter rather using firebase. I'm working on a smart parking system project where i need to insert the latitude and longitude of the parking area which is free into the database which is created in server and retrieve it whenever user requests for it. It would be great if anyone gives solution for above mentioned problem (Flutter with database).
Upvotes: 2
Views: 22651
Reputation: 29
Try using sqflite. It's a package you can include in your Flutter app that allows you to persist data to the local device. You will need to use the path_provider as well. Here is the link to the repository on Github https://github.com/tekartik/sqflite
Upvotes: 2
Reputation: 17849
Since Flutter is just a UI Framework, topics such as persistence and databases may be out of scope or may depend on the use case.
Flutter UI's can persist data (application state) for short periods of time in a manner that is really only useful for the purposes of creating a good User Experience (is this button click? is it green? etc.)
For persisting more useful data outside of the application and on the actual device, you may want to consider the Shared Preferences Plugin for Flutter.
Wraps NSUserDefaults (on iOS) and SharedPreferences (on Android), providing a persistent store for simple data. Data is persisted to disk automatically and asynchronously.
Now, if you require persisting data in any centralized manner (e.g. RDMS, Firebase, or any data persistence service) your options are:
It sounds like you need a central read/write data store, so your best bet may be to host a server that provides access to a database while exposing an API to Flutter for which you can use dart:io
to make requests.
Upvotes: 6