Unverified Commit dff703f0 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Update GestureDetector docs to use DartPad sample (#85148)

This removes the broken video for GestureDetector, and replaces it with a Dartpad sample, for both samples in GestureDetector.
parent ff5258a5
...@@ -127,18 +127,20 @@ class GestureRecognizerFactoryWithHandlers<T extends GestureRecognizer> extends ...@@ -127,18 +127,20 @@ class GestureRecognizerFactoryWithHandlers<T extends GestureRecognizer> extends
/// effects. The [InkWell] class implements this effect and can be used in place /// effects. The [InkWell] class implements this effect and can be used in place
/// of a [GestureDetector] for handling taps. /// of a [GestureDetector] for handling taps.
/// ///
/// {@animation 200 150 https://flutter.github.io/assets-for-api-docs/assets/widgets/gesture_detector.mp4} /// {@tool dartpad --template=stateful_widget_material}
/// ///
/// {@tool snippet} /// This example contains a black light bulb wrapped in a [GestureDetector]. It
/// /// turns the light bulb yellow when the "TURN LIGHT ON" button is tapped by
/// This example of a [Container] contains a black light bulb wrapped in a [GestureDetector]. /// setting the `_lights` field, and off again when "TURN LIGHT OFF" is tapped.
/// It turns the light bulb yellow when the "turn lights on" button is tapped
/// by setting the `_lights` field. Above animation shows the code in use:
/// ///
/// ```dart /// ```dart
/// Container( /// bool _lightIsOn = false;
///
/// @override
/// Widget build(BuildContext context) {
/// return Scaffold(
/// body: Container(
/// alignment: FractionalOffset.center, /// alignment: FractionalOffset.center,
/// color: Colors.white,
/// child: Column( /// child: Column(
/// mainAxisAlignment: MainAxisAlignment.center, /// mainAxisAlignment: MainAxisAlignment.center,
/// children: <Widget>[ /// children: <Widget>[
...@@ -146,48 +148,60 @@ class GestureRecognizerFactoryWithHandlers<T extends GestureRecognizer> extends ...@@ -146,48 +148,60 @@ class GestureRecognizerFactoryWithHandlers<T extends GestureRecognizer> extends
/// padding: const EdgeInsets.all(8.0), /// padding: const EdgeInsets.all(8.0),
/// child: Icon( /// child: Icon(
/// Icons.lightbulb_outline, /// Icons.lightbulb_outline,
/// color: _lights ? Colors.yellow.shade600 : Colors.black, /// color: _lightIsOn ? Colors.yellow.shade600 : Colors.black,
/// size: 60, /// size: 60,
/// ), /// ),
/// ), /// ),
/// GestureDetector( /// GestureDetector(
/// onTap: () { /// onTap: () {
/// setState(() { /// setState(() {
/// _lights = true; /// // Toggle light when tapped.
/// _lightIsOn = !_lightIsOn;
/// }); /// });
/// }, /// },
/// child: Container( /// child: Container(
/// color: Colors.yellow.shade600, /// color: Colors.yellow.shade600,
/// padding: const EdgeInsets.all(8), /// padding: const EdgeInsets.all(8),
/// child: const Text('TURN LIGHTS ON'), /// // Change button text when light changes state.
/// child: Text(_lightIsOn ? 'TURN LIGHT OFF' : 'TURN LIGHT ON'),
/// ), /// ),
/// ), /// ),
/// ], /// ],
/// ), /// ),
/// ) /// ),
/// );
/// }
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
/// ///
/// {@tool snippet} /// {@tool dartpad --template=stateful_widget_material}
///
/// This example uses a [Container] that wraps a [GestureDetector] widget which
/// detects a tap.
/// ///
/// This example of a [Container] wraps a [GestureDetector] widget. /// Since the [GestureDetector] does not have a child, it takes on the size of its
/// Since the [GestureDetector] does not have a child it takes on the size of /// parent, making the entire area of the surrounding [Container] clickable. When
/// its parent making the entire area of the surrounding [Container] clickable. /// tapped, the [Container] turns yellow by setting the `_color` field. When
/// When tapped the [Container] turns yellow by setting the `_color` field: /// tapped again, it goes back to white.
/// ///
/// ```dart /// ```dart
/// Container( /// Color _color = Colors.white;
///
/// @override
/// Widget build(BuildContext context) {
/// return Container(
/// color: _color, /// color: _color,
/// height: 200.0, /// height: 200.0,
/// width: 200.0, /// width: 200.0,
/// child: GestureDetector( /// child: GestureDetector(
/// onTap: () { /// onTap: () {
/// setState(() { /// setState(() {
/// _color = Colors.yellow; /// _color == Colors.yellow ? _color = Colors.white : _color = Colors.yellow;
/// }); /// });
/// }, /// },
/// ), /// ),
/// ) /// );
/// }
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
/// ///
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment