Create your flutter projects by using the sample resources, and get your web/apk/ios builds right away
flutter create <project_name>Copy the necessary resource files from the repo
flutter build webflutter build web --web-renderer htmlRun the build in an emulator or chrome or press crtl+F5 for debubbing and run or just F5 to run without debugger attached.
flutter runGo inside IOS folder
cd iosDeintegrate IOS if needed
pod DeintegrateUpdate the latest Pod Version
pod Update- Debug Key Generation Get to terminal and enter
keytool -list -v -keystore ~/.android/debug.keystore -storepass android- Signed Key Generation
keytool -alias key0 -keystore your_keystore_name -storepass your_keystore_password -keypass your_key_password -list -v- Setup All firebase Features
- Firebase
AppCheck - Firebase
Authencation(AddGmailasnew providerinsidesign-in-method) - Firebase
Remoteconfig - Firebase
Database - Firebase
Cloudstorage - Firebase
Functions(Only forblazeplan)
- Add keys into the Firebase Projects
- Add a
IOSproject withcom.companyname.appname - Add an
Androidproject withcom.companyname.appname
- The app name or bundle name is used as identifier in
playstoreandappstore - Make sure you also purchase the domain
companyname.comfor better integration - If you have
companyname.indomain, it's also fine, but its better to take.comalso for future proofing - The default name would be
com.example.flutterprojectname
- Also change
build.gradleinside theappfolder inside android Go toandroid>> app >> build.gradleand change theapplicationIdto your owncom.companyname.appname
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.companyname.appname"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}- Also change in
android {
namespace "com.companyname.appname"
.....
.....
}- Also add google sign-in in
build.gradleaboveandroid namespace
apply plugin: 'com.google.gms.google-services'
android {
namespace "com.companyname.appname"
.....
.....
multiDexEnabled true //Make sure you add multi dex
}- Open the ios folder inside your flutter folder
- right click on the folder, and choose
open in xcode - Open the
runner, change the package name tocom.companyname.appname
ctrl+shift+Hfor find and replace- find
com.example.flutterprojectnametocom.companyname.appname
Make sure you enable the firebase services and also added your dev SHA1-key into the firebase console
- Then download
google-services.jsonand paste it insideandroid/app/alongsidebuild.gradle - Then download
GoogleService-info.plistand paste it insideios/runneralongsideinfo.plist - Also check the content inside each to verify, your
production-sha-keyanddeveloper-sha-keyare inside the json file - Make sure to write
gitignoreon public projects files, as these files holds the api key acccess for clientside.
# Ignore Google Services JSON files for Android in all Flutter projects
**/android/app/google-services.json
# Ignore Google Service Info plist files for iOS in all Flutter projects
**/ios/Runner/GoogleService-Info.plist- Refer
https://pub.dev/packages/google_sign_in - Copy the
REVERSED_CLIENT_IDfromGoogleService-info.plist - If you cant find the
REVERSED_CLIENT_ID, make sure you created and enabledgooglesignin fromauthenticationinsidefirebase console - If you are still facing error, make sure the
bundle IDis same in thexcodeand thefireabase console - Make sure you chane all profiles ,
debug,releaseandprofileto the samebundle id - Change the bundle id through out the app using
find and replaceoption.
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.3232323223-1urjaf9ia017upf6lsdfsfk3sekdfs9gq0c9d</string>- Add the whole code into
info.plistand also change theREVERSED_CLIENT_IDwith copied value
<!-- 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>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
</array>
</dict>
</array>
<!-- End of the Google Sign-in Section -->- If get error
impeller not connected, taking longer - Paste this code inside info.plist
<key>FLTEnableImpeller</key>
<false/>
- If you get error
[FirebaseCore][I-COR000005] No app has been configured yet., make sure you addWidgetsFlutterBinding.ensureInitialized();inmain()
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); // Ensure initialisation
await Firebase.initializeApp();
// await Get.put(Database()).initStorage();
runApp(const MyApp()); // This should be called after calling firebase and binding
}Change the build.gradle main file.
android {
namespace "com.companyname.appname"
.....
.....
multiDexEnabled true //Make sure you add multi dex
}-
Make sure you have added google-services.json in
android/app -
Make sure you have added
apply plugin: 'com.google.gms.google-services'in build.gradle (app) -
Make sure you have added
classpath 'com.google.gms:google-services:4.3.15'in build.gradle (main) -
build.gradle (app)
apply plugin: 'com.google.gms.google-services' //Add this to ensure the google-services intialisation
android {
namespace "com.companyname.appname"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}- build.gradle (main)
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.google.gms:google-services:4.3.15' // Add this inside dependency for firebase
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
- Even tho you have copied the file
GoogleService-info.plistinto the folder, it won't work - You need to manually add to
runnerviaxcode, reffer to the following link
https://firebase.flutter.dev/docs/manual-installation/ios/If you find yourself having gsm.google.service errors, its probably because your debug, production key are not updated on the cloud.google console, even tho you have added in firebase.google.com. If thats the case, you have to do the following steps
- Select the project and go to API and services>
- Credentials > Android key (Edit this auto created by firebase)
- Add the new Key (SHA-1 of the debug) and save
- Wait for 5 seconds
- Goto json to dart converter
https://javiercbk.github.io/json_to_dart/- Make the json for the datamodel
{
"name":"something",
"email":"something@gmail.com",
"date":"15/06/1999",
"time": "3:00 AM",
"timeinmill":5656565
}- Name the datamodel class as
dm_user - Generate the code
- Copy paste the code to
dm_user.dartunder theDataModelsfolder. - Remember to change the
fromJson,dm_user.fromJson(Map<String, dynamic> json)todynamic,dynamic> - Genereated Version
dm_user.fromJson(Map<String, dynamic> json) {
name = json['name'];
email = json['email'];
date = json['date'];
time = json['time'];
timeinmill = json['timeinmill'];
}- Right version
dm_user.fromJson(Map<dynamic, dynamic> json) {
name = json['name'];
email = json['email'];
date = json['date'];
time = json['time'];
timeinmill = json['timeinmill'];
}- To disbale yellow warning signs when using print functions
- go to
analysis_options.yamland uncommentavoid_print: falseto not show the warning
linter:
# producing the lint.
rules:
avoid_print: false # Uncomment to disable the `avoid_print` rule- Upgrade the
ext.kotlin_versioninsidebuild.gradleto
ext.kotlin_version = '1.7.10'- Upgrade the
tools.build:gradleinsidebuild.gradleto
classpath 'com.android.tools.build:gradle:7.3.0'- Add the following permission code inside the
info.plistin ios to get access tophoto library
<!-- Start of photo gallery Permisison -->
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to pick images for your profile.</string>
<!-- End of photo gallery Permisison -->- add in
pubspec.yaml
# show notification
flutter_local_notifications: ^16.1.0
# listen for notification
rxdart: ^0.27.7- add this to
ios>>Runner>>AppDelegate.swift - also add
importfunction on top of theAppDelegate.swift
import flutter_local_notifications- add this code inside the
boolfunction, above thereturncallback
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)}- just above the
returnstatement
// For notification
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}- sample code
import UIKit
import Flutter
import flutter_local_notifications //Import for notification
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// For notification
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)}
GeneratedPluginRegistrant.register(with: self)
// For notification
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
- add the
initialisationin themain.dart - it shoulde be inside the
mainfunction aboverunApp(const MyApp());
await NotificationService().initNotification();
runApp(const MyApp());- add to android manifest, for API 33 or greater
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> - add to main function, to request the acess, above
runApp(const MyApp());function
await Permission.notification.isDenied.then((value) {
if (value) {
Permission.notification.request();
}
});
runApp(const MyApp());- change the file at
/Users/name/.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart - from this
class _LANGANDCODEPAGE extends Struct {
@Uint16()
external int? wLanguage;
@Uint16()
external int? wCodePage;
}- to this
class _LANGANDCODEPAGE extends Struct {
@Uint16()
external int wLanguage;
@Uint16()
external int wCodePage;
}- In
Android, Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR KEY HERE"/>- In
IOS, go toAppDelegate.swiftand alsoimport GoogleMaps
import GoogleMaps
GMSServices.provideAPIKey("YOUR KEY HERE")- There is no method to actually refresh the page
- It can be done on
OninitorBuildstate - So the work arround is to use
asynconontapmethod - and calling
setstateafter the await
InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ActAddChapters(
widget.coursesdata.crKey.toString())),
);
setState(() {});
},
child: AddChaptersButton(),
),- Add these to manifest.xml on
android - Above the
applicationtag
<queries>
<!-- <package android:name="com.whatsapp" /> -->
<package android:name="com.android.chrome" />
<!-- <package android:name="org.telegram.messenger" /> -->
<package android:name="com.google.android.youtube" />
<!-- <package android:name="com.twitter.android" /> -->
<!-- <package android:name="com.instagram.android" />
<package android:name="com.facebook.katana" />
<package android:name="com.facebook.lite" /> -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>- Update the
pubspec.yaml - Change the
icon_backgroundto any color if you want
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.9.2
flutter_icons:
android: true
ios: true
remove_alpha_ios: true
image_path: "assets/images/stockexlogo.png"
min_sdk_android: 21 # android min sdk min:16, default 21
adaptive_icon_background: "#000000"
adaptive_icon_foreground: "assets/images/logo_foreground.png"- Create
logo_foreground.pngfrom
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html- Then finish by running
flutter pub run flutter_launcher_icons:main- find the uuid and add the simulator as test device in google mobile ads
xcrun simctl list- Update the
AndroidManifest.xmlunder<application>tag
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/admob_app_id" />
- Update
info.plist
<!-- Google Mobile Ads Section -->
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-93453535353535~1243242424</string>
<!-- End of the Google Ads Section -->
- Find simulator data
open ~/Library/Developer/CoreSimulator
- Deleting unused simulator
xcrun simctl delete unavailable
- Getting some space, deleting cache and other artifacts in android
open ~/.gradle/wrapper/dists/
open ~/.gradle/caches/
- Copy the following gradle files
build.gradle.ktsbuild.gradle.ktsin app alsosettings.gradle.ktsgradle-wrapper.propertiesinside the gradle/wrapperproguard-rules.profor minify- Then update the flutter packages to latest
- Update
local.propertieswith
flutter.ndkVersion=27.0.12077973
flutter.compileSdkVersion=36
flutter.targetSdkVersion=36
- Add gitignore
/android/app/.cxx/
- If already added, remove via terminal command
git rm -r --cached android/app/.cxx/