# Flutter Docs
# Firebase CLI commands
flutter pub add firebase_core
dart pub global activate flutterfire_cli
flutterfire configure
# In main.dart
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(MyApp());
}
# Web
# Web messaging fix error messages
create firebase-messaging-sw.js in your root folder and paste the code in it.
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('../firebase-messaging-sw.js')
.then(function(registration) {
console.log('Registration successful, scope is:', registration.scope);
}).catch(function(err) {
console.log('Service worker registration failed, error:', err);
});
}
# Fav Icon Maker
https://www.favicon-generator.org
# Firebase hosting custom site
{
"hosting": {
"site": "SITE_NAME",
"public": "web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
# Packages
# flutter_launcher_icons
flutter pub run flutter_launcher_icons:main
# The following section is specific to Flutter.
flutter_icons:
# image_path: "assets/images/icon-128x128.png"
image_path_android: "assets/icons/iconAndroid.png"
image_path_ios: "assets/icons/iconIOS.png"
android: true # can specify file name here e.g. "ic_launcher"
ios: true # can specify file name here e.g. "My-Launcher-Icon"
adaptive_icon_background: "assets/icons/iconB.png" # only available for Android 8.0 devices and above
adaptive_icon_foreground: "assets/icons/iconP.png" # only available for Android 8.0 devices and above
# Rename
flutter pub add rename
pub global activate rename
pub global run rename --bundleId com.onatcipli.networkUpp
pub global run rename --appname "Network Upp"
# Android
flutter build appbundle --release
# References
https://docs.flutter.dev/deployment/android https://www.youtube.com/watch?v=g0GNuoCOtaQ
# key.properties file
storePassword=password
keyPassword=password
keyAlias=upload
storeFile=../app/upload-keystore.jks
# Create an upload keystore
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
# Configure signing in gradle
- Add the keystore information from your properties file before the android block:
In android/app/build.gradle
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
- Find the buildTypes block:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
}
}
# iOS fix ARM pod bug
# Deintegrate
sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod clean
rm Podfile
rm -rf Pods Podfile.lock
# Cocoa Pods Installation in M1
sudo gem install cocoapods && sudo gem install ffi && arch -x86_64 sudo gem install cocoapods -n /usr/local/bin && sudo gem install cocoapods -n /usr/local/bin
# Install ffi
sudo arch -x86_64 gem install ffi
# update repo in iOS folder of flutter project
cd ios && arch -x86_64 pod install --repo-update && cd ..
# Flutter iOS builds
flutter clean
flutter build ios
# Re-install dependency in iOS folder of flutter project
arch -x86_64 pod install