From bcdee0ac74bc973c37fd8317e4fba1751d20afdf Mon Sep 17 00:00:00 2001 From: Yazeed AlKhalaf Date: Mon, 23 Nov 2020 20:45:37 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20AdoptAWidget:=20IgnorePointer=20?= =?UTF-8?q?(#70185)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ➕ Add IgnorePointer Widget dartpad * 🐛 Fix grammatical issues in docs of IgnorePointer * ❌ Remove trailing spaces --- packages/flutter/lib/src/widgets/basic.dart | 57 ++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 729caeefbb2..840d38dd8ab 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -6609,8 +6609,6 @@ class RepaintBoundary extends SingleChildRenderObjectWidget { /// A widget that is invisible during hit testing. /// -/// {@youtube 560 315 https://www.youtube.com/watch?v=qV9pqHWxYgI} -/// /// When [ignoring] is true, this widget (and its subtree) is invisible /// to hit testing. It still consumes space during layout and paints its child /// as usual. It just cannot be the target of located events, because it returns @@ -6620,6 +6618,61 @@ class RepaintBoundary extends SingleChildRenderObjectWidget { /// the semantics layer (and thus e.g. accessibility tools). If /// [ignoringSemantics] is null, it uses the value of [ignoring]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=qV9pqHWxYgI} +/// +/// {@tool dartpad --template=stateful_widget_material} +/// The following sample has an [IgnorePointer] widget wrapping the `Column` +/// which contains a button. +/// When [ignoring] is set to `true` anything inside the `Column` can +/// not be tapped. When [ignoring] is set to `false` anything +/// inside the `Column` can be tapped. +/// +/// ```dart +/// bool ignoring = false; +/// void setIgnoring(bool newValue) { +/// setState(() { +/// ignoring = newValue; +/// }); +/// } +/// +/// @override +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// centerTitle: true, +/// title: ElevatedButton( +/// onPressed: () { +/// setIgnoring(!ignoring); +/// }, +/// child: Text( +/// ignoring ? 'Set ignoring to false' : 'Set ignoring to true', +/// ), +/// ), +/// ), +/// body: Center( +/// child: IgnorePointer( +/// ignoring: ignoring, +/// child: Column( +/// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +/// children: [ +/// Text( +/// 'Ignoring: $ignoring', +/// ), +/// ElevatedButton( +/// onPressed: () {}, +/// child: Text( +/// 'Click me!', +/// ), +/// ), +/// ], +/// ), +/// ), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [AbsorbPointer], which also prevents its children from receiving pointer