@@ -14,15 +14,15 @@ enum ExpanderDirection {
1414
1515/// The [Expander] control lets you show or hide less important content that's
1616/// related to a piece of primary content that's always visible. Items contained
17- /// in the Header are always visible. The user can expand and collapse the Content
18- /// area, where secondary content is displayed, by interacting with the header.
19- /// When the content area is expanded, it pushes other UI elements out of the
20- /// way; it does not overlay other UI. The Expander can expand upwards or
17+ /// in the Header are always visible. The user can expand and collapse the
18+ /// Content area, where secondary content is displayed, by interacting with the
19+ /// header. When the content area is expanded, it pushes other UI elements out
20+ /// of the way; it does not overlay other UI. The Expander can expand upwards or
2121/// downwards.
2222///
2323/// Both the Header and Content areas can contain any content, from simple text
24- /// to complex UI layouts. For example, you can use the control to show additional
25- /// options for an item.
24+ /// to complex UI layouts. For example, you can use the control to show
25+ /// additional options for an item.
2626///
2727/// ![Expander Preview] (https://docs.microsoft.com/en-us/windows/apps/design/controls/images/expander-default.gif)
2828///
@@ -43,6 +43,7 @@ class Expander extends StatefulWidget {
4343 this .direction = ExpanderDirection .down,
4444 this .initiallyExpanded = false ,
4545 this .onStateChanged,
46+ this .enabled = true ,
4647 this .headerBackgroundColor,
4748 this .headerShape,
4849 this .contentBackgroundColor,
@@ -61,7 +62,7 @@ class Expander extends StatefulWidget {
6162
6263 /// The expander header
6364 ///
64- /// Usually a [Text] widget
65+ /// Usually a [Text] widget.
6566 final Widget header;
6667
6768 /// The expander content
@@ -73,12 +74,15 @@ class Expander extends StatefulWidget {
7374 /// ![Expander Nested Content] (https://docs.microsoft.com/en-us/windows/apps/design/controls/images/expander-nested.png)
7475 final Widget content;
7576
76- /// The expander icon. If null, defaults to a chevron down or up, depending on
77- /// the direction.
77+ /// The expander icon.
78+ ///
79+ /// If not provided, defaults to a chevron icon down or up, depending on the
80+ /// [direction] .
7881 final Widget ? icon;
7982
80- /// The trailing widget. It's positioned at the right of [header]
81- /// and before [icon] .
83+ /// The trailing widget.
84+ ///
85+ /// It's positioned at the right of [header] and before [icon] .
8286 ///
8387 /// See also:
8488 ///
@@ -102,14 +106,19 @@ class Expander extends StatefulWidget {
102106
103107 /// Whether the [Expander] is initially expanded.
104108 ///
105- /// Defaults to `false`
109+ /// Defaults to `false` .
106110 final bool initiallyExpanded;
107111
108112 /// A callback called when the current state is changed.
109113 ///
110114 /// `true` when open and `false` when closed.
111115 final ValueChanged <bool >? onStateChanged;
112116
117+ /// Whether the [Expander] is enabled.
118+ ///
119+ /// Defaults to `true` .
120+ final bool enabled;
121+
113122 /// The background color of the header.
114123 final WidgetStateProperty <Color >? headerBackgroundColor;
115124
@@ -226,7 +235,7 @@ class ExpanderState extends State<Expander>
226235 final children = [
227236 // HEADER
228237 HoverButton (
229- onPressed: _handlePressed,
238+ onPressed: widget.enabled ? _handlePressed : null ,
230239 hitTestBehavior: HitTestBehavior .deferToChild,
231240 builder: (context, states) {
232241 return Container (
0 commit comments