Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

Follow publication

In-App update in Flutter Desktop using Github

--

In this blog, we will be looking at how to update your Flutter Desktop app using Github. Wait, What? Is that even possible? Yes, we can automatically update our app to the latest version by adding the exe and dmg file of our app to GitHub and downloading our latest app from there, and installing it on our local machine.

Let’s start by creating a New Flutter Project.

I have done some minor changes to the default boilerplate code.

Add these packages in your pubspec.yaml file

Create Version Check File

Create a new file in the app_version_check folder, this folder is under the project root directory.

Update your version.json file by adding some useful information like version, description is the updates detail information. Make sure your app version has be less than the version which you upload on Github.

MacOS Configuration

For Internet access Navigate to macos/Runner/DebugbugProfile.entitlements and macos/Runner/ReleaseProfile.entitlements and add <key>com.apple.security.network.client</key><true/> between the dict.

Your DebugProfile.entitlements will look like this.

Application Config

Create a new file application.dart and add the currentVersion.

Functionality

The checking for Updates functions loads the raw JSON file from GitHub which you have uploaded.

Decode the String that you got from the Github version and pass it to the Update Dialog.

If the version which we get from GitHub is greater than our AppConfig version then the update button will be visible. Once after clicking the update button, we are checking with the Platform of the application if it's windows then the windows file location will be passed else the macOS file location.

Downloading the New Version.

Here we are downloading the .exe or .dmg file using dio package. and here if the platform is windows then we are trying to open the EXE file using Process.

Create the builds

Now create the macOS build by running flutter build macOS and in windows run flutter build windows. Once done for windows make a single EXE build and for macOS make .dmg file.

Check this for making the .dmg file using NodeJS.

Check this blog for making an EXE file.

now inside the app_versions_check folder add the .dmg and .exe file.

Push all your files and changes made to Github

Now you can download the latest version from Github.

macOS Outputs.

Windows Outputs

But in windows, it will open the .exe file for you automatically whereas in macOS we need to navigate to the folder location and then install it.

Hurrah! and we are done with the In-App update in Flutter Desktop using Github. You can check my GitHub Repository for the entire Project.

Do you know you can press the clap👏 button 50 times? The higher you go, the more it motivates me to write more stuff for you guys!
Hello, I am Agnel Selvan. A noob developer. You can find me on Linkedin or stalk me on GitHub.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

Written by Agnel Selvan

A person who is learning Flutter Development, Shaders, OpenGL, and Augmented Reality.

Responses (3)

Write a response