SlideShare a Scribd company logo
1 of 65
Flutter Architecture
Flutter architecture application mainly
consists
• Widgets
• Gestures
• Concept of State
• Layers
Widgets
• Widgets are the primary component of any flutter
application. It acts as a UI for the user to interact
with the application. Any flutter application is itself
a widget that is made up of a combination of
widgets. In a standard application, the root defines
the structure of the application followed by a
MaterialApp widget which basically holds its
internal components in place. This is where the
properties of the UI and the application itself is set.
Cont..
• MaterialApp Widget is a predefined class
in a flutter. It is likely the main or core
component of flutter. we can access all the
other components and widgets provided
by Flutter SDK
MaterialApp and Scaffold
• MaterialApp is a widget that introduces a
number of widgets Navigator, Theme that
are required to build a material design app.
Scaffold Widget is used under MaterialApp,
it gives you many basic functionalities, like
AppBar, BottomNavigationBar, Drawer,
FloatingActionButton, etc
Difference MaterialApp and Scaffold
• MaterialApp Widget is the starting point of your app,
it tells Flutter that you are going to use Material
components and follow the material design in your app.
• MaterialApp is a widget that introduces a number of
widgets Navigator, Theme that are required to build a
material design app.
• Scaffold Widget is used under MaterialApp, it gives
you many basic functionalities, like AppBar,
BottomNavigationBar, Drawer, FloatingActionButton,
etc.
• The Scaffold is designed to be the single top-level
container for a MaterialApp although it is not necessary
to nest a Scaffold.
Example
void main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: YourWidget(),
),
));
}
Cont..
• Inside Scaffold, there is usually an AppBar widget,
which as the name suggests defines the appbar of
the application. The scaffold also has a body where
all the component widgets are placed. This is where
these widget’s properties are set. All these widgets
combined form the Homepage of the application
itself. The Center widget has a property, Child,
which refers to the actual content and it is built
using the Text widget.
Layers
Flutter is packaged with three layers:
• Embedder (lowest layer)
• Engine
• Framework (highest layer)
Embedder layer
• An entry point is provided by a platform-specific
embedder, which coordinates with the underlying
operating system to access services such as
accessibility, rendering surfaces, and input.
• The embedder is written in a platform-specific
language, such as Java and C++ for Android,
Objective-C/Objective-C++ for iOS and macOS,
and C++ for Windows and Linux.
• Flutter code can be embedded into an existing
application as a module or as the complete
application’s content using the embedder.
Engine layer
• The engine layer is written in C/C++, and it takes
care of the input, output, network requests, and
handles the difficult translation of rendering
whenever a frame needs to be painted.
• Flutter use skia as its rendering engine and it is
revealed to the Flutter framework through the
dart : ui which wraps the principal C++ code in
Dart classes.
Framework layer
• The framework layer is the part where most developers
can interact with Flutter. The Flutter framework
provides a reactive and modern framework that is
written in Dart.
• Within the framework layer, it comprises of the
following:
• Rendering
• Widgets
• Material and cupertino
• It also has foundational classes and building block
services like animation, drawing, and gestures, which
are required for writing a Flutter application.
• Data layer: This layer is the one in charge of
interacting with APIs.
• Domain layer: This is the one in charge of
transforming the data that comes from the data layer.
• finally, we want to manage the state of that data and
present it on our user interface, that’s why we split
the presentation layer in two:
• Business logic layer: This layer manages the state
(usually using flutter_bloc).
• Presentation layer: Renders UI components based
on state.
Gesture
• The gesture system in Flutter has two separate layers. The
first layer has raw pointer events that describe the location
and movement of pointers (for example, touches, mice, and
styli) across the screen. The second layer has gestures
that describe semantic actions that consist of one or more
pointer movements
Gestures
• All physical form of interaction with a flutter
application is done through pre-defined gestures.
GestureDetectors are used for the same. It is an
invisible widget that is used to process physical
interaction with the flutter application. The
interaction includes gestures like tapping, dragging,
and swiping, etc. These features can be used to
creatively enhance the user experiences of the app
by making it perform desired actions based on
simple gestures.
Gesture Detect
• Gesture Detector in Flutter is used to detect the user's
gestures on the application. It is a non-visual widget.
Inside the gesture detector, another widget is placed and the
gesture detector will capture all these events (gestures) and
execute the tasks accordingly.
Concept of State
• State is information that (1) can be read
synchronously when the widget is built and (2) might
change during the lifetime of the widget. It is the
responsibility of the widget implementer to ensure that
the State is promptly notified when such state changes,
using State.
• State can be described as "whatever data you need in
order to rebuild your UI at any moment in time".
When the state of your app changes (for example, the
user flips a switch in the settings screen), you change
the state, and that triggers a redraw of the user interface.
Concept of State
• If you have ever worked with React js, you might be
familiar with the concept of a state. The states are
nothing but data objects. Flutter also operates on
similar turf. For the management of state in a
Flutter application, StatefulWidget is used. Similar
to the concept of state in React js, the re-rendering
of widgets specific to the state occurs whenever the
state changes. This also avoids the re-rendering of
the entire application, every time the state of a
widget changes.
Stateful and Stateless Widgets
• A widget is either stateful or stateless. If a
widget can change—when a user interacts
with it, for example—it's stateful.
• A stateless widget never changes. Icon ,
IconButton , and Text are examples of stateless
widgets.
Examples
• Stateless widgets are text, icons, icon buttons, and
raised buttons.
• A stateful widget is dynamic: for example, it can
change its appearance in response to events
triggered by user interactions or when it receives
data. Checkbox , Radio , Slider , InkWell , Form ,
and TextField are examples of stateful widgets.
Flutter Layouts
• The main concept of the layout mechanism is
the widget. We know that flutter assume
everything as a widget. So the image, icon, text,
and even the layout of your app are all widgets.
Here, some of the things you do not see on
your app UI, such as rows, columns, and grids
that arrange, constrain, and align the visible
widgets are also the widgets.
• Flutter allows us to create a layout by
composing multiple widgets to build more
complex widgets. For example, we can see the
Cont..
In the second image, we can see the visual layout
of the above image. This image shows a row of
three columns, and these columns contain an
icon and label.
Cont.
• In the above image, the container is a widget
class that allows us to customize the child
widget. It is mainly used to add borders,
padding, margins, background color, and many
more. Here, the text widget comes under the
container for adding margins. The entire row is
also placed in a container for adding margin
and padding around the row. Also, the rest of
the UI is controlled by properties such as color,
text.style, etc.
Layout a widget
• Let us learn how we can create and display a
simple widget. The following steps show how to
layout a widget:
• Step 1: First, you need to select a Layout
widget.
• Step 2: Next, create a visible widget.
• Step 3: Then, add the visible widget to the
layout widget.
• Step 4: Finally, add the layout widget to the
page where you want to display.
Types of Layout Widgets
• We can categories the layout widget into two
types:
1.Single Child Widget
2.Multiple Child Widget
Single Child Widgets
• The single child layout widget is a type of widget,
which can have only one child widget inside the
parent layout widget. These widgets can also
contain special layout functionality. Flutter provides
us many single child widgets to make the app UI
attractive. If we use these widgets appropriately, it
can save our time and makes the app code more
readable. The list of different types of single child
widgets are:
Example
• Container: It is the most popular layout widget
that provides customizable options for painting,
positioning, and sizing of widgets.
Center(
child: Container(
margin: const EdgeInsets.all(15.0),
color: Colors.blue,
width: 42.0,
height: 42.0,
),
)
Padding
• It is a widget that is used to arrange its child
widget by the given padding.
• It
contains EdgeInsets and EdgeInsets.fromLT
RB for the desired side where you want to
provide padding.
const Greetings(
child: Padding(
padding: EdgeInsets.all(14.0),
child: Text('Hello JavaTpoint!'),
),
Cont..
• Center: This widget allows you to center
the child widget within itself.
• Align: It is a widget, which aligns its child
widget within itself and sizes it based on
the child's size. It provides more control to
place the child widget in the exact position
where you need it.
Example
Center(
child: Container(
height: 110.0,
width: 110.0,
color: Colors.blue,
child: Align(
alignment: Alignment.topLeft,
child: FlutterLogo(
size: 50,
),
),
),
)
SizedBox:
This widget allows you to give the specified
size to the child widget through all screens.
SizedBox(
width: 300.0,
height: 450.0,
child: const Card(child: Text('Hello JavaTp
oint!'),
)
AspectRatio
• This widget allows you to keep the size of the
child widget to a specified aspect ratio.
AspectRatio(
aspectRatio: 5/3,
child: Container(
color: Colors.bluel,
),
),
Baseline
• This widget shifts the child widget according to the
child's baseline.
child: Baseline(
baseline: 30.0,
baselineType: TextBaseline.alphabetic,
child: Container(
height: 60,
width: 50,
color: Colors.blue,
),
)
ConstrainedBox
• It is a widget that allows you to force the
additional constraints on its child widget. It
means you can force the child widget to have a
specific constraint without changing the
properties of the child widget.
Example
ConstrainedBox(
constraints: new BoxConstraints(
minHeight: 150.0,
minWidth: 150.0,
maxHeight: 300.0,
maxWidth: 300.0,
),
child: new DecoratedBox(
decoration: new BoxDecoration(color: Colors.r
ed,
),
CustomSingleChildLayout
• It is a widget, which defers from the layout of
the single child to a delegate. The delegate
decides to position the child widget and also
used to determine the size of the parent
widget.
• FittedBox: It scales and positions the child
widget according to the specified fit.
Example
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// It is the root widget of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Multiple Layout Widget',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
primarySwatch: Colors.green,
),
home: MyHomePage(),
);
}
}
Cont..
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("FittedBox Widget")),
body: Center(
child: FittedBox(child: Row(
children: <Widget>[
Container(
child: Image.asset('assets/computer.png'),
),
Container(
child: Text("This is a widget"),
)
],
),
fit: BoxFit.contain,
)
),
);
}
}
Output
Setup
• Set up Android Studio to run Flutter
Applications. Android Studio is one of the
popular IDE developed by Google itself to
create cross-platform android applications.
First, you have to install Android
Studio of version 3.0 or later, as it offers an
integrated IDE experience for a Flutter
Install the Flutter and Dart plugins
• After the successful installation of Android Studio, you
have to install Flutter and Dart plugins. To do so follow
the steps mentioned below:
• Start Android Studio.
• Open plugin preferences (Configure > Plugins as of
v3.6.3.0 or later).
• Select the Flutter plugin and click Install.
• Click Yes when prompted to install the Dart plugin.
• Click Restart when prompted.
• Open plugin preferences:
• For macOS: Preferences > Plugins on macOS,
• For Linux and Windows: File > Settings > Plugins
Creating the application:
• After installing Dart and Flutter plugins create a
flutter app to check if it is working properly or not,
to do so follow the steps mentioned below:
• Step 1: Open the IDE and select Start a new Flutter
project.
Configure Flutter SDK and Dart SDK
Path if not Set
• Step 1 : Go to File Menu
Step 2 : Click on Settings ( Ctrl + Alt + S)
Step 3: then click on Flutter under Language &
Frameworks Tab
Step 4: In my PC I installed flutter in this location
( C:srcflutter )
[Note : please copy your PC installed location of flutter
]
Step 5 : Copy above Location and paste it to
your Flutter SDK path: location and click on Apply
and OK
Step 6 : after above settings you will see that Dart SDK
path set automatically.
Settings under File Menu
Step 2
• Select the Flutter Application as the project
type. Then click Next.
Step 3
• Verify the Flutter SDK path specifies the SDK’s
location (select Install SDK… if the text field is
blank)
Step 4
• Enter a project name (for example, myapp). Then
click Next.
Step 5: Click Finish
Step 6
• Wait for Android Studio to install the SDK and
create the project.
• When creating a new Flutter app, some Flutter IDE
plugins ask for a company domain name in reverse
order, something like com.example. The company
domain name and project name are used together
as the package name for Android (the Bundle ID for
iOS) when the app is released. If you think that the
app might be released, it’s better to specify the
package name now. The package name can’t be
changed once the app is released, so make the
name unique.
Running the application
• Step 1: Locate the main Android Studio toolbar
Step 2
• In the target selector, select an Android
device for running the app. If none are listed
as available, select Tools> Android > AVD
Manager and create one there. For details,
see Managing AVDs.
Step 3
• Click the run icon in the toolbar, or invoke the
menu item Run > Run.
• After the app build completes, you’ll see the starter
app on your device.

More Related Content

Similar to FlutterArchitecture FlutterArchitecture.ppt

Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developersmhant
 
Debugging MAD lecture june .pptx
Debugging MAD lecture june .pptxDebugging MAD lecture june .pptx
Debugging MAD lecture june .pptxArishaNaz2
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
Introduction to Visual Basic 6.0
Introduction to Visual Basic 6.0Introduction to Visual Basic 6.0
Introduction to Visual Basic 6.0DivyaR219113
 
GUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxGUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxdvarshitha04
 
Embedded Systems.pdf
Embedded Systems.pdfEmbedded Systems.pdf
Embedded Systems.pdfruvabebe
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development TutorialGermán Bringas
 
Flutter-Festivals Day-2.pptx
Flutter-Festivals Day-2.pptxFlutter-Festivals Day-2.pptx
Flutter-Festivals Day-2.pptxDSCVSSUT
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid drawinfo_zybotech
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1Hussain Behestee
 
The Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a WidgetThe Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a WidgetWaqas Tariq
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-TejamFandat
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Androidrizki adam kurniawan
 
Beautiful UI in react native By - nativebase.io
Beautiful UI in react native By - nativebase.ioBeautiful UI in react native By - nativebase.io
Beautiful UI in react native By - nativebase.ioGeekyants
 
java swing programming
java swing programming java swing programming
java swing programming Ankit Desai
 

Similar to FlutterArchitecture FlutterArchitecture.ppt (20)

Android Widget
Android WidgetAndroid Widget
Android Widget
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developers
 
Debugging MAD lecture june .pptx
Debugging MAD lecture june .pptxDebugging MAD lecture june .pptx
Debugging MAD lecture june .pptx
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Introduction to Visual Basic 6.0
Introduction to Visual Basic 6.0Introduction to Visual Basic 6.0
Introduction to Visual Basic 6.0
 
GUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxGUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptx
 
Embedded Systems.pdf
Embedded Systems.pdfEmbedded Systems.pdf
Embedded Systems.pdf
 
Chapter 1-Note.docx
Chapter 1-Note.docxChapter 1-Note.docx
Chapter 1-Note.docx
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 
Flutter-Festivals Day-2.pptx
Flutter-Festivals Day-2.pptxFlutter-Festivals Day-2.pptx
Flutter-Festivals Day-2.pptx
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Mobile Application Development class 001
Mobile Application Development class 001Mobile Application Development class 001
Mobile Application Development class 001
 
hema ppt (2).pptx
hema ppt (2).pptxhema ppt (2).pptx
hema ppt (2).pptx
 
The Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a WidgetThe Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a Widget
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android
 
Beautiful UI in react native By - nativebase.io
Beautiful UI in react native By - nativebase.ioBeautiful UI in react native By - nativebase.io
Beautiful UI in react native By - nativebase.io
 
java swing programming
java swing programming java swing programming
java swing programming
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

FlutterArchitecture FlutterArchitecture.ppt

  • 2. Flutter architecture application mainly consists • Widgets • Gestures • Concept of State • Layers
  • 3. Widgets • Widgets are the primary component of any flutter application. It acts as a UI for the user to interact with the application. Any flutter application is itself a widget that is made up of a combination of widgets. In a standard application, the root defines the structure of the application followed by a MaterialApp widget which basically holds its internal components in place. This is where the properties of the UI and the application itself is set.
  • 4. Cont.. • MaterialApp Widget is a predefined class in a flutter. It is likely the main or core component of flutter. we can access all the other components and widgets provided by Flutter SDK
  • 5. MaterialApp and Scaffold • MaterialApp is a widget that introduces a number of widgets Navigator, Theme that are required to build a material design app. Scaffold Widget is used under MaterialApp, it gives you many basic functionalities, like AppBar, BottomNavigationBar, Drawer, FloatingActionButton, etc
  • 6. Difference MaterialApp and Scaffold • MaterialApp Widget is the starting point of your app, it tells Flutter that you are going to use Material components and follow the material design in your app. • MaterialApp is a widget that introduces a number of widgets Navigator, Theme that are required to build a material design app. • Scaffold Widget is used under MaterialApp, it gives you many basic functionalities, like AppBar, BottomNavigationBar, Drawer, FloatingActionButton, etc. • The Scaffold is designed to be the single top-level container for a MaterialApp although it is not necessary to nest a Scaffold.
  • 7. Example void main() { runApp(MaterialApp( home: Scaffold( appBar: AppBar(), body: YourWidget(), ), )); }
  • 8.
  • 9. Cont.. • Inside Scaffold, there is usually an AppBar widget, which as the name suggests defines the appbar of the application. The scaffold also has a body where all the component widgets are placed. This is where these widget’s properties are set. All these widgets combined form the Homepage of the application itself. The Center widget has a property, Child, which refers to the actual content and it is built using the Text widget.
  • 10.
  • 11.
  • 12. Layers Flutter is packaged with three layers: • Embedder (lowest layer) • Engine • Framework (highest layer)
  • 13.
  • 14. Embedder layer • An entry point is provided by a platform-specific embedder, which coordinates with the underlying operating system to access services such as accessibility, rendering surfaces, and input. • The embedder is written in a platform-specific language, such as Java and C++ for Android, Objective-C/Objective-C++ for iOS and macOS, and C++ for Windows and Linux. • Flutter code can be embedded into an existing application as a module or as the complete application’s content using the embedder.
  • 15. Engine layer • The engine layer is written in C/C++, and it takes care of the input, output, network requests, and handles the difficult translation of rendering whenever a frame needs to be painted. • Flutter use skia as its rendering engine and it is revealed to the Flutter framework through the dart : ui which wraps the principal C++ code in Dart classes.
  • 16. Framework layer • The framework layer is the part where most developers can interact with Flutter. The Flutter framework provides a reactive and modern framework that is written in Dart. • Within the framework layer, it comprises of the following: • Rendering • Widgets • Material and cupertino • It also has foundational classes and building block services like animation, drawing, and gestures, which are required for writing a Flutter application.
  • 17.
  • 18.
  • 19. • Data layer: This layer is the one in charge of interacting with APIs. • Domain layer: This is the one in charge of transforming the data that comes from the data layer. • finally, we want to manage the state of that data and present it on our user interface, that’s why we split the presentation layer in two: • Business logic layer: This layer manages the state (usually using flutter_bloc). • Presentation layer: Renders UI components based on state.
  • 20. Gesture • The gesture system in Flutter has two separate layers. The first layer has raw pointer events that describe the location and movement of pointers (for example, touches, mice, and styli) across the screen. The second layer has gestures that describe semantic actions that consist of one or more pointer movements
  • 21. Gestures • All physical form of interaction with a flutter application is done through pre-defined gestures. GestureDetectors are used for the same. It is an invisible widget that is used to process physical interaction with the flutter application. The interaction includes gestures like tapping, dragging, and swiping, etc. These features can be used to creatively enhance the user experiences of the app by making it perform desired actions based on simple gestures.
  • 22. Gesture Detect • Gesture Detector in Flutter is used to detect the user's gestures on the application. It is a non-visual widget. Inside the gesture detector, another widget is placed and the gesture detector will capture all these events (gestures) and execute the tasks accordingly.
  • 23. Concept of State • State is information that (1) can be read synchronously when the widget is built and (2) might change during the lifetime of the widget. It is the responsibility of the widget implementer to ensure that the State is promptly notified when such state changes, using State. • State can be described as "whatever data you need in order to rebuild your UI at any moment in time". When the state of your app changes (for example, the user flips a switch in the settings screen), you change the state, and that triggers a redraw of the user interface.
  • 24.
  • 25. Concept of State • If you have ever worked with React js, you might be familiar with the concept of a state. The states are nothing but data objects. Flutter also operates on similar turf. For the management of state in a Flutter application, StatefulWidget is used. Similar to the concept of state in React js, the re-rendering of widgets specific to the state occurs whenever the state changes. This also avoids the re-rendering of the entire application, every time the state of a widget changes.
  • 26. Stateful and Stateless Widgets • A widget is either stateful or stateless. If a widget can change—when a user interacts with it, for example—it's stateful. • A stateless widget never changes. Icon , IconButton , and Text are examples of stateless widgets.
  • 27. Examples • Stateless widgets are text, icons, icon buttons, and raised buttons. • A stateful widget is dynamic: for example, it can change its appearance in response to events triggered by user interactions or when it receives data. Checkbox , Radio , Slider , InkWell , Form , and TextField are examples of stateful widgets.
  • 28.
  • 29.
  • 30.
  • 31. Flutter Layouts • The main concept of the layout mechanism is the widget. We know that flutter assume everything as a widget. So the image, icon, text, and even the layout of your app are all widgets. Here, some of the things you do not see on your app UI, such as rows, columns, and grids that arrange, constrain, and align the visible widgets are also the widgets. • Flutter allows us to create a layout by composing multiple widgets to build more complex widgets. For example, we can see the
  • 32. Cont.. In the second image, we can see the visual layout of the above image. This image shows a row of three columns, and these columns contain an icon and label.
  • 33.
  • 34. Cont. • In the above image, the container is a widget class that allows us to customize the child widget. It is mainly used to add borders, padding, margins, background color, and many more. Here, the text widget comes under the container for adding margins. The entire row is also placed in a container for adding margin and padding around the row. Also, the rest of the UI is controlled by properties such as color, text.style, etc.
  • 35. Layout a widget • Let us learn how we can create and display a simple widget. The following steps show how to layout a widget: • Step 1: First, you need to select a Layout widget. • Step 2: Next, create a visible widget. • Step 3: Then, add the visible widget to the layout widget. • Step 4: Finally, add the layout widget to the page where you want to display.
  • 36. Types of Layout Widgets • We can categories the layout widget into two types: 1.Single Child Widget 2.Multiple Child Widget
  • 37. Single Child Widgets • The single child layout widget is a type of widget, which can have only one child widget inside the parent layout widget. These widgets can also contain special layout functionality. Flutter provides us many single child widgets to make the app UI attractive. If we use these widgets appropriately, it can save our time and makes the app code more readable. The list of different types of single child widgets are:
  • 38. Example • Container: It is the most popular layout widget that provides customizable options for painting, positioning, and sizing of widgets. Center( child: Container( margin: const EdgeInsets.all(15.0), color: Colors.blue, width: 42.0, height: 42.0, ), )
  • 39. Padding • It is a widget that is used to arrange its child widget by the given padding. • It contains EdgeInsets and EdgeInsets.fromLT RB for the desired side where you want to provide padding. const Greetings( child: Padding( padding: EdgeInsets.all(14.0), child: Text('Hello JavaTpoint!'), ),
  • 40. Cont.. • Center: This widget allows you to center the child widget within itself. • Align: It is a widget, which aligns its child widget within itself and sizes it based on the child's size. It provides more control to place the child widget in the exact position where you need it.
  • 41. Example Center( child: Container( height: 110.0, width: 110.0, color: Colors.blue, child: Align( alignment: Alignment.topLeft, child: FlutterLogo( size: 50, ), ), ), )
  • 42. SizedBox: This widget allows you to give the specified size to the child widget through all screens. SizedBox( width: 300.0, height: 450.0, child: const Card(child: Text('Hello JavaTp oint!'), )
  • 43. AspectRatio • This widget allows you to keep the size of the child widget to a specified aspect ratio. AspectRatio( aspectRatio: 5/3, child: Container( color: Colors.bluel, ), ),
  • 44. Baseline • This widget shifts the child widget according to the child's baseline. child: Baseline( baseline: 30.0, baselineType: TextBaseline.alphabetic, child: Container( height: 60, width: 50, color: Colors.blue, ), )
  • 45. ConstrainedBox • It is a widget that allows you to force the additional constraints on its child widget. It means you can force the child widget to have a specific constraint without changing the properties of the child widget.
  • 46. Example ConstrainedBox( constraints: new BoxConstraints( minHeight: 150.0, minWidth: 150.0, maxHeight: 300.0, maxWidth: 300.0, ), child: new DecoratedBox( decoration: new BoxDecoration(color: Colors.r ed, ),
  • 47. CustomSingleChildLayout • It is a widget, which defers from the layout of the single child to a delegate. The delegate decides to position the child widget and also used to determine the size of the parent widget. • FittedBox: It scales and positions the child widget according to the specified fit.
  • 48. Example import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // It is the root widget of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Multiple Layout Widget', debugShowCheckedModeBanner: false, theme: ThemeData( // This is the theme of your application. primarySwatch: Colors.green, ), home: MyHomePage(), ); } }
  • 49. Cont.. class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("FittedBox Widget")), body: Center( child: FittedBox(child: Row( children: <Widget>[ Container( child: Image.asset('assets/computer.png'), ), Container( child: Text("This is a widget"), ) ], ), fit: BoxFit.contain, ) ), ); } }
  • 51. Setup • Set up Android Studio to run Flutter Applications. Android Studio is one of the popular IDE developed by Google itself to create cross-platform android applications. First, you have to install Android Studio of version 3.0 or later, as it offers an integrated IDE experience for a Flutter
  • 52. Install the Flutter and Dart plugins • After the successful installation of Android Studio, you have to install Flutter and Dart plugins. To do so follow the steps mentioned below: • Start Android Studio. • Open plugin preferences (Configure > Plugins as of v3.6.3.0 or later). • Select the Flutter plugin and click Install. • Click Yes when prompted to install the Dart plugin. • Click Restart when prompted. • Open plugin preferences: • For macOS: Preferences > Plugins on macOS, • For Linux and Windows: File > Settings > Plugins
  • 53. Creating the application: • After installing Dart and Flutter plugins create a flutter app to check if it is working properly or not, to do so follow the steps mentioned below: • Step 1: Open the IDE and select Start a new Flutter project.
  • 54. Configure Flutter SDK and Dart SDK Path if not Set • Step 1 : Go to File Menu Step 2 : Click on Settings ( Ctrl + Alt + S) Step 3: then click on Flutter under Language & Frameworks Tab Step 4: In my PC I installed flutter in this location ( C:srcflutter ) [Note : please copy your PC installed location of flutter ] Step 5 : Copy above Location and paste it to your Flutter SDK path: location and click on Apply and OK Step 6 : after above settings you will see that Dart SDK path set automatically.
  • 56.
  • 57.
  • 58. Step 2 • Select the Flutter Application as the project type. Then click Next.
  • 59. Step 3 • Verify the Flutter SDK path specifies the SDK’s location (select Install SDK… if the text field is blank)
  • 60. Step 4 • Enter a project name (for example, myapp). Then click Next.
  • 61. Step 5: Click Finish
  • 62. Step 6 • Wait for Android Studio to install the SDK and create the project. • When creating a new Flutter app, some Flutter IDE plugins ask for a company domain name in reverse order, something like com.example. The company domain name and project name are used together as the package name for Android (the Bundle ID for iOS) when the app is released. If you think that the app might be released, it’s better to specify the package name now. The package name can’t be changed once the app is released, so make the name unique.
  • 63. Running the application • Step 1: Locate the main Android Studio toolbar
  • 64. Step 2 • In the target selector, select an Android device for running the app. If none are listed as available, select Tools> Android > AVD Manager and create one there. For details, see Managing AVDs.
  • 65. Step 3 • Click the run icon in the toolbar, or invoke the menu item Run > Run. • After the app build completes, you’ll see the starter app on your device.