Using Inherited Widgets and Gesture Detectors in Dart's Flutter Framework

What Will I Learn?

  • You will learn how to reason about a Flutter Widget Tree
  • You will learn how to make use of the Inherited Widget class in Flutter
  • You will learn how to use a Gesture Detector in Flutter
  • You will learn how to use the context of an application to get its state

Requirements

Difficulty

  • Intermediate

Description

In this video tutorial, we look at inherited widgets, the widget tree and gesture detectors in Flutter. Inherited widgets are a idiomatic way of proliferating state, data and actions from one area of the application widget tree to another. They expose their information to the inheriting children widgets as public variables which can be access through the build context object. When an inherited widget's state changes, it calls for the consumer child widget to re-render in the tree which can help us save on performance when we have multiple widgets that share the same state.

Gesture detectors are widgets that detect gestures through the use of gesture recognizer functions. These recognizer functions are callback functions and the behavior of the gesture detector is based on which of these call backs are not null. The gesture detector listens for a stream of data which represent semantic actions such as taps, drags and panning. Based on the actions and the data that is presented to the gesture detector, the widget decides which function to use through various different rules.

All flutter objects are considered widgets. In this way, a flutter application is represented through a tree of widgets. Even the objects that have no form are considered widgets in the flutter application. Optimization of the widget tree can be helpful to make it easy to maintain a flutter application as well as increase the performance of this application.

The source code for this project can be found here

Video Tutorial

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
3 Comments