Hello. I'm Masaru Hirose.
I introduced the Masamune framework, which enables stable and fast development of applications in Flutter.
I would like to write several introductory articles to let you know its charm and how to use it.
By mastering the Masamune framework, you will be able to develop ultra-fast, stable, and high-quality applications.
In the previous issue, I talked about creating a project.
The second session is "Easy Connection to Firestore".
First, make Firestore available.
Create a project from the Firebase console.
Project ID that are created together here.
This time, I will create it with
GoogleAnalyitics is at your disposal.
A project is created.
Create a new Firestore.
The mode should be set to
region specified here.
asia-northeast1 is specified.
Firestore has been created.
Firebase configuration in a Flutter project
Return to the previously created Flutter project and reflect the Firebase settings.
Enter the Firebase project ID you just created in
project_id and set
# This section contains information related to Firebase.
# Set the Firebase project ID.
# Enable Firebase Firestore.
# Firebase Firestoreを有効にします。
enable: true # false -> true
# Enable Firebase Authentication.
# Firebase Authenticationを有効にします。
Open a terminal and login to the account where you created the Firebase project.
*If you have logged in to a different account, please log out and log in again.
Finally, run the
katana apply command.
This will create a configuration for the platform in the Firebase project and automatically create a configuration in the Flutter project to connect to Firebase.
import 'firebase_options.dart'; // Add
final modelAdapter = FirestoreModelAdapter(
// final modelAdapter = LocalModelAdapter();
// final modelAdapter = RuntimeModelAdapter();
When debugging, the counter application is launched.
If you count up, you can see that the data stored in Firestore has changed.
In the last issue, I explained the use of fields of type ModelCounter in the data model.
ModelCounter is used with
FieldValue.increment is used internally when the value is increased or decreased.
Thus, values can be increased or decreased without inconsistency even when many users access the same field.
With just a few lines of change, we were able to easily connect to Firestore.
Thus, the Masamune framework can be easily configured outside the Dart with a single command, and within the Dart, settings can be easily switched by replacing the adapter.
I will proceed with the actual application development in the next issue. Please look forward to it!
The Masamune framework is available here, and I welcome issues and PullRequests!
Sponsors are always welcome. Thank you for your support!