Importing a Project from Github and Running It on Educative

Setting up our application

In this lesson, we will set up an Android widget to run a Flutter App imported and cloned a json example application from GitHub. In the previous lesson, it was discussed that how we can use a sample app to test flutter. In this lesson, we will import a project from Github and use it in the Android widget.

Editor View Android Widget
Editor View Android Widget

Cloning the project

After selecting Android Widget and following the steps to select Flutter Framework. Now press Import code from Github button and paste the GitHub repository link in the text box, and hit Apply.

Github Repository Add Button in Android Widget
Github Repository Add Button in Android Widget

After applying you will see multiple folders and files appear in the code directory.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="dev.flutter.jsonexample">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Json Example Github code

Package Name

Now we have to move to the path android/app/src/main and look for the file AndroidManifest.xml and copy the package name.

Android Manifest file
Android Manifest file

Copy the package name and paste it in the Package name dialog box in Android Widget editor view.

Setting Package Name
Setting Package Name

Custom Script

After completing this we have to use specify a Custom Run / Build Script which is as follows:-

Press + to interact
cd /usercode && flutter upgrade && flutter build apk --debug --target-platform=android-arm && echo EDSTATUSCODE 1 && echo Build Completed
  • cd /usercode && flutter upgrade: Moving to our /usercode directory and upgrading flutter to latest version 2.10.5
  • flutter build apk --debug --target-platform=android-arm: builds the apk for the project using flutter build apk --debug --target-platform=android-arm command.
  • echo EDSTATUSCODE 1 && echo Build Completed : echo EDSTATUSCODE 1 && echo Build Completed. This command connects the virtual device and installs the apk on it and relaunches the virtual device (Genymotion).

Lets Run this code

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="dev.flutter.jsonexample">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>
A Flutter app that deserializes a set of JSON strings using three different libraries: dart:convert, json_serializable, and built_value.

Note: The above project may take upto 6 minutes because we are upgrading flutter to latest version as it is the requirement of the project.