Repository navigation
Expand file tree
/
Copy pathmaterial_state.dart
More file actions
633 lines (601 loc) · 27.5 KB
/
Copy pathmaterial_state.dart
File metadata and controls
633 lines (601 loc) · 27.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// @docImport 'package:flutter/scheduler.dart';
///
/// @docImport 'action_chip.dart';
/// @docImport 'button_style.dart';
/// @docImport 'elevated_button.dart';
/// @docImport 'ink_well.dart';
/// @docImport 'input_decorator.dart';
/// @docImport 'list_tile.dart';
/// @docImport 'outlined_button.dart';
/// @docImport 'text_button.dart';
/// @docImport 'text_field.dart';
/// @docImport 'time_picker_theme.dart';
library;
import 'package:flutter/widgets.dart';
import 'input_border.dart';
// Examples can assume:
// late BuildContext context;
/// Interactive states that some of the Material widgets can take on when
/// receiving input from the user.
///
/// States are defined by https://material.io/design/interaction/states.html#usage.
///
/// Some Material widgets track their current state in a `Set<MaterialState>`.
///
/// See also:
///
/// * [WidgetState], a general non-Material version that can be used
/// interchangeably with `MaterialState`. They functionally work the same,
/// except [WidgetState] can be used outside of Material.
/// * [MaterialStateProperty], an interface for objects that "resolve" to
/// different values depending on a widget's material state.
/// {@template material_ui.MaterialStateProperty.implementations}
/// * [MaterialStateColor], a [Color] that implements `MaterialStateProperty`
/// which is used in APIs that need to accept either a [Color] or a
/// `MaterialStateProperty<Color>`.
/// * [MaterialStateMouseCursor], a [MouseCursor] that implements
/// `MaterialStateProperty` which is used in APIs that need to accept either
/// a [MouseCursor] or a [MaterialStateProperty<MouseCursor>].
/// * [MaterialStateOutlinedBorder], an [OutlinedBorder] that implements
/// `MaterialStateProperty` which is used in APIs that need to accept either
/// an [OutlinedBorder] or a [MaterialStateProperty<OutlinedBorder>].
/// * [MaterialStateOutlineInputBorder], an [OutlineInputBorder] that implements
/// `MaterialStateProperty` which is used in APIs that need to accept either
/// an [OutlineInputBorder] or a [MaterialStateProperty<OutlineInputBorder>].
/// * [MaterialStateUnderlineInputBorder], an [UnderlineInputBorder] that implements
/// `MaterialStateProperty` which is used in APIs that need to accept either
/// an [UnderlineInputBorder] or a [MaterialStateProperty<UnderlineInputBorder>].
/// * [MaterialStateBorderSide], a [BorderSide] that implements
/// `MaterialStateProperty` which is used in APIs that need to accept either
/// a [BorderSide] or a [MaterialStateProperty<BorderSide>].
/// * [MaterialStateTextStyle], a [TextStyle] that implements
/// `MaterialStateProperty` which is used in APIs that need to accept either
/// a [TextStyle] or a [MaterialStateProperty<TextStyle>].
/// {@endtemplate}
@Deprecated(
'Use WidgetState instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialState = WidgetState;
/// Signature for the function that returns a value of type `T` based on a given
/// set of states.
///
/// See also:
///
/// * [WidgetPropertyResolver], the non-Material form of `MaterialPropertyResolver`
/// that can be used interchangeably with `MaterialPropertyResolver.
@Deprecated(
'Use WidgetPropertyResolver instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialPropertyResolver<T> = WidgetPropertyResolver<T>;
/// Defines a [Color] that is also a [MaterialStateProperty].
///
/// This class exists to enable widgets with [Color] valued properties
/// to also accept [MaterialStateProperty<Color>] values. A material
/// state color property represents a color which depends on
/// a widget's "interactive state". This state is represented as a
/// [Set] of [MaterialState]s, like [MaterialState.pressed],
/// [MaterialState.focused] and [MaterialState.hovered].
///
/// [MaterialStateColor] should only be used with widgets that document
/// their support, like [TimePickerThemeData.dayPeriodColor].
///
/// To use a [MaterialStateColor], you can either:
/// 1. Create a subclass of [MaterialStateColor] and implement the abstract `resolve` method.
/// 2. Use [MaterialStateColor.resolveWith] and pass in a callback that
/// will be used to resolve the color in the given states.
///
/// If a [MaterialStateColor] is used for a property or a parameter that doesn't
/// support resolving [MaterialStateProperty<Color>]s, then its default color
/// value will be used for all states.
///
/// To define a `const` [MaterialStateColor], you'll need to extend
/// [MaterialStateColor] and override its [MaterialStateColor.resolve] method.
/// You'll also need to provide a `defaultValue` to the super constructor, so
/// that we can know at compile-time what its default color is.
///
/// <callout-box>
///
// TODO(framework): Add unit tests to this code snippet.
// https://github.com/flutter/flutter/issues/188530
///
/// This example defines a [MaterialStateColor] with a const constructor.
///
/// ```dart
/// // ignore: deprecated_member_use
/// class MyColor extends MaterialStateColor {
/// const MyColor() : super(_defaultColor);
///
/// static const int _defaultColor = 0xcafefeed;
/// static const int _pressedColor = 0xdeadbeef;
///
/// @override
/// // ignore: deprecated_member_use
/// Color resolve(Set<MaterialState> states) {
/// // ignore: deprecated_member_use
/// if (states.contains(MaterialState.pressed)) {
/// return const Color(_pressedColor);
/// }
/// return const Color(_defaultColor);
/// }
/// }
/// ```
///
/// </callout-box>
///
/// See also
///
/// * [WidgetStateColor], the non-Material version that can be used
/// interchangeably with `MaterialStateColor`.
@Deprecated(
'Use WidgetStateColor instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStateColor = WidgetStateColor;
/// Defines a [MouseCursor] whose value depends on a set of [MaterialState]s which
/// represent the interactive state of a component.
///
/// This kind of [MouseCursor] is useful when the set of interactive
/// actions a widget supports varies with its state. For example, a
/// mouse pointer hovering over a disabled [ListTile] should not
/// display [SystemMouseCursors.click], since a disabled list tile
/// doesn't respond to mouse clicks. [ListTile]'s default mouse cursor
/// is a [MaterialStateMouseCursor.clickable], which resolves to
/// [SystemMouseCursors.basic] when the button is disabled.
///
/// To use a [MaterialStateMouseCursor], you should create a subclass of
/// [MaterialStateMouseCursor] and implement the abstract `resolve` method.
///
/// <callout-box>
///
/// This example defines a mouse cursor that resolves to
/// [SystemMouseCursors.forbidden] when its widget is disabled.
///
// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/material_state/material_state_mouse_cursor.0.dart#body}
///
/// </callout-box>
///
/// This class should only be used for parameters which are documented to take
/// [MaterialStateMouseCursor], otherwise only the default state will be used.
///
/// See also:
///
/// * [WidgetStateMouseCursor], the non-Material version that can be used
/// interchangeably with `MaterialStateMouseCursor`.
/// * [MouseCursor] for introduction on the mouse cursor system.
/// * [SystemMouseCursors], which defines cursors that are supported by
/// native platforms.
@Deprecated(
'Use WidgetStateMouseCursor instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStateMouseCursor = WidgetStateMouseCursor;
/// Defines a [BorderSide] whose value depends on a set of [MaterialState]s
/// which represent the interactive state of a component.
///
/// To use a [MaterialStateBorderSide], you should create a subclass of a
/// [MaterialStateBorderSide] and override the abstract `resolve` method.
///
/// This class enables existing widget implementations with [BorderSide]
/// properties to be extended to also effectively support `MaterialStateProperty<BorderSide>`
/// property values. [MaterialStateBorderSide] should only be used with widgets that document
/// their support, like [ActionChip.side].
///
/// <callout-box>
///
/// This example defines a subclass of [MaterialStateBorderSide], that resolves
/// to a red border side when its widget is selected.
///
// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/material_state/material_state_border_side.0.dart#body}
///
/// </callout-box>
///
/// This class should only be used for parameters which are documented to take
/// [MaterialStateBorderSide], otherwise only the default state will be used.
///
/// See also:
///
/// * [WidgetStateBorderSide], the non-Material version that can be used
/// interchangeably with `MaterialStateBorderSide`.
@Deprecated(
'Use WidgetStateBorderSide instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStateBorderSide = WidgetStateBorderSide;
/// Defines an [OutlinedBorder] whose value depends on a set of [MaterialState]s
/// which represent the interactive state of a component.
///
/// To use a [MaterialStateOutlinedBorder], you should create a subclass of an
/// [OutlinedBorder] and implement [MaterialStateOutlinedBorder]'s abstract
/// `resolve` method.
///
/// <callout-box>
///
/// This example defines a subclass of [RoundedRectangleBorder] and an
/// implementation of [MaterialStateOutlinedBorder], that resolves to
/// [RoundedRectangleBorder] when its widget is selected.
///
// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/material_state/material_state_outlined_border.0.dart#body}
///
/// </callout-box>
///
/// This class should only be used for parameters which are documented to take
/// [MaterialStateOutlinedBorder], otherwise only the default state will be used.
///
/// See also:
///
/// * [WidgetStateOutlinedBorder], the non-Material version that can be used
/// interchangeably with `MaterialStateOutlinedBorder`.
/// * [ShapeBorder] the base class for shape outlines.
@Deprecated(
'Use WidgetStateOutlinedBorder instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStateOutlinedBorder = WidgetStateOutlinedBorder;
/// Defines a [TextStyle] that is also a [MaterialStateProperty].
///
/// This class exists to enable widgets with [TextStyle] valued properties
/// to also accept [MaterialStateProperty<TextStyle>] values. A material
/// state text style property represents a text style which depends on
/// a widget's "interactive state". This state is represented as a
/// [Set] of [MaterialState]s, like [MaterialState.pressed],
/// [MaterialState.focused] and [MaterialState.hovered].
///
/// [MaterialStateTextStyle] should only be used with widgets that document
/// their support, like [InputDecoration.labelStyle].
///
/// To use a [MaterialStateTextStyle], you can either:
/// 1. Create a subclass of [MaterialStateTextStyle] and implement the abstract `resolve` method.
/// 2. Use [MaterialStateTextStyle.resolveWith] and pass in a callback that
/// will be used to resolve the color in the given states.
///
/// If a [MaterialStateTextStyle] is used for a property or a parameter that doesn't
/// support resolving [MaterialStateProperty<TextStyle>]s, then its default color
/// value will be used for all states.
///
/// To define a `const` [MaterialStateTextStyle], you'll need to extend
/// [MaterialStateTextStyle] and override its [MaterialStateTextStyle.resolve]
/// method. You'll also need to provide a `defaultValue` to the super
/// constructor, so that we can know at compile-time what its default color is.
///
/// See also:
///
/// * [WidgetStateTextStyle], the non-Material version that can be used
/// interchangeably with `MaterialStateTextStyle`.
@Deprecated(
'Use WidgetStateTextStyle instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStateTextStyle = WidgetStateTextStyle;
/// Defines a [OutlineInputBorder] that is also a [MaterialStateProperty].
///
/// This class exists to enable widgets with [OutlineInputBorder] valued properties
/// to also accept [MaterialStateProperty<OutlineInputBorder>] values. A material
/// state input border property represents an input border which depends on
/// a widget's "interactive state". This state is represented as a
/// [Set] of [MaterialState]s, like [MaterialState.pressed],
/// [MaterialState.focused] and [MaterialState.hovered].
///
/// [MaterialStateOutlineInputBorder] should only be used with widgets that document
/// their support, like [InputDecoration.border].
///
/// To use a [MaterialStateOutlineInputBorder], you can either:
/// 1. Create a subclass of [MaterialStateOutlineInputBorder] and implement the abstract `resolve` method.
/// 2. Use [MaterialStateOutlineInputBorder.resolveWith] and pass in a callback that
/// will be used to resolve the color in the given states.
///
/// If a [MaterialStateOutlineInputBorder] is used for a property or a parameter that doesn't
/// support resolving [MaterialStateProperty<OutlineInputBorder>]s, then its default color
/// value will be used for all states.
///
/// To define a `const` [MaterialStateOutlineInputBorder], you'll need to extend
/// [MaterialStateOutlineInputBorder] and override its [resolve] method. You'll also need
/// to provide a `defaultValue` to the super constructor, so that we can know
/// at compile-time what its default color is.
@Deprecated(
'Use WidgetStateInputBorder instead. '
'Renamed to match other WidgetStateProperty objects. '
'This feature was deprecated after v3.26.0-0.1.pre.',
)
abstract class MaterialStateOutlineInputBorder extends OutlineInputBorder
implements MaterialStateProperty<InputBorder> {
/// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
@Deprecated(
'Use WidgetStateInputBorder instead. '
'Renamed to match other WidgetStateProperty objects. '
'This feature was deprecated after v3.26.0-0.1.pre.',
)
const MaterialStateOutlineInputBorder();
/// Creates a [MaterialStateOutlineInputBorder] from a [MaterialPropertyResolver<InputBorder>]
/// callback function.
///
/// If used as a regular input border, the border resolved in the default state (the
/// empty set of states) will be used.
///
/// The given callback parameter must return a non-null text style in the default
/// state.
@Deprecated(
'Use WidgetStateInputBorder.resolveWith() instead. '
'Renamed to match other WidgetStateProperty objects. '
'This feature was deprecated after v3.26.0-0.1.pre.',
)
const factory MaterialStateOutlineInputBorder.resolveWith(
MaterialPropertyResolver<InputBorder> callback,
) = _MaterialStateOutlineInputBorder;
/// Returns a [InputBorder] that's to be used when a Material component is in the
/// specified state.
@override
InputBorder resolve(Set<MaterialState> states);
}
/// A [MaterialStateOutlineInputBorder] created from a [MaterialPropertyResolver<OutlineInputBorder>]
/// callback alone.
///
/// If used as a regular input border, the border resolved in the default state will
/// be used.
///
/// Used by [MaterialStateTextStyle.resolveWith].
class _MaterialStateOutlineInputBorder extends MaterialStateOutlineInputBorder {
const _MaterialStateOutlineInputBorder(this._resolve);
final MaterialPropertyResolver<InputBorder> _resolve;
@override
InputBorder resolve(Set<MaterialState> states) => _resolve(states);
}
/// Defines a [UnderlineInputBorder] that is also a [MaterialStateProperty].
///
/// This class exists to enable widgets with [UnderlineInputBorder] valued properties
/// to also accept [MaterialStateProperty<UnderlineInputBorder>] values. A material
/// state input border property represents an input border which depends on
/// a widget's "interactive state". This state is represented as a
/// [Set] of [MaterialState]s, like [MaterialState.pressed],
/// [MaterialState.focused] and [MaterialState.hovered].
///
/// [MaterialStateUnderlineInputBorder] should only be used with widgets that document
/// their support, like [InputDecoration.border].
///
/// To use a [MaterialStateUnderlineInputBorder], you can either:
/// 1. Create a subclass of [MaterialStateUnderlineInputBorder] and implement the abstract `resolve` method.
/// 2. Use [MaterialStateUnderlineInputBorder.resolveWith] and pass in a callback that
/// will be used to resolve the color in the given states.
///
/// If a [MaterialStateUnderlineInputBorder] is used for a property or a parameter that doesn't
/// support resolving [MaterialStateProperty<UnderlineInputBorder>]s, then its default color
/// value will be used for all states.
///
/// To define a `const` [MaterialStateUnderlineInputBorder], you'll need to extend
/// [MaterialStateUnderlineInputBorder] and override its [resolve] method. You'll also need
/// to provide a `defaultValue` to the super constructor, so that we can know
/// at compile-time what its default color is.
@Deprecated(
'Use WidgetStateInputBorder instead. '
'Renamed to match other WidgetStateProperty objects. '
'This feature was deprecated after v3.26.0-0.1.pre.',
)
abstract class MaterialStateUnderlineInputBorder extends UnderlineInputBorder
implements MaterialStateProperty<InputBorder> {
/// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
@Deprecated(
'Use WidgetStateInputBorder instead. '
'Renamed to match other WidgetStateProperty objects. '
'This feature was deprecated after v3.26.0-0.1.pre.',
)
const MaterialStateUnderlineInputBorder();
/// Creates a [MaterialStateUnderlineInputBorder] from a [MaterialPropertyResolver<InputBorder>]
/// callback function.
///
/// If used as a regular input border, the border resolved in the default state (the
/// empty set of states) will be used.
///
/// The given callback parameter must return a non-null text style in the default
/// state.
@Deprecated(
'Use WidgetStateInputBorder.resolveWith() instead. '
'Renamed to match other WidgetStateProperty objects. '
'This feature was deprecated after v3.26.0-0.1.pre.',
)
const factory MaterialStateUnderlineInputBorder.resolveWith(
MaterialPropertyResolver<InputBorder> callback,
) = _MaterialStateUnderlineInputBorder;
/// Returns a [InputBorder] that's to be used when a Material component is in the
/// specified state.
@override
InputBorder resolve(Set<MaterialState> states);
}
/// A [MaterialStateUnderlineInputBorder] created from a [MaterialPropertyResolver<UnderlineInputBorder>]
/// callback alone.
///
/// If used as a regular input border, the border resolved in the default state will
/// be used.
///
/// Used by [MaterialStateTextStyle.resolveWith].
class _MaterialStateUnderlineInputBorder extends MaterialStateUnderlineInputBorder {
const _MaterialStateUnderlineInputBorder(this._resolve);
final MaterialPropertyResolver<InputBorder> _resolve;
@override
InputBorder resolve(Set<MaterialState> states) => _resolve(states);
}
/// Defines an [InputBorder] that is also a [WidgetStateProperty].
///
/// This class exists to enable widgets with [InputBorder] valued properties
/// to also accept [WidgetStateProperty] objects.
///
/// [WidgetStateInputBorder] should only be used with widgets that document
/// their support, like [InputDecoration.border].
///
/// A [WidgetStateInputBorder] can be created by:
/// 1. Creating a class that extends [OutlineInputBorder] or [UnderlineInputBorder]
/// and implements [WidgetStateInputBorder]. The class would also need to
/// override the [resolve] method.
/// 2. Using [WidgetStateInputBorder.resolveWith] with a callback that
/// resolves the input border in the given states.
/// 3. Using [WidgetStateInputBorder.fromMap] to assign a border with a [WidgetStateMap].
///
/// <callout-box>
///
/// This example shows how to use [WidgetStateInputBorder] to create
/// a [TextField] with an appearance that responds to user interaction.
///
// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/widget_state_input_border/widget_state_input_border.0.dart#body}
///
/// </callout-box>
abstract interface class WidgetStateInputBorder
implements InputBorder, WidgetStateProperty<InputBorder> {
/// Creates a [WidgetStateInputBorder] using a [WidgetPropertyResolver]
/// callback.
///
/// This constructor should only be used for fields that support
/// [WidgetStateInputBorder], such as [InputDecoration.border]
/// (if used as a regular [InputBorder], it acts the same as
/// an empty `OutlineInputBorder()` constructor).
const factory WidgetStateInputBorder.resolveWith(WidgetPropertyResolver<InputBorder> callback) =
_WidgetStateInputBorder;
/// Creates a [WidgetStateOutlinedBorder] from a [WidgetStateMap].
///
/// {@macro flutter.widgets.WidgetStateProperty.fromMap}
/// It should only be used for fields that support [WidgetStateOutlinedBorder]
/// objects, such as [InputDecoration.border]
/// (throws an error if used as a regular [OutlinedBorder]).
///
/// {@macro flutter.widgets.WidgetState.any}
const factory WidgetStateInputBorder.fromMap(WidgetStateMap<InputBorder> map) =
_WidgetInputBorderMapper;
}
class _WidgetStateInputBorder extends OutlineInputBorder implements WidgetStateInputBorder {
const _WidgetStateInputBorder(this._resolve);
final WidgetPropertyResolver<InputBorder> _resolve;
@override
InputBorder resolve(Set<WidgetState> states) => _resolve(states);
}
class _WidgetInputBorderMapper extends WidgetStateMapper<InputBorder>
implements WidgetStateInputBorder {
const _WidgetInputBorderMapper(super.map);
}
/// Interface for classes that [MaterialStateProperty.resolve] to a value of
/// type `T` based on a widget's interactive "state", which is defined as a set
/// of [MaterialState]s.
///
/// Learn more about [WidgetStateProperty] on the [Flutter YouTube channel](https://www.youtube.com/watch?v=CylXr3AF3uU).
///
/// Material state properties represent values that depend on a widget's material
/// "state". The state is encoded as a set of [MaterialState] values, like
/// [WidgetState.focused], [WidgetState.hovered], [WidgetState.pressed]. For
/// example the [InkWell.overlayColor] defines the color that fills the ink well
/// when it's pressed (the "splash color"), focused, or hovered. The [InkWell]
/// uses the overlay color's [MaterialStateProperty.resolve] method to compute
/// the color for the ink well's current state.
///
/// [ButtonStyle], which is used to configure the appearance of
/// buttons like [TextButton], [ElevatedButton], and [OutlinedButton],
/// has many material state properties. The button widgets keep track
/// of their current material state and [MaterialStateProperty.resolve] the
/// button style's material state properties when their value is needed.
///
/// <callout-box>
///
/// This example shows how you can override the default text and icon
/// color (the "foreground color") of a [TextButton] with a
/// [MaterialStateProperty]. In this example, the button's text color
/// will be `Colors.blue` when the button is being pressed, hovered,
/// or focused. Otherwise, the text color will be `Colors.red`.
///
// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/material_state/material_state_property.0.dart#body}
///
/// </callout-box>
///
/// See also:
///
/// * [WidgetStateProperty], the non-Material version that can be used
/// interchangeably with `MaterialStateProperty`.
/// {@macro material_ui.MaterialStateProperty.implementations}
@Deprecated(
'Use WidgetStateProperty instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStateProperty<T> = WidgetStateProperty<T>;
/// Convenience class for creating a [MaterialStateProperty] that
/// resolves to the given value for all states.
///
/// See also:
///
/// * [WidgetStatePropertyAll], the non-Material version that can be used
/// interchangeably with `MaterialStatePropertyAll`.
@Deprecated(
'Use WidgetStatePropertyAll instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStatePropertyAll<T> = WidgetStatePropertyAll<T>;
/// Manages a set of [MaterialState]s and notifies listeners of changes.
///
/// Used by widgets that expose their internal state for the sake of
/// extensions that add support for additional states. See
/// [TextButton] for an example.
///
/// The controller's [MaterialStatesController.value] is its current set of
/// states. Listeners are notified whenever the
/// [MaterialStatesController.value] changes. The
/// [MaterialStatesController.value] should only be changed with
/// [MaterialStatesController.update]; it should not be modified directly.
///
/// The controller's [MaterialStatesController.value] represents the set of
/// states that a widget's visual properties, typically [MaterialStateProperty]
/// values, are resolved against. It is _not_ the intrinsic state of
/// the widget. The widget is responsible for ensuring that the
/// controller's [MaterialStatesController.value] tracks its intrinsic state.
/// For example one cannot request the keyboard focus for a widget by adding
/// [WidgetState.focused] to its controller. When the widget gains or loses the
/// focus it will [MaterialStatesController.update] its controller's
/// [MaterialStatesController.value] and notify listeners of the change.
///
/// When calling `setState` in a [MaterialStatesController] listener, use the
/// [SchedulerBinding.addPostFrameCallback] to delay the call to `setState` after
/// the frame has been rendered. It's generally prudent to use the
/// [SchedulerBinding.addPostFrameCallback] because some of the widgets that
/// depend on [MaterialStatesController] may call
/// [MaterialStatesController.update] in their build method.
/// In such cases, listener's that call `setState` - during the build phase - will cause
/// an error.
///
/// See also:
///
/// * [WidgetStatesController], the non-Material version that can be used
/// interchangeably with `MaterialStatesController`.
@Deprecated(
'Use WidgetStatesController instead. '
'Moved to the Widgets layer to make code available outside of Material. '
'This feature was deprecated after v3.19.0-0.3.pre.',
)
typedef MaterialStatesController = WidgetStatesController;