Scale

The scale version is nothing more than panning on more than one pointer. Let's see what the scale version of panning looks like:

// part of scale_event_example.dart (full source code in the attached files)

GestureDetector(

onScaleStart: (ScaleStartDetails details) {
setState(() {
_scale = 1.0;
_resizing = true;
});
},
onScaleUpdate: (ScaleUpdateDetails details) {
setState(() {
_scale = details.scale;
});
},
onScaleEnd: (ScaleEndDetails details) {
setState(() {
_resizing = false;
_scaleCount++;
});
},
child: ... // for brevity
)

The code here is very similar to the previous ones. We have three properties in the state:

  • _resizing: This is used to update the text viewed by the user while resizing using the scale gesture.
  • _scaleCount: This accumulates the total number of scale events made from start to end.
  • _scale: This stores the scale value from the ScaleUpdateDetails parameter, and that later is applied to the Text widget using the scale constructor of the Transform widget.

As you can see, the scale callbacks look very similar to drag callbacks in that they also receive parameters related to each event – ScaleStartDetails, ScaleUpdateDetails, and ScaleEndDetails – which contain values that may help on each stage of the scale event.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.190.167