This article highlights the use of Flutter within the application Android Studio. Flutter is a useful framework to utilize when developing both Android and iOS apps. Projects can be easily started within IDE's such as Visual Studio Code, Android Studio, and IntelliJ.
MacinCloud's Dedicated Sever Plan is recommended for use with Flutter, as many dependencies that need to be installed separately may require sudo/admin privileges. Try a Mac Server to use with Flutter by obtaining a Dedicated Server Plan to quickly get started!
Note: If you are a beginner who wishes to try Flutter, you may try MacinCloud's Managed Server Plan with some limitations due to the lack of root/admin privileges.
Getting Started with Flutter:
- To Begin, open Android Studio and install the Flutter plug-in.
- Within Android Studio, navigate to Preferences > Plug-ins
- Search "Flutter" within the Plug-ins search bar, and install it. The plug-in should look like the image below:
- Install the Android SDK tools. This will allow you to accept licenses when you are setting up your environment for Flutter.
- In Android Studio, go to Preferences > Appearance & Behavior > System Settings > Android SDK.
- Check, "Android SDK Command-line Tools(Latest)" and click apply on the bottom of the window.
- If this is your first time opening Android Studio, please go through the setup wizard and when you see a HAXM pop up, you may press cancel to complete the installation.
- Install Flutter on the server. This is done by running the following command within terminal and your home directory:
git clone https://github.com/flutter/flutter.git -b stable
Verify that your environment is properly setup. Flutter offers a tool called Doctor that will check this for you. Run the following command by adding Flutter to your PATH or by going to the following directory ~/flutter/bin
If the following error is received:
Run the following command after you have installed the Android SDK Command-Line tools through Android Studio, as highlighted in step 2.
flutter doctor --android-licenses
We are now ready to start our first project. Open up Android Studio and click, "Create New Flutter Project". Set your Flutter path to the relative path to where you cloned the Github command. For this example, Flutter was downloaded to a MacinCloud server account home directory: /Users/<username>/flutter
Note: if the path is incorrect, you will see an error at the bottom stating, "Flutter SDK is not found in the specific location".
Set the location for your project, choose the languages of your preference for iOS and android. For this example, we used Swift and Kotlin. Finally, set your project name. It is important to note, all characters must be lowercase. When the project starts up, notice there is a starter project with the material framework already imported for you. Start by working off the main.dart file. Lets create two child widgets: one will be to center the data, and the other will be the widget that contains the data.
child: Text("Hello World!")
The entire main.dart file should now look like the image below.
At the top Menu Bar, choose the simulator of your choice and run your application by hitting the run button. An iPhone simulator should populate with the text, "Hello world!", at its center.
Interested in MacinCloud Dedicated Servers?
Visit the Dedicated Server Plan page to obtain a Dedicated Server.