Lab W11 Flutter
Lab W11 Flutter
Objectives:
1. Understand Flutter development with Android Studio
2. Understand Flutter project structure and widgets
3. Learn to develop a basic flutter application
Tasks:
1. Setup Flutter with Android Studio
2. Create the first Flutter Project
3. Create your Flutter To-Do Application
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.5.2 on Microsoft Windows [Version
10.0.17134.706], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version
28.0.3)
[√] Android Studio (version 3.2)
[√] VS Code, 64-bit edition (version 1.60.2)
[!] Connected device
Step 5 − Running the above command will analyse the system and show its
report as shown below –
Step 6 − Install the latest Android SDK, if reported by flutter doctor
Step 7 − Install the latest Android Studio, if reported by flutter doctor
Step 8 − Start an Android emulator or connect a real Android device to the
system.
Step 3: Select Flutter on the new project screen and click Next.
Step 4: On the new project screen add the following details for the project and
click Create.
Step 5 – Expand the project structure to analyse various files in the Flutter
project. Various components of the structure of the application are explained
here –
• android – Auto-generated source code to create an Android application
• ios – Auto-generated source code to create an iOS application
Step 6 – Select the emulator and click the run button to start the application.
To debug the application, add breakpoints at the required places and click on
the debug button.
The explanation for the code: Since we are going to use the navigation
system of GETX and other alerts and snackbar that’s why we have converted
MaterialApp to GetMaterialApp and we have provided our home screen as
TodoList().
Step 5 - Create a new folder Model and add a new dart file by right clicking
on the folder and select new option -> dart file. Copy the code from
model.dart from canvas to the newly created file.
Explanation: The model.dart file creates the models of our TODO application.
We will be only storing the title as Task. So, we have created a class Task and
provided a String title as the parameter.
Step 8 – Replace the pubspec.yaml file from Canvas with the project and click
on Pub Get or Pub Upgrade at the top of the file.
Step – 9 Select the emulator and click on the run button, Mac users could
start an iOS emulator and use it as well to run the application. On building the
application final screen should appear like the screenshots below.
Google Chrome:
MacOS:
References
The tutorial is partially adopted based on the materials from Flutter
Developer:
https://flutter.dev/docs/get-started/codelab
https://flutter.dev/docs/reference/tutorials
If you wish to set up Flutter app development environment, please refer to:
https://flutter.dev/docs/get-started/install/windows
https://flutter.dev/docs/get-started/install/macos