SlideShare a Scribd company logo
1 of 14
Mobile Application Development
class 05
Dr. Mazin Alkathiri
IT Department
Seiyun University
2023-2024
Flutter - Introduction to Gestures
• Gestures are an interesting feature in Flutter that allows us to interact
with the mobile app (or any touch-based device).
• Generally, gestures define any physical action or movement of a user in
the intention of specific control of the mobile device.
• Some of the examples of gestures are:
– When the mobile screen is locked, you slide your finger across the screen to
unlock it.
– Tapping a button on your mobile screen, and
– Tapping and holding an app icon on a touch-based device to drag it across
screens.
• Flutter divides the gesture system into two different layers, which are
given below:
– Pointers
– Gestures
Pointers
• Pointers are the first layer that represents the raw data about
user interaction.
• It has events, which describe the location and movement of
pointers such as touches, mice, and style across the screens.
• Flutter does not provide any mechanism to cancel or stop the
pointer-events from being dispatched further.
• Flutter provides a Listener widget to listen to the pointer-
events directly from the widgets layer.
• The pointer-events are categories into mainly four types:
– PointerDownEvents
– PointerMoveEvents
– PointerUpEvents
– PointerCancelEvents
• PointerDownEvents: It allows the pointer to
contact the screen at a particular location.
• PointerMoveEvents: It allows the pointer to
move from one location to another location
on the screen.
• PointerUpEvents: It allows the pointer to stop
contacting the screen.
• PointerCancelEvents: This event is sent when
the pointer interaction is canceled.
Listener(
onPointerDown: (event) {
print('Pointer down');
},
onPointerUp: (event) {
print('Pointer up');
},
onPointerMove: (event) {
print('Pointer move');
},
child:Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
),
Gestures
• It is the second layer that represents semantic
actions such as tap, drag, and scale, which are
recognized from multiple individual pointer
events.
• It is also able to dispatch multiple events
corresponding to gesture lifecycle like drag start,
drag update, and drag end.
• Some of the popularly used gesture are listed
below:
Some of the widely used gestures are
mentioned here −
• Tap − Touching the surface of the device with fingertip for a
short period and then releasing the fingertip.
• Double Tap − Tapping twice in a short time.
• Drag − Touching the surface of the device with fingertip and
then moving the fingertip in a steady manner and then
finally releasing the fingertip.
• Flick − Similar to dragging, but doing it in a speeder way.
• Pinch − Pinching the surface of the device using two
fingers.
• Spread/Zoom − Opposite of pinching.
• Panning − Touching the surface of the device with fingertip
and moving it in any direction without releasing the
fingertip.
Gesture Detector
• Flutter provides an excellent support for all type of
gestures through its exclusive widget,
GestureDetector.
• GestureDetector is a non-visual widget primarily
used for detecting the user’s gesture.
• To identify a gesture targeted on a widget, the widget
can be placed inside GestureDetector widget.
• GestureDetector will capture the gesture and
dispatch multiple events based on the gesture.
return new Scaffold(
appBar: new AppBar(
title: new Text('Gestures Example'),
centerTitle: true,
),
body: new Center(child: GestureDetector(
onTap: () {
print('Box Clicked');
},
child: Container(
height: 60.0,
width: 120.0,
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(15.0),
),
child: Center(child: Text('Click Me')),
)
)),
);
Some of the gestures and the
corresponding events are given below
• Tap
– onTapDown
– onTapUp
– onTap
– onTapCancel
• Double tap
– onDoubleTap
• Long press
– onLongPress
• Vertical drag
– onVerticalDragStart
– onVerticalDragUpdate
– onVerticalDragEnd
• Horizontal drag
– onHorizontalDragStart
– onHorizontalDragUpdate
– onHorizontalDragEnd
• Pan
– onPanStart
– onPanUpdate
– onPanEnd
• let us modify the hello world application to include
gesture detection feature and try to understand the
concept.
• Change the body content of the MyHomePage widget
as shown below −
body: Center(
child: GestureDetector(
onTap: () {
_showDialog(context);
},
child: Text( 'Hello World', )
)
),
• Observe that here we have placed the
GestureDetector widget above the Text widget in
the widget hierarchy, captured the onTap event
and then finally shown a dialog window.
• Implement the *_showDialog* function to
present a dialog when user tabs the hello world
message. It uses the
generic showDialog and AlertDialog widget to
create a new dialog widget.
• The code is shown below –
// user defined function void _showDialog(BuildContext context)
{
// flutter defined function
showDialog(
context: context, builder: (BuildContext context) {
// return object of type Dialog
return AlertDialog(
title: new Text("Message"),
content: new Text("Hello World"),
actions: <Widget>[
new FlatButton(
child: new Text("Close"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
Flutter also provides a set of widgets that can allow you to do a specific as
well as advanced gestures. These widgets are given below:
• Dismissible: It is a type of widget that supports the flick gesture to
dismiss the widget.
• Draggable: It is a type of widget that supports drag gestures to move
the widget.
• LongPressDraggable: It is a type of widget that supports drag gesture to
move a widget along with its parent widget.
• DragTarget: It is a type of widget that can accept any Draggable widget
• IgnorePointer: It is a type of widget that hides the widget and its
children from the gesture detection process.
• AbsorbPointer: It is a type of widget that stops the gesture detection
process itself. Due to this, any overlapping widget cannot able to
participate in the gesture detection process, and thus, no event is
raised.
• Scrollable: It is a type of widget that supports scrolling of the content
which is available inside the widget.

More Related Content

Similar to Mobile Application Development class 005

Scratching the Surface with JavaFX
Scratching the Surface with JavaFXScratching the Surface with JavaFX
Scratching the Surface with JavaFXNLJUG
 
DHTML - Events & Buttons
DHTML - Events  & ButtonsDHTML - Events  & Buttons
DHTML - Events & ButtonsDeep Patel
 
Multi Touch presentation
Multi Touch presentationMulti Touch presentation
Multi Touch presentationsenthil0809
 
How to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptxHow to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptxFlutter Agency
 
Fast multi touch enabled web sites
Fast multi touch enabled web sitesFast multi touch enabled web sites
Fast multi touch enabled web sitesAspenware
 
Tips for building fast multi touch enabled web sites
 Tips for building fast multi touch enabled web sites Tips for building fast multi touch enabled web sites
Tips for building fast multi touch enabled web sitesAspenware
 
Event handling
Event handlingEvent handling
Event handlingswapnac12
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handlingteach4uin
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intentPERKYTORIALS
 
Advance java for bscit
Advance java for bscitAdvance java for bscit
Advance java for bscitYogeshDhamke2
 
Developing Multi Touch Applications
Developing Multi Touch ApplicationsDeveloping Multi Touch Applications
Developing Multi Touch ApplicationsBrian Blanchard
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxusvirat1805
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceNick Pruehs
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docPalakjaiswal43
 
Introduction to development
Introduction to developmentIntroduction to development
Introduction to developmentMatteo Valoriani
 
Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...
Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...
Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...Patrick Lauke
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03Ankit Dubey
 

Similar to Mobile Application Development class 005 (20)

Scratching the Surface with JavaFX
Scratching the Surface with JavaFXScratching the Surface with JavaFX
Scratching the Surface with JavaFX
 
DHTML - Events & Buttons
DHTML - Events  & ButtonsDHTML - Events  & Buttons
DHTML - Events & Buttons
 
Multi Touch presentation
Multi Touch presentationMulti Touch presentation
Multi Touch presentation
 
How to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptxHow to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptx
 
Fast multi touch enabled web sites
Fast multi touch enabled web sitesFast multi touch enabled web sites
Fast multi touch enabled web sites
 
Tips for building fast multi touch enabled web sites
 Tips for building fast multi touch enabled web sites Tips for building fast multi touch enabled web sites
Tips for building fast multi touch enabled web sites
 
Event handling
Event handlingEvent handling
Event handling
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handling
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
Advance java for bscit
Advance java for bscitAdvance java for bscit
Advance java for bscit
 
Developing Multi Touch Applications
Developing Multi Touch ApplicationsDeveloping Multi Touch Applications
Developing Multi Touch Applications
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 
Introduction to development
Introduction to developmentIntroduction to development
Introduction to development
 
Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...
Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...
Getting touchy - an introduction to touch and pointer events / TPAC 2016 / Li...
 
09events
09events09events
09events
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 

More from Dr. Mazin Mohamed alkathiri

ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)Dr. Mazin Mohamed alkathiri
 
Advance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BAdvance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BDr. Mazin Mohamed alkathiri
 
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)Dr. Mazin Mohamed alkathiri
 

More from Dr. Mazin Mohamed alkathiri (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Advance Mobile Application Development class 05
Advance Mobile Application Development class 05Advance Mobile Application Development class 05
Advance Mobile Application Development class 05
 
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
 
OS-operating systems- ch03
OS-operating systems- ch03OS-operating systems- ch03
OS-operating systems- ch03
 
OS-operating systems - ch02 - part-2-2024
OS-operating systems - ch02 - part-2-2024OS-operating systems - ch02 - part-2-2024
OS-operating systems - ch02 - part-2-2024
 
Advance Mobile Application Development class 04
Advance Mobile Application Development class 04Advance Mobile Application Development class 04
Advance Mobile Application Development class 04
 
Advance Mobile Application Development class 03
Advance Mobile Application Development class 03Advance Mobile Application Development class 03
Advance Mobile Application Development class 03
 
Advance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BAdvance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-B
 
OS-ch02-part-1-2024.ppt
OS-ch02-part-1-2024.pptOS-ch02-part-1-2024.ppt
OS-ch02-part-1-2024.ppt
 
Advance Mobile Application Development class 02
Advance Mobile Application Development class 02Advance Mobile Application Development class 02
Advance Mobile Application Development class 02
 
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
 
Advance Mobile Application Development class 01
Advance Mobile Application Development class 01Advance Mobile Application Development class 01
Advance Mobile Application Development class 01
 
ESSENTIAL of (CS/IT/IS) class 02 (HCI)
ESSENTIAL of (CS/IT/IS) class 02 (HCI)ESSENTIAL of (CS/IT/IS) class 02 (HCI)
ESSENTIAL of (CS/IT/IS) class 02 (HCI)
 
Seminar
SeminarSeminar
Seminar
 
ESSENTIAL of (CS/IT/IS)
ESSENTIAL of (CS/IT/IS)ESSENTIAL of (CS/IT/IS)
ESSENTIAL of (CS/IT/IS)
 
OS-ch01-2024.ppt
OS-ch01-2024.pptOS-ch01-2024.ppt
OS-ch01-2024.ppt
 
Mobile Application Development class 008
Mobile Application Development class 008Mobile Application Development class 008
Mobile Application Development class 008
 
Academic Writing (Punctuation ) class 06
Academic Writing (Punctuation ) class 06Academic Writing (Punctuation ) class 06
Academic Writing (Punctuation ) class 06
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
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
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Mobile Application Development class 005

  • 1. Mobile Application Development class 05 Dr. Mazin Alkathiri IT Department Seiyun University 2023-2024
  • 2. Flutter - Introduction to Gestures • Gestures are an interesting feature in Flutter that allows us to interact with the mobile app (or any touch-based device). • Generally, gestures define any physical action or movement of a user in the intention of specific control of the mobile device. • Some of the examples of gestures are: – When the mobile screen is locked, you slide your finger across the screen to unlock it. – Tapping a button on your mobile screen, and – Tapping and holding an app icon on a touch-based device to drag it across screens. • Flutter divides the gesture system into two different layers, which are given below: – Pointers – Gestures
  • 3. Pointers • Pointers are the first layer that represents the raw data about user interaction. • It has events, which describe the location and movement of pointers such as touches, mice, and style across the screens. • Flutter does not provide any mechanism to cancel or stop the pointer-events from being dispatched further. • Flutter provides a Listener widget to listen to the pointer- events directly from the widgets layer. • The pointer-events are categories into mainly four types: – PointerDownEvents – PointerMoveEvents – PointerUpEvents – PointerCancelEvents
  • 4. • PointerDownEvents: It allows the pointer to contact the screen at a particular location. • PointerMoveEvents: It allows the pointer to move from one location to another location on the screen. • PointerUpEvents: It allows the pointer to stop contacting the screen. • PointerCancelEvents: This event is sent when the pointer interaction is canceled.
  • 5. Listener( onPointerDown: (event) { print('Pointer down'); }, onPointerUp: (event) { print('Pointer up'); }, onPointerMove: (event) { print('Pointer move'); }, child:Text( '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), ),
  • 6. Gestures • It is the second layer that represents semantic actions such as tap, drag, and scale, which are recognized from multiple individual pointer events. • It is also able to dispatch multiple events corresponding to gesture lifecycle like drag start, drag update, and drag end. • Some of the popularly used gesture are listed below:
  • 7. Some of the widely used gestures are mentioned here − • Tap − Touching the surface of the device with fingertip for a short period and then releasing the fingertip. • Double Tap − Tapping twice in a short time. • Drag − Touching the surface of the device with fingertip and then moving the fingertip in a steady manner and then finally releasing the fingertip. • Flick − Similar to dragging, but doing it in a speeder way. • Pinch − Pinching the surface of the device using two fingers. • Spread/Zoom − Opposite of pinching. • Panning − Touching the surface of the device with fingertip and moving it in any direction without releasing the fingertip.
  • 8. Gesture Detector • Flutter provides an excellent support for all type of gestures through its exclusive widget, GestureDetector. • GestureDetector is a non-visual widget primarily used for detecting the user’s gesture. • To identify a gesture targeted on a widget, the widget can be placed inside GestureDetector widget. • GestureDetector will capture the gesture and dispatch multiple events based on the gesture.
  • 9. return new Scaffold( appBar: new AppBar( title: new Text('Gestures Example'), centerTitle: true, ), body: new Center(child: GestureDetector( onTap: () { print('Box Clicked'); }, child: Container( height: 60.0, width: 120.0, padding: EdgeInsets.all(10.0), decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(15.0), ), child: Center(child: Text('Click Me')), ) )), );
  • 10. Some of the gestures and the corresponding events are given below • Tap – onTapDown – onTapUp – onTap – onTapCancel • Double tap – onDoubleTap • Long press – onLongPress • Vertical drag – onVerticalDragStart – onVerticalDragUpdate – onVerticalDragEnd • Horizontal drag – onHorizontalDragStart – onHorizontalDragUpdate – onHorizontalDragEnd • Pan – onPanStart – onPanUpdate – onPanEnd
  • 11. • let us modify the hello world application to include gesture detection feature and try to understand the concept. • Change the body content of the MyHomePage widget as shown below − body: Center( child: GestureDetector( onTap: () { _showDialog(context); }, child: Text( 'Hello World', ) ) ),
  • 12. • Observe that here we have placed the GestureDetector widget above the Text widget in the widget hierarchy, captured the onTap event and then finally shown a dialog window. • Implement the *_showDialog* function to present a dialog when user tabs the hello world message. It uses the generic showDialog and AlertDialog widget to create a new dialog widget. • The code is shown below –
  • 13. // user defined function void _showDialog(BuildContext context) { // flutter defined function showDialog( context: context, builder: (BuildContext context) { // return object of type Dialog return AlertDialog( title: new Text("Message"), content: new Text("Hello World"), actions: <Widget>[ new FlatButton( child: new Text("Close"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); }
  • 14. Flutter also provides a set of widgets that can allow you to do a specific as well as advanced gestures. These widgets are given below: • Dismissible: It is a type of widget that supports the flick gesture to dismiss the widget. • Draggable: It is a type of widget that supports drag gestures to move the widget. • LongPressDraggable: It is a type of widget that supports drag gesture to move a widget along with its parent widget. • DragTarget: It is a type of widget that can accept any Draggable widget • IgnorePointer: It is a type of widget that hides the widget and its children from the gesture detection process. • AbsorbPointer: It is a type of widget that stops the gesture detection process itself. Due to this, any overlapping widget cannot able to participate in the gesture detection process, and thus, no event is raised. • Scrollable: It is a type of widget that supports scrolling of the content which is available inside the widget.