Flutter Blog — 3

💠Flutter Integration with RHEL and FireBase

📱 Mobile App which can run Linux Commands and Retrieve their Output from FireStore

ANUPREET DUBE
Mobile App Development Using FLUTTER
4 min readMay 1, 2021

--

🔰Introduction to the Tools

🟦Flutter

Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.

In other words, Flutter is Google’s mobile app SDK, complete with a framework, widgets, and tools, that gives developers an easy way to build and deploy visually attractive, fast mobile apps on both Android and iOS platforms.

🟥 Linux: RHEL8

Linux is a family of open-source Unix-like operating systems based on the Linux kernel. Red Hat Enterprise Linux (often abbreviated to RHEL) is a Linux distribution developed by Red Hat for the commercial market. It is an Open Source Operating System with all the capabilities to edit and configure the OS files and customize the OS according to our requirements.

🟨FIREBASE

Firebase is a platform developed by Google for creating mobile and web applications. Firebase is a Backend-as-a-Service (Baas). It provides developers with a variety of tools and services to help them develop quality apps, grow their user base, and earn profit. It is built on Google’s infrastructure. Firebase is categorized as a NoSQL database program, which stores data in JSON-like documents.

📝Problem Statement

Our goal is to build a Custom Andriod App using FLUTTER with the following App Features :

  1. An Android app that can run any Linux command using API.
  2. The output of the command will be saved in Firestore.
  3. The App will retrieve this output from Firestore and print it on the App screen.

✔ SOLUTION

1️⃣ Create a Project in Firebase

  1. The first step will be to create an account on FIREBASE with the Google Login Credentials
  2. Create a new Project on Firebase Dashboard and give a Name to it. : FirebaseProj-1
  3. We will then be landed in the Project’s Dashboard
  4. Click on the Android Icon as shown below and follow the steps .
Firebase Project Dashboard

To complete the setting up of above Firebase project, we need an APP and an API to connect Firebase to the App. This is explained in the further steps.

2️⃣ API Creation

  1. Install and configure APACHE WEB SERVER in the Base OS.
  2. Run the following commands :
cd  /var/www/cgi-bin/
vim API.py

3. Write the following code in API.py file

Python script to create API

The code snippet will create an API via which we can execute Linux commands from a Webpage.

4. Make the file executable by running the following command :

chmod +x API.py

3️⃣ Create a Flutter APP

To get a UI interface for executing Linux command, we will create an Android Application using Dart Language.

Dart Code for Andriod App using Flutter Framework

Before executing the following code, update the Pubspec.yml File with the dependencies for this code.

Pubspec.yml File with the dependencies for FlutterAPI.dart

🔗The code for this application is uploaded in my Github Repository :

https://github.com/AnupreetDube/Flutter-Integration-with-RHEL-and-FireBase.git

💯OUTPUT

Final Application

The Andriod App with Simple UI has a TEXT BOX in which we can enter any Linux command, e.g. — ifconfig.

On clicking the EXECUTE button, the command will go to the Base OS (RHEL-8) and will get executed and the output of the command will be stored in FIREBASE.

On clicking the GET OUTPUT button, the utput will be retrieved from the FIREBASE and displayed on the Terminal of VSCode

Output stored in FIRESTORE

The App Development is still under process.

So finally, we have successfully created an Android Application via which we can remotely execute Linux Commands. ✨✨

--

--