Flutter App: Linux Terminal

Aman Jhagrolia
5 min readOct 15, 2020

--

I’ve created an app using Flutter framework to connect with Linux host over API and run commands. This app is also integrated with the Firestore database. After running a command it will fetch the output of it and store it in Firestore Database.

Flutter is an open-source UI software development kit created by Google. It is used to develop applications for Android, iOS, Linux, Mac, Windows, Google Fuchsia and the web from a single codebase.

An application programming interface (API) is a computing interface which defines interactions between multiple software intermediaries.

Here is my Github URL -

Video Demo -

About the App :-

Theme Mode - App theme will change according to system theme. If the device is in Light mode then the app will be in Light Theme and as soon as the device is changed to dark mode then the app theme will automatically be changed to Dark theme.

Terminal - We will land on the Terminal as we open the app. If the app is opened the first time, then by default the host is set to 127.0.0.1, but we can change it to our Linux Host by clicking on the icon (💻) in the app bar.

Terminal

Authentication — Security is the first need for any user. In this App, the authentication is directly done from our Linux Host. By default, the host is set as 127.0.0.1 but when we try to change the host it asks the username and password of that along with the IP Address.

This is exactly same as Linux, without login in the Linux OS we can’t get its shell to run any commands. So here also to run any command we have login by using our Linux host user credentials.

To Change Host - In the App Bar, we have a host icon (💻) by which we can change our host. When we tap on it, a pop-up dialog box will appear asking for the IP of the host along with the username and password.

Change Host Dialog

Providing the wrong IP - If we provide wrong IP or the IP which is not reachable then we can't connect to it. On this, a small Circular Awaitor will keep rotating till the time we not connected to IP. So we have to provide IP that is reachable and having the API enabled.

Wrong IP Test

Authentication Failure — After providing correct IP, if we provide the wrong user name or password it will show you an error.

If the username is wrong then it will show user does not exist and if the password is wrong it will show Authentication failure.

Wrong User or Password Test

Successful Authentication - After providing right credentials, the host is successfully changed and in the CMD prompt also the changes will reflect i.e. it will show the IP and the username by which you have logged-in in the CMD Prompt. Along with this, It will also show you some details about failed login attempts since your last successful login

Successful Authentication

Run Commands - After successful authentication, the host will be changed we are able to run commands with our app remotely in the Linux host.

Also if the screen got full we can run clear command to clear the screen.

Running the Commands

History to Firestore - As soon as we run command, that command and its output will be stored in the Firestore database and which is used to maintain the history.

When you run any command this app will maintain the history of them in firestore along with their output. In this app, side drawer is implemented which show us the History of commands that we have run. Each previously run command is maintained in a separate tile and when we tap on any of the command tiles then it will also show us the output of that command in a dialog box.

History Drawer

Output of History - By clicking on tiles in history drawer we can see the output of the command in both cases of successful or failed. It is now fetching the output from Firestore which was stored when the command was run.

Output from History

To Take Help - In the App Bar we also find the button for help. When you click on help Icon a Dialog box will appear showing some info.

Help Dialog

Changing the Colors - We can use Linux tput command to change the colours of the terminal.

Changing the Colors

We can also use the ‘reset’ or ‘tput reset’ command to Change the terminal colours to default.

Reset to Default

Thanks for Reaching out here, Hope this is helpful to you!!

--

--