In this post I’ll try to enumerate as detailed as possible – the steps to Build your Flutter Apps – Non-Cloud – on your machines and distribute the Cross-Platform Build to the appropiate location.
General Idea
You need a trigger that initiates a new build at it is commonly
- a git hook – after “push” (on the remote remote – shared by larger team).
It is common – to increase the semanticality of the Git history with git tags and they are often the triggers of build – with optional information inside the tag name like,
- deployment environment,
- build version (as int) – (incrementing by 1 every build),
- build as semantic 3 integers – major.minor.bug-fix.
Thanks to tags and filter in the hook – the initialization of the build may be done entirely from the git repository web platform – without a technical individual.
Steps
The steps that are executed – are not placed in the git hook script, because this will slow down the git merge operation – made from the developer. The different commands needed are placed – inside jenkins command line scripts (for non-cloud setup) or inside actions (for GitHub/Gitlab/etc).
Dev Steps 1
- Code your app
- update platform specific settings
- build.gradle (Android)
- Info.plist (iOS)
- index.html (Web)
- CMakeLists.txt (Windows, Linux, etc)
- update app icon:
- Git commit -m “message”
- Git push (after the server has folder with git init –bare)
Server Steps 2
The actual commands executed by the CI/CD Platform (Jenkins or Git Provider) are :
- git init –bare
- make hooks/post-update that curl that activates build
- ————— from here are actions in jenkins
- Git pull. The git providers contain all the source code. With Jenkins – it needs to have the credentials entered in the system – with special care – limit to access and permissions
- Get the source to the appropiate host platform (or tune the host OS – on the actions running platforms)
- Add some platform specific build steps listed below
- upload/distribute the package to the appropiate store or distribution center.
Flutter Web Build
With Flutter Web you may be able to serve all the platforms described below. This may be true, if all the data is on the backend and there are no special requirements of your app – for sensor data, client-side storage, lightening speed, performance, security. Otherwise – you may need the platform – specific app. You could offer partial functionality from the web – as a bridge to the app or to clients that do not want another app on their device. The steps are:
- “flutter build web”. Optionally append –profile –source-maps – if you have some issues and you cannot get the problem from the obfuscated code
- upload the content in build/web. If there is a change just in your Flutter business logic (no-dependencies or native code updates) – the only changed file will be main.dart.js
Flutter Android
Unfortunately – there are tons of App Stores For Android: https://programtom.com/dev/2023/06/24/application-stores-android-ios-windows-linux-macos/ The most popular one – as the origin of Android – is the Google Play Store. It allows distributing
- (Fat) APK – flutter build apk –release
- App Bundle – flutter build appbundle –release
For more details on how to integrate with a store – follow the instructions in this article: …..
If you don’t want to use the stores:
- your users must allow installation from third party sources
- you will need the APK app packaging
- you will need to upload it and make it accessible over the internet.
Flutter Windows Desktop
The prerequisites for building flutter app for Windows are the build tools for C++ Desktop Development: https://visualstudio.microsoft.com/downloads/?q=build+tools:
- C++ Compiler
- Cmake executable
- Visual Studio Build Tools 2022
- Visual Studio Build Tools 2019
- other windows specific tools
You need a pack of gigabytes free on your windows machine – as you may find harder to figure out what modules and libraries fit the Flutter version you have.
Actual Commands
To have ready to be executed package – you need to execute “flutter build windows”.
- runs outside of any sandbox
- signs the executable file with a dev certificate.
The moment you deliver your app, there will be a warning(s) on the machines of your client. For this to not appear
- you need to distribute your app through the windows store. The registration there you must make there protects users. They must know who is the app creator and have you responsible for any issues on the app
- have a key & certificate – signed or issued by key provider authority.
In terms of packaging – the better way is to create installable package – by using the msix plugin https://pub.dev/packages/msixdart run msix:create
Have in mind that – sometimes – flutter clean and flutter pub get – fixes some cached stuff issues. This you will not distribute flying exe, but a packaged and sandboxed installer.
Flutter iOS
You will need to setup first –
- pay Apple for Developer Account
- configure with xCode –
- provisioning profiles
- dev and prod certificates
- etc
After that you need “flutter build ios” (with potential environment parameters and settings)
Flutter macOS and Linux Desktop
Use “flutter build macos” and “flutter build linux”