Chapter 1
Chapter 1
Chapter 1
Development
Chapter one: Introduction to Flutter
Development
compiled by Samuel. A
Android Debug Bridge (ADB) is a command line tool that lets you communicate
with a device, enabling you to access certain features of the Android platform that
are not otherwise accessible.
There are two ways to use adb: over a USB or Wi-Fi.
Installing ADB on Windows
Step 1: Download and install the latest Android Studio release.
Step 2: Once installed, click the More Actions button, and select SDK Manager from
the dropdown.
Step 3: In the SDK manager, click SDK Tools and select the following for installation:
◦ Android SDK Command-Line tools
◦ Android SDK Platform-Tools
◦ Google USB Driver
Step 4: Once installed, set the platform-tools file into the path.
◦ In your search bar, type environment and click “Edit the system environment
variables”.
◦ Click “Environment Variables”.
◦ Under “User variables,” click “New”.
◦ Set the variable name to “Android”.
◦ For the variable value, you need to find where your platform tools are located on
your hard drive. In general, when installed with Android Studio, it will live here:
C:\Users{Your username}\AppData\Local\Android\Sdk\platform-tools
◦ Note: You need to turn on the view hidden files function to access app data.
◦ Once you have verified the location of your platform tools, click “OK”.
Step 1: Connect Your Phone via USB Before setting up a wireless connection, make
sure you have previously connected your phone via USB for initial setup and
debugging. This step is necessary to install the necessary Flutter and Dart packages
on your device.
Step 2: Check ADB Installation Ensure that you have the Android Debug Bridge
(ADB) tool installed on your computer. You can check this by running the following
command in your terminal:
adb --version
If ADB is not installed, you can download it from the Android Studio or the
Android Command Line Tools.
Step 3: Find Your Phone’s IP Address You’ll need your phone’s IP address to
connect wirelessly. You can usually find this information in your phone’s network
settings or Wi-Fi settings. Note down the IP address.
Step 4: Start ADB Over TCP/IP On your computer, run the following command to
start ADB in TCP/IP mode:
adb tcpip 5555
Step 5: Connect to Your Phone Now, connect your phone to your computer
wirelessly using the IP address you noted earlier. Replace your_phone_ip with your
phone's IP address:
adb connect your_phone_ip:5555
Step 6: Verify the Connection To verify that your phone is connected wirelessly,
run the following command:
adb devices
You should see your device listed as connected over the network.
Step 7: Run Your Flutter App With the wireless connection established, you can
now run your Flutter app on your phone as if it were an emulator. Navigate to your
Flutter project’s directory and run the app using:
flutter run
Flutter will build and install the app on your connected phone.
Step 8: Debug Wirelessly You can now debug your Flutter app wirelessly. Any print
statements or error messages will appear in the terminal, just like when running the
app on an emulator or a physically connected device.
Step 9: Disconnect Wirelessly (Optional) If you want to disconnect your phone
from the wireless debugging, you can use the following command:
adb disconnect your_phone_ip:5555
OR
adb disconnect
Launch Visual Studio Code and open the command palette (with F1 or
Ctrl+Shift+P or Shift+Cmd+P). Start typing "flutter new". Select the
Flutter: New Project command.
Next, select Application and then a folder in which to create your
project. This could be your home directory, or something like C:\src\.
Once you’re done with that, it's time to create your first Flutter app by
using the command line:
Flutter now creates your project folder and VS Code opens it.
MOBILE APPLICATION DEVELOPMENT 24
Creating first Flutter project
Then execute this command and you should see the default Flutter
app running on your device or your emulator.
Caveat: In this app, you will find that by default, Flutter is using the
material design system, but you will not be attached to this. Flutter also
provides iOS-styled widgets (Cupertino Widgets) and both of them are
highly customizable, so you can even have your own styled app
The majority of the files and folders you will find are intended for configuration.
Let's take a look at the most important ones:
Android (folder): Contains a complete Android project, and it will be the one
in which your Flutter app will be “merged” when compiling to native code.
Inside this folder, you will find important files like build.gradle and
AndroidManifex.xml.
build (folder): Maintains the output of your Flutter app and will be managed
by Flutter’s SDK.
ios (folder): Contains a complete iOS project and will be the one in which
your Flutter app will be “merged” when compiling to native code.
Lib (folder): The folder where you will probably be working the most. It contains all
the .dart files to create the Flutter application and contains the main.dart file, which
is by default the entry point of the app.
test (folder): Holds all the automated tests that will check the functionality of the
code.
pubspec.yaml (file): Contains some metadata about the flutter application, but
most importantly it will be the palace to manage the project’s dependencies, so this
is the place to configure the external packages that will be used by your application.