Flutter App: Run Linux Commands
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 - https://github.com/jhagdu/flutter-linux-app.git
You can get Flutter Dart code of App, CGI Code and also the apk of my app from here.
About the App :-
Theme Mode - App theme will change according to system theme. If your device is in Light mode then the app will be in Light Theme and as soon as you change your device into dark mode then the app theme will automatically be changed to Dark theme.
Authentication - Security is the first need for any user. In this App, the authentication is directly done from you Linux Host. Every time when app is opened, you will land on the sign-in page. There you get only Login button, not a Register button. Actually, in this scenario you don't need to register on the app, this is not a normal sign-in page, this page is directly authenticating you from your Linux host user account and password. You have to put User name and password of your Linux host here and when you tap on login button app will go to Linux host using API and authenticate your identity.
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.
Authentication Failure - If you provide wrong user name or password it will show you an error. A red colour Toast will be popped up showing you the error reason. If your password is wrong it will show Authentication failure and if your username is wrong then it will show user does not exist.
Authentication Successful - If you provide right credentials then it will take you to the Home page with a login successful message in a green colour toast. Along with this, It will also show you some details about failed login attempts since your last successful login
Home Page - Here we are landed on our Home Page after successful authentication. Home page contains different flutter widgets. It has an App Bar with Title, two leading icons and a side drawer. And in body, a Text field is there with two buttons, we can write our Linux Command here and in order to run it tap on store output button.
To Change Host or Take Help - In the App Bar there are two leading icons, one for help and another for changing the host. When you click on help Icon a Dialog box will appear showing some info. To change the Linux Host IP click on the host icon in App Bar, this will open a dialog box in which you can enter new IP and click on change.
Run Commands - To run any command, write the command in the text field and then click on the Store Output button. This will run the command on the Linux system and fetch the Output from there and store the output in Firestore. Here on the app, it will show us the command successful or failed message accordingly.
Updated in FireStore - As soon as we run command, that command and its output will be stored in the Firestore database.
History - In this app, side drawer is also implemented which show us a 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.
The output of Command - By clicking on tiles in history drawer we can see the output of command whether it was successful or failed. It is now fetching the output from Firestore which was stored when the command was run.
Retrieve Complete Firestore Data - There is one more button of retrieve output in app body and when we tap on it, it will fetch the complete data of commands from Firestore and show it to us on the app.
Video Demo -
Thanks for Reaching out here, Hope this is helpful to you!!