Developed by Flow Labs 🚀
This starter kit was created to address the challenges of initializing a project. At Flow Labs, we identified recurring patterns when starting a project: state management, authentication, forms, alerts, snackbars, styles, authentication, users, rules and more. The idea behind this repository is to consolidate all the knowledge we’ve gained from building apps into a single resource.
This kit is not a "framework"; rather, it's a guide for initializing a project with useful tools, popular libraries, folder structures, widgets, and more. The key idea is flexibility: developers have the freedom to choose their preferred structure. The goal of this repository is to be a helpful starting point without imposing rigid constraints on developers.
- Android
- IOS
- Sign In
- Apple
- Sign Up
- Email/Password
- Validate Email
- Forgot Password
- Profile
- Preferences
- Lenguage
- Theme
- Light
- Dark
- Delete user
- Export data
- Auth
- Firestore
- Emulators
- Download Kit
- Firebase
- Install firebase CLI
- Create firebase projects
- Configuration services
- Authentication
- Apple
- Email and password
- Firebase Database
- Storage
- Functions
- Authentication
- Deploy
- Rules
- Flutter App
- Configuration initial project
- Install VGV project
- Add dependencies
- Copy the app_initial
- Set Firabase environments in the project
- Create the app
- Install the kit
- Configuration initial project
- Set plaforms
- IOS
- Set BundleId
- Set Min Version iOS
- Add Permissions
- Sign in with Apple
- Sign in with Google
- Android
- Set Namespace
- Update min-sdk-version
- Sign in with Google
- IOS
- Emulators
- Run emulators
- Functions
- Config App
- Export data from Firebase
- Firebase Auth
- Firestore
This is the first step to do something with the kit
git clone https://github.com/Flowlabsio/flutter_starter_kit.git <project-name>
cd <project-name>
# Open project with vscode
code .
# Download CLI
curl -sL https://firebase.tools | bash
# Or from npm
npm install -g firebase-tools
# Login in firebase
firebase login
We will go to create the firebase projects for each environment
- Open
firebase/Makefile
and rename the varPROJECT_NAME
Aclaration: If you will have more than three envirnments, add you other envirnments in the var ENVIRONMENTS
on firebase/Makefile
- Create the projects for each envirnments
cd firebase
make create_firebase_project
This command could be failed because the name is used on another project (and the names of the projects could be unique), if that happen try to run the next command for each failed project
firebase projects:create <project-name>-<env>
Or go to the console and drop the projects created and start again this process. Or create manually
This configuration is the basic setup to use the app_initial
this app use four services in Firabase, Authentication and Firestore Database, Storage and Functions
You must to cofig every services in each environment. Or if you want to only start with development
(or another) you can only set that and then the another environments
The Sign-in methods should be three
- Email and password (iOS and Android)
- Google (iOS and Android)
- Apple (iOS)
- Select "Google"
- Set enable and set the facing name (you can change this later)
You will see this title when you try to sign-in with Google in the app.
- Press "Save"
- Select "Apple"
- Press "Save"
- Select "Email/Password"
- Press "Save"
- Enter in "Firebase Database" and press in "Create Database"
- Choose a location
- Press "Create"
Both Storage and Functions will need to set a "Billing Account". This point is important because if you dont do that you won't be able to use this services instead with the emulators
- Go to the "Storage" section and press "Upgrade project"
- If you have an account, choose one of them, otherwise, create one
- Set a budget
- After that you will see the button "Get started", press it
- Select your location
- Press "Create"
- Press "Get started"
- Press "Continue"
- Press "Finish"
Go to /firebase
and select the project firebase use <project-name>-<env>
Deploy the rules to Firebase
firebase deploy --only firestore:rules
firebase deploy --only storage
This starter kit use the template of Very Good Ventures to generate the app. The team believe it's a great standard to lunch an app. Therefore we will follow the next steps to install the CLI and generate the app.
- Install the VGV CLI
dart pub global activate very_good_cli
- Run one by one the commands to create the project and leave every file and file in the root folder
# Go to the root of the project
# Create the project
very_good create flutter_app <project-name>
# Copy project files
rsync -avh --ignore-existing <project-name>/ .
# Delete the other project
rm -rf <project-name>
flutter pub add app_ui --path=./kit/app_ui
flutter pub add app_core --path=./kit/app_core
flutter pub add app_helpers --path=./kit/app_helpers
flutter pub add go_router \
equatable \
flutter_native_splash \
reactive_forms \
google_sign_in \
sign_in_with_apple \
firebase_core \
firebase_auth \
cloud_firestore \
firebase_storage \
image_cropper \
image_picker \
permission_handler \
shared_preferences
-
Delete the folder
lib/app
,lib/counter
,test/counter
-
Go to
test/app/view/app_test.dart
and paste this
import 'package:flutter_test/flutter_test.dart';
void main() {
group('App', () {
testWidgets('', (tester) async {
expect(true, true);
});
});
}
-
Replace the folder
lib/l10n/arb
bykit/app_initial/lib/l10n/arb
-
Move the
kit/app_initial/lib/src
tolib/
-
Go to
kit/app_initial/lib/bootstrap.dart.template
copy the content and paste inlib/bootstrap.dart
-
Run this command to fix the path's dependencies
./replace_text.sh ./lib "app_initial" "<project-name>"
flutter pub get
- Go to every
main_<env>
and fix theApp
dependencie
import 'package:<project-name>/src/app/app.dart';
- Delete the folder
kit/app_initial
Before to start with this step remember to finish all the steps about create projects in the "Firebase" section
- Instal flutterfire_cli to config the firebase console with the app
dart pub global activate flutterfire_cli
- Then config run this command
./configure_firebase.sh \
--project="<project-name>-<env>" \
--ios-bundle-id="com.<org>.<project-name>.<env>" \
--android-package-name="com.<org>.<project-name>.<env>" \
--env="<env>"
- Set the platforms
If you go to
At the seccion "Your apps", you will see your apps
Will apear four new files in environments/<env>/
.
* firebase_options.dart
* GoogleService-Info.plist
* google-services.json
* firebase.json
After run the project with vscode, this files with be paste in their correct position
* lib/firebase_options.dart
* ios/Runner/GoogleService-Info.plist
* android/app/google-services.json
* firebase.json
Repeat this process for each environment (if you configurated the other environment).
-
From the root of the project run
make <env>
to paste the firebase config files in their positions (this proccess in automatic with vscode) -
Go to
lib/bootstrap.dart
and uncomment this lines
/// UNCOMMENT THIS LIKE AFTER ADDING FIREBASE CONFIGURATION
// await Firebase.initializeApp(
// options: DefaultFirebaseOptions.currentPlatform,
// );
- Delete old
.git
withrm -rf .git
- Open xcode
open ios/Runner.xcworkspace
- Press on "Runner"
- Go to "Signing & Capabilities"
- Set the bundle id and team for each team (remember that the bundle id must match with the bundle id create in firebase console)
In the Podfile
set the min version in 13
(required by firebase_auth). Go to ios/Podfile
, paste
platform :ios, '13.0'
In the Podfile
paste in the final
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# You can remove unused permissions here
# for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=1',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
## dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',
]
end
end
end
- Press on "Runner"
- Go to "Signing & Capabilities"
- Press
- Add "Sign in with Apple"
- Go to
environments/<env>/GoogleService-Info.plist
and copy the value of the keyREVERSED_CLIENT_ID
and past it in theenvironments/<env>/Info.plist
in theCFBundleURLSchemes
If you can't find the REVERSED_CLIENT_ID
it's because the Sign in with Google configuration in firabase is missing.
<dict>
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- TODO Replace this value: -->
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
<string>[REVERSED_CLIENT_ID]</string>
</array>
</dict>
</array>
...
</dict>
- Go to
environments/<env>/GoogleService-Info.plist
and copy the value of the keyCLIENT_ID
and past it in theenvironments/<env>/env.json
in theGOOGLE_CLIENT_ID
{
...
"GOOGLE_CLIENT_ID": "<CLIENT_ID>",
...
}
- Intall the next package
flutter pub add --dev change_app_package_name
- Run the command
dart run change_app_package_name:main com.<org>.<project-name> --android
Go to android/app/build.gradle
and set minSdkVersion
...
minSdkVersion 23
...
- Excecute
# Debug
keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android
- Copy the
SHA1
and go to the firebase console
- Go to "Project settings"
And select the android app
- Press in "Add fingerprint"
-
Paste the
SHA1
and press "Save" -
Update the environment files with the command
./configure_firebase.sh
(check the documentation about generate if you forgot the process)
To use the emulators, it's necessary to choose a real firebase project, use one of created before (recommended dev environment).
Clarification: If you want to use any service in the emulator, that service must be activated in the firebase project, for example "Google Sign In", the provider of google should be activated to use it in the emulator
To start the emulator run
cd firebase
firebase use <project-name>-<env>
firebase emulators:start --import export/ --export-on-exit export/
Install the function dependencies (if you want to use it)
cd firebase/functions
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
In the app, uncomment this lines in the bootstrap.dart
/// USE EMULATORS
FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080);
await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
await FirebaseStorage.instance.useStorageEmulator('localhost', 9199);
Clarification: There isn't a "native" way to export the data from firebase and insert in the emulator,
# Select the project
firebase use <project-name>-<env>
# Export data
firebase auth:export export/firebase_users.json --format=JSON --project <project-name>-<env>
- Install
firestore-export-import
npm install -g firestore-export-import
- You have to generate new private key from "Project Settings" from Firebase Console.
- Go to "Service Account" tab
- And press "Generate new private key"
-
Move the key
serviceAccountKey.json
to the folderfirebase/
-
Run
cd firebase
firestore-export -a ./<service-account-key>.json -b ./<data-namefile>.json