SlideShare a Scribd company logo
Application Programming
Flutter First Application
 In this section, we are going to learn how to create a simple application in
Android Studio to understand the basics of the Flutter application. To create
Flutter application, do the following steps:
 Step 1: Open the Android Studio.
 Step 2: Create the Flutter project. To create a project, go to File-> New-
>New Flutter Project. The following screen helps to understand it more
clearly.
 Step 3: In the next wizard, you need to choose the Flutter Application. For
this, select Flutter Application-> click Next, as shown in the below screen.
 Step 4: Next, configure the application details as shown in the below screen
and click on the Next button.
 Project Name: Write your Application Name.
 Flutter SDK Path: <path_to_flutter_sdk>
 Project Location: <path_to_project_folder>
 Descriptions: <A new Flutter hello world application>.
 After clicking the Finish button, it will take some time to create a project.
When the project is created, you will get a fully working Flutter application
with minimal functionality.
Installation Flutter in VSCode
 Step 1: Install Visual Studio Code
1. Download and Install:
1. Download Visual Studio Code from the official website.
2. Follow the installation instructions for your operating system.
 Step 2: Install Flutter and Dart Extensions in VS Code
1.Open VS Code.
2.Go to Extensions:
•Click on the Extensions icon in the Activity Bar on the side of the window or use
the shortcut Ctrl+Shift+X
3. Search for Flutter:
1. Type "Flutter" in the search bar.
4. Install Extensions:
2. Click on the "Install" button for the Flutter and Dart extensions by Dart Code
to enable Flutter development in VS Code.
 Step 3: Create a New Flutter Project
1. Open Command Palette:
•In VS Code, open the Command Palette by
pressing Ctrl+Shift+P.
2. Create New Project:
•Type and select Flutter: New Project.
•Choose the project type (e.g., Flutter Application).
•Select a location for the project and provide a name
3. Wait for Dependencies:
1. VS Code will create the project and download necessary
dependencies.
 Step4: Run Your Flutter App
1.Connect a Device:
•Ensure you have an emulator running or a physical device
connected to your computer.
2.Select Target Device:
•Click on the device selector in the bottom right corner to select
your target device.
3.Run the App:
•Press F5 or click on the Run icon in the left toolbar to start your
Flutter application.
 Step5: Check Flutter Installation
You can run flutter doctor in the terminal to check if everything is set
up correctly and see if there are any additional steps you need to take.
Command Line Installation
Step 1: Open Terminal
1. Open Visual Studio Code.
2. Open a Terminal:
o You can open the terminal within VS Code by selecting Terminal from the top menu
and then clicking New Terminal, or you can use the shortcut Ctrl + ` (the backtick key).
Step 2: Navigate to Your Desired Directory
1. Use the cd command to change to the directory where you want to
create your Flutter project. For example:
2. cd path_to_your_desired_directory
Step 3: Create a New Flutter Project
1. Run the following command to create a new Flutter project:
2. flutter create project_name
3. Replace project_name with the desired name for your project. For
example:
4. flutter create my_flutter_app
Step 4: Navigate into Your Project Directory
1. After the project is created, navigate into the project directory using:
2. cd project_name
3. For example:
4. cd my_flutter_app
Step 5: Open the Project in Visual Studio Code
1. You can open your newly created Flutter project in VS Code directly
from the terminal with the following command:
2. code .
3. The . indicates that you want to open the current directory.
Step 6: Run Your Flutter App
1. Ensure you have a device (either an emulator or a physical device)
connected, then you can run your Flutter app using the following
command:
2. flutter run
Step 7: Additional Commands (Optional)
1. To see a list of available options when creating a project, you can run:
2. flutter create --help
3. If you want to create a more specific type of project, such as a Flutter
plugin or package, you can specify that in the create command. For
example:
4. flutter create --template=plugin my_plugin
Step 8: Check Your Setup
1. If this is your first time using Flutter, it's a good idea to run:
2. flutter doctor
3. This command checks your environment and shows you any missing
dependencies you need to resolve.
Structure of Project
 .idea: .
 This folder is at the very top of the project structure, which holds the
configuration for Android Studio. It doesn't matter because we are not going
to work with Android Studio so that the content of this folder can be ignored.
 .android:
 This folder holds a complete Android project and used when you build the
Flutter application for Android. When the Flutter code is compiled into the
native code, it will get injected into this Android project, so that the result is
a native Android application. For Example: When you are using the Android
emulator, this Android project is used to build the Android app, which further
deployed to the Android Virtual Device.
 .ios:
 This folder holds a complete Mac project and used when you build the Flutter
application for iOS. It is similar to the android folder that is used when
developing an app for Android. When the Flutter code is compiled into the
native code, it will get injected into this iOS project, so that the result is a
native iOS application. Building a Flutter application for iOS is only possible
when you are working on macOS.
 .lib:
 It is an essential folder, which stands for the library. It is a folder where we
will do our 99 percent of project work. Inside the lib folder, we will find the
Dart files which contain the code of our Flutter application. By default, this
folder contains the file main.dart, which is the entry file of the Flutter
application.

.test: This folder contains a Dart code, which is written for the Flutter
application to perform the automated test when building the app. It won't be too
important for us here.
 We can also have some default files in the Flutter application. In 99.99 percent
of cases, we don't touch these files manually. These files are:
 .gitignore:
 It is a text file containing a list of files, file extensions, and folders that tells Git
which files should be ignored in a project. Git is a version-control file for tracking
changes in source code during software development Git.
 .metadata:
 It is an auto-generated file by the flutter tools, which is used to track the
properties of the Flutter project. This file performs the internal tasks, so you do
not need to edit the content manually at any time.
 .packages:
 It is an auto-generated file by the Flutter SDK, which is used to contain a list
of dependencies for your Flutter project.
 flutter_demoapp.iml:
 It is always named according to the Flutter project's name that contains
additional settings of the project. This file performs the internal tasks, which
is managed by the Flutter SDK, so you do not need to edit the content
manually at any time.
 pubspec.yaml:
 It is the project's configuration file that will use a lot during working with the
Flutter project. It allows you how your application works. This file contains:
 1) Project general settings such as name, description, and version of the
project.
 2) Project dependencies.
 3) Project assets (e.g., images).
 pubspec.lock:
 It is an auto-generated file based on the .yaml file. It holds more detail setup
about all dependencies.
 README.md:
 It is an auto-generated file that holds information about the project. We can
edit this file if we want to share information with the developers.
 Step 7: Let us understand the main.dart code snippet line by line.
 To start Flutter programming, you need first to import the Flutter package.
Here, we have imported a Material package. This package allows you to
create user interface according to the Material design guidelines specified by
Android.
 The second line is an entry point of the Flutter applications similar to the
main method in other programming languages. It calls the runApp function
and pass it an object of MyApp The primary purpose of this function is to
attach the given widget to the screen.
 it a widget used for creating UI in the Flutter framework. Here, the Stateless Widget does not
maintain any state of the widget. MyApp extends Stateless Widget that overrides its build The
build method is used for creating a part of the UI of the application. In this block, the build
method uses MaterialApp, a widget to create the root level UI of the application and contains
three properties - title, theme, and home.
 Title: It is the title of the Flutter application.
 Theme: It is the theme of the widget. By default, it set the blue as the overall color of the application.
 Home: It is the inner UI of the application, which sets another widget (MyHomePage) for the application.
 the MyHomePage is similar to MyApp, except it will return
the Scaffold Scaffold widget is a top-level widget after the MaterialApp
widget for creating the user interface. This widget contains two
properties appBar and body. The appBar shows the header of the app, and
body property shows the actual content of the application.
Here, AppBar render the header of the application, Center widget is used to
center the child widget, and Text is the final widget used to show the text
content and displays in the center of the screen.
 Step 8: Now, run the application. To do this, go to Run->Run main.dart, as
shown in the below screen.
Home Work!
Difference between Flutter and React Native
 Step 9: Finally, you will get the output as below screen.
Ad

More Related Content

Similar to Application Programming and continuing.pptx (20)

How to develop a Flutter app.pdf
How to develop a Flutter app.pdfHow to develop a Flutter app.pdf
How to develop a Flutter app.pdf
Smith Daniel
 
Android software development – the first few hours
Android software development – the first few hoursAndroid software development – the first few hours
Android software development – the first few hours
sjmarsh
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12th
Rishi Kumar
 
Android development session
Android development sessionAndroid development session
Android development session
Esraa Ibrahim
 
Bird.pdf
 Bird.pdf Bird.pdf
Bird.pdf
RebaMaheen
 
Classification of the document
Classification of the documentClassification of the document
Classification of the document
think_cloud
 
Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010
Lars Vogel
 
UNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptx
UNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptxUNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptx
UNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptx
LeeroyMugadza
 
Mobile Application Development class 002
Mobile Application Development class 002Mobile Application Development class 002
Mobile Application Development class 002
Dr. Mazin Mohamed alkathiri
 
A Complete Guide to Building Your First App with Flutter
A Complete Guide to Building Your First App with FlutterA Complete Guide to Building Your First App with Flutter
A Complete Guide to Building Your First App with Flutter
beppamgadu
 
Android session 1
Android session 1Android session 1
Android session 1
Ahesanali Suthar
 
Day2GDSC.pptx
Day2GDSC.pptxDay2GDSC.pptx
Day2GDSC.pptx
GDSCICOER
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
sanket1996
 
Final NEWS.pdf
Final NEWS.pdfFinal NEWS.pdf
Final NEWS.pdf
RebaMaheen
 
Final NewsApp.pdf
Final NewsApp.pdfFinal NewsApp.pdf
Final NewsApp.pdf
RebaMaheen
 
Google Android
Google AndroidGoogle Android
Google Android
Michael Angelo Rivera
 
I os application bundle by flutter
I os application bundle by flutterI os application bundle by flutter
I os application bundle by flutter
Concetto Labs
 
Ios application bundle by flutter
Ios application bundle by flutterIos application bundle by flutter
Ios application bundle by flutter
Concetto Labs
 
Android app development guide for freshers by ace web academy
Android app development guide for freshers  by ace web academyAndroid app development guide for freshers  by ace web academy
Android app development guide for freshers by ace web academy
Ace Web Academy -Career Development Center
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
Sandip Ganguli
 
How to develop a Flutter app.pdf
How to develop a Flutter app.pdfHow to develop a Flutter app.pdf
How to develop a Flutter app.pdf
Smith Daniel
 
Android software development – the first few hours
Android software development – the first few hoursAndroid software development – the first few hours
Android software development – the first few hours
sjmarsh
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12th
Rishi Kumar
 
Android development session
Android development sessionAndroid development session
Android development session
Esraa Ibrahim
 
Classification of the document
Classification of the documentClassification of the document
Classification of the document
think_cloud
 
Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010
Lars Vogel
 
UNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptx
UNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptxUNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptx
UNIT5newpart1pptx__2024_11_13_09_51_59 (1).pptx
LeeroyMugadza
 
A Complete Guide to Building Your First App with Flutter
A Complete Guide to Building Your First App with FlutterA Complete Guide to Building Your First App with Flutter
A Complete Guide to Building Your First App with Flutter
beppamgadu
 
Day2GDSC.pptx
Day2GDSC.pptxDay2GDSC.pptx
Day2GDSC.pptx
GDSCICOER
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
sanket1996
 
Final NEWS.pdf
Final NEWS.pdfFinal NEWS.pdf
Final NEWS.pdf
RebaMaheen
 
Final NewsApp.pdf
Final NewsApp.pdfFinal NewsApp.pdf
Final NewsApp.pdf
RebaMaheen
 
I os application bundle by flutter
I os application bundle by flutterI os application bundle by flutter
I os application bundle by flutter
Concetto Labs
 
Ios application bundle by flutter
Ios application bundle by flutterIos application bundle by flutter
Ios application bundle by flutter
Concetto Labs
 

Application Programming and continuing.pptx

  • 2.  In this section, we are going to learn how to create a simple application in Android Studio to understand the basics of the Flutter application. To create Flutter application, do the following steps:  Step 1: Open the Android Studio.  Step 2: Create the Flutter project. To create a project, go to File-> New- >New Flutter Project. The following screen helps to understand it more clearly.
  • 3.  Step 3: In the next wizard, you need to choose the Flutter Application. For this, select Flutter Application-> click Next, as shown in the below screen.
  • 4.  Step 4: Next, configure the application details as shown in the below screen and click on the Next button.  Project Name: Write your Application Name.  Flutter SDK Path: <path_to_flutter_sdk>  Project Location: <path_to_project_folder>  Descriptions: <A new Flutter hello world application>.
  • 5.  After clicking the Finish button, it will take some time to create a project. When the project is created, you will get a fully working Flutter application with minimal functionality.
  • 6. Installation Flutter in VSCode  Step 1: Install Visual Studio Code 1. Download and Install: 1. Download Visual Studio Code from the official website. 2. Follow the installation instructions for your operating system.
  • 7.  Step 2: Install Flutter and Dart Extensions in VS Code 1.Open VS Code. 2.Go to Extensions: •Click on the Extensions icon in the Activity Bar on the side of the window or use the shortcut Ctrl+Shift+X 3. Search for Flutter: 1. Type "Flutter" in the search bar. 4. Install Extensions: 2. Click on the "Install" button for the Flutter and Dart extensions by Dart Code to enable Flutter development in VS Code.
  • 8.  Step 3: Create a New Flutter Project 1. Open Command Palette: •In VS Code, open the Command Palette by pressing Ctrl+Shift+P. 2. Create New Project: •Type and select Flutter: New Project. •Choose the project type (e.g., Flutter Application). •Select a location for the project and provide a name 3. Wait for Dependencies: 1. VS Code will create the project and download necessary dependencies.
  • 9.  Step4: Run Your Flutter App 1.Connect a Device: •Ensure you have an emulator running or a physical device connected to your computer. 2.Select Target Device: •Click on the device selector in the bottom right corner to select your target device. 3.Run the App: •Press F5 or click on the Run icon in the left toolbar to start your Flutter application.
  • 10.  Step5: Check Flutter Installation You can run flutter doctor in the terminal to check if everything is set up correctly and see if there are any additional steps you need to take.
  • 11. Command Line Installation Step 1: Open Terminal 1. Open Visual Studio Code. 2. Open a Terminal: o You can open the terminal within VS Code by selecting Terminal from the top menu and then clicking New Terminal, or you can use the shortcut Ctrl + ` (the backtick key).
  • 12. Step 2: Navigate to Your Desired Directory 1. Use the cd command to change to the directory where you want to create your Flutter project. For example: 2. cd path_to_your_desired_directory Step 3: Create a New Flutter Project 1. Run the following command to create a new Flutter project: 2. flutter create project_name 3. Replace project_name with the desired name for your project. For example: 4. flutter create my_flutter_app
  • 13. Step 4: Navigate into Your Project Directory 1. After the project is created, navigate into the project directory using: 2. cd project_name 3. For example: 4. cd my_flutter_app Step 5: Open the Project in Visual Studio Code 1. You can open your newly created Flutter project in VS Code directly from the terminal with the following command: 2. code . 3. The . indicates that you want to open the current directory.
  • 14. Step 6: Run Your Flutter App 1. Ensure you have a device (either an emulator or a physical device) connected, then you can run your Flutter app using the following command: 2. flutter run Step 7: Additional Commands (Optional) 1. To see a list of available options when creating a project, you can run: 2. flutter create --help 3. If you want to create a more specific type of project, such as a Flutter plugin or package, you can specify that in the create command. For example: 4. flutter create --template=plugin my_plugin
  • 15. Step 8: Check Your Setup 1. If this is your first time using Flutter, it's a good idea to run: 2. flutter doctor 3. This command checks your environment and shows you any missing dependencies you need to resolve.
  • 17.  .idea: .  This folder is at the very top of the project structure, which holds the configuration for Android Studio. It doesn't matter because we are not going to work with Android Studio so that the content of this folder can be ignored.  .android:  This folder holds a complete Android project and used when you build the Flutter application for Android. When the Flutter code is compiled into the native code, it will get injected into this Android project, so that the result is a native Android application. For Example: When you are using the Android emulator, this Android project is used to build the Android app, which further deployed to the Android Virtual Device.
  • 18.  .ios:  This folder holds a complete Mac project and used when you build the Flutter application for iOS. It is similar to the android folder that is used when developing an app for Android. When the Flutter code is compiled into the native code, it will get injected into this iOS project, so that the result is a native iOS application. Building a Flutter application for iOS is only possible when you are working on macOS.  .lib:  It is an essential folder, which stands for the library. It is a folder where we will do our 99 percent of project work. Inside the lib folder, we will find the Dart files which contain the code of our Flutter application. By default, this folder contains the file main.dart, which is the entry file of the Flutter application.
  • 19.  .test: This folder contains a Dart code, which is written for the Flutter application to perform the automated test when building the app. It won't be too important for us here.  We can also have some default files in the Flutter application. In 99.99 percent of cases, we don't touch these files manually. These files are:  .gitignore:  It is a text file containing a list of files, file extensions, and folders that tells Git which files should be ignored in a project. Git is a version-control file for tracking changes in source code during software development Git.  .metadata:  It is an auto-generated file by the flutter tools, which is used to track the properties of the Flutter project. This file performs the internal tasks, so you do not need to edit the content manually at any time.
  • 20.  .packages:  It is an auto-generated file by the Flutter SDK, which is used to contain a list of dependencies for your Flutter project.  flutter_demoapp.iml:  It is always named according to the Flutter project's name that contains additional settings of the project. This file performs the internal tasks, which is managed by the Flutter SDK, so you do not need to edit the content manually at any time.
  • 21.  pubspec.yaml:  It is the project's configuration file that will use a lot during working with the Flutter project. It allows you how your application works. This file contains:  1) Project general settings such as name, description, and version of the project.  2) Project dependencies.  3) Project assets (e.g., images).  pubspec.lock:  It is an auto-generated file based on the .yaml file. It holds more detail setup about all dependencies.  README.md:  It is an auto-generated file that holds information about the project. We can edit this file if we want to share information with the developers.
  • 22.  Step 7: Let us understand the main.dart code snippet line by line.  To start Flutter programming, you need first to import the Flutter package. Here, we have imported a Material package. This package allows you to create user interface according to the Material design guidelines specified by Android.  The second line is an entry point of the Flutter applications similar to the main method in other programming languages. It calls the runApp function and pass it an object of MyApp The primary purpose of this function is to attach the given widget to the screen.
  • 23.  it a widget used for creating UI in the Flutter framework. Here, the Stateless Widget does not maintain any state of the widget. MyApp extends Stateless Widget that overrides its build The build method is used for creating a part of the UI of the application. In this block, the build method uses MaterialApp, a widget to create the root level UI of the application and contains three properties - title, theme, and home.  Title: It is the title of the Flutter application.  Theme: It is the theme of the widget. By default, it set the blue as the overall color of the application.  Home: It is the inner UI of the application, which sets another widget (MyHomePage) for the application.
  • 24.  the MyHomePage is similar to MyApp, except it will return the Scaffold Scaffold widget is a top-level widget after the MaterialApp widget for creating the user interface. This widget contains two properties appBar and body. The appBar shows the header of the app, and body property shows the actual content of the application. Here, AppBar render the header of the application, Center widget is used to center the child widget, and Text is the final widget used to show the text content and displays in the center of the screen.
  • 25.  Step 8: Now, run the application. To do this, go to Run->Run main.dart, as shown in the below screen.
  • 26. Home Work! Difference between Flutter and React Native
  • 27.  Step 9: Finally, you will get the output as below screen.