Unverified Commit 34198423 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Const constructor audit. (#76162)

parent d3c8a0bd
...@@ -20,7 +20,8 @@ import 'package:flutter/foundation.dart'; ...@@ -20,7 +20,8 @@ import 'package:flutter/foundation.dart';
/// * [LogicalKeyboardKey], a class with static values that describe the keys /// * [LogicalKeyboardKey], a class with static values that describe the keys
/// that are returned from [RawKeyEvent.logicalKey]. /// that are returned from [RawKeyEvent.logicalKey].
abstract class KeyboardKey with Diagnosticable { abstract class KeyboardKey with Diagnosticable {
/// A const constructor so that subclasses may be const. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const KeyboardKey(); const KeyboardKey();
} }
......
...@@ -550,7 +550,7 @@ abstract class Curve2D extends ParametricCurve<Offset> { ...@@ -550,7 +550,7 @@ abstract class Curve2D extends ParametricCurve<Offset> {
/// * [Curve2D.generateSamples], which generates samples of this type. /// * [Curve2D.generateSamples], which generates samples of this type.
/// * [Curve2D], a parametric curve that maps a double parameter to a 2D location. /// * [Curve2D], a parametric curve that maps a double parameter to a 2D location.
class Curve2DSample { class Curve2DSample {
/// A const constructor for the sample so that subclasses can be const. /// Creates an object that holds a sample; used with [Curve2D] subclasses.
/// ///
/// All arguments must not be null. /// All arguments must not be null.
const Curve2DSample(this.t, this.value) : assert(t != null), assert(value != null); const Curve2DSample(this.t, this.value) : assert(t != null), assert(value != null);
......
...@@ -93,7 +93,8 @@ class PartialStackFrame { ...@@ -93,7 +93,8 @@ class PartialStackFrame {
/// A class that filters stack frames for additional filtering on /// A class that filters stack frames for additional filtering on
/// [FlutterError.defaultStackFilter]. /// [FlutterError.defaultStackFilter].
abstract class StackFilter { abstract class StackFilter {
/// A const constructor to allow subclasses to be const. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const StackFilter(); const StackFilter();
/// Filters the list of [StackFrame]s by updating corresponding indices in /// Filters the list of [StackFrame]s by updating corresponding indices in
......
...@@ -44,7 +44,8 @@ abstract class Key { ...@@ -44,7 +44,8 @@ abstract class Key {
/// ///
/// * [Widget.key], which discusses how widgets use keys. /// * [Widget.key], which discusses how widgets use keys.
abstract class LocalKey extends Key { abstract class LocalKey extends Key {
/// Default constructor, used by subclasses. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const LocalKey() : super.empty(); const LocalKey() : super.empty();
} }
......
...@@ -30,7 +30,6 @@ part of material_animated_icons; ...@@ -30,7 +30,6 @@ part of material_animated_icons;
/// {@end-tool} /// {@end-tool}
/// ///
class AnimatedIcon extends StatelessWidget { class AnimatedIcon extends StatelessWidget {
/// Creates an AnimatedIcon. /// Creates an AnimatedIcon.
/// ///
/// The [progress] and [icon] arguments must not be null. /// The [progress] and [icon] arguments must not be null.
......
...@@ -26,7 +26,8 @@ import 'theme_data.dart'; ...@@ -26,7 +26,8 @@ import 'theme_data.dart';
/// * [ElevatedButton], a filled ButtonStyleButton whose material elevates when pressed. /// * [ElevatedButton], a filled ButtonStyleButton whose material elevates when pressed.
/// * [OutlinedButton], similar to [TextButton], but with an outline. /// * [OutlinedButton], similar to [TextButton], but with an outline.
abstract class ButtonStyleButton extends StatefulWidget { abstract class ButtonStyleButton extends StatefulWidget {
/// Create a [ButtonStyleButton]. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const ButtonStyleButton({ const ButtonStyleButton({
Key? key, Key? key,
required this.onPressed, required this.onPressed,
......
...@@ -153,6 +153,9 @@ abstract class InteractiveInkFeature extends InkFeature { ...@@ -153,6 +153,9 @@ abstract class InteractiveInkFeature extends InkFeature {
/// * [InkSplash.splashFactory] /// * [InkSplash.splashFactory]
/// * [InkRipple.splashFactory] /// * [InkRipple.splashFactory]
abstract class InteractiveInkFeatureFactory { abstract class InteractiveInkFeatureFactory {
/// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
///
/// Subclasses should provide a const constructor. /// Subclasses should provide a const constructor.
const InteractiveInkFeatureFactory(); const InteractiveInkFeatureFactory();
......
...@@ -125,7 +125,8 @@ typedef MaterialPropertyResolver<T> = T Function(Set<MaterialState> states); ...@@ -125,7 +125,8 @@ typedef MaterialPropertyResolver<T> = T Function(Set<MaterialState> states);
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
abstract class MaterialStateColor extends Color implements MaterialStateProperty<Color> { abstract class MaterialStateColor extends Color implements MaterialStateProperty<Color> {
/// Creates a [MaterialStateColor]. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const MaterialStateColor(int defaultValue) : super(defaultValue); const MaterialStateColor(int defaultValue) : super(defaultValue);
/// Creates a [MaterialStateColor] from a [MaterialPropertyResolver<Color>] /// Creates a [MaterialStateColor] from a [MaterialPropertyResolver<Color>]
...@@ -220,7 +221,8 @@ class _MaterialStateColor extends MaterialStateColor { ...@@ -220,7 +221,8 @@ class _MaterialStateColor extends MaterialStateColor {
/// * [SystemMouseCursors], which defines cursors that are supported by /// * [SystemMouseCursors], which defines cursors that are supported by
/// native platforms. /// native platforms.
abstract class MaterialStateMouseCursor extends MouseCursor implements MaterialStateProperty<MouseCursor> { abstract class MaterialStateMouseCursor extends MouseCursor implements MaterialStateProperty<MouseCursor> {
/// Creates a [MaterialStateMouseCursor]. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const MaterialStateMouseCursor(); const MaterialStateMouseCursor();
@protected @protected
...@@ -333,7 +335,8 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor { ...@@ -333,7 +335,8 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor {
/// This class should only be used for parameters which are documented to take /// This class should only be used for parameters which are documented to take
/// [MaterialStateBorderSide], otherwise only the default state will be used. /// [MaterialStateBorderSide], otherwise only the default state will be used.
abstract class MaterialStateBorderSide extends BorderSide implements MaterialStateProperty<BorderSide?> { abstract class MaterialStateBorderSide extends BorderSide implements MaterialStateProperty<BorderSide?> {
/// Creates a [MaterialStateBorderSide]. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const MaterialStateBorderSide(); const MaterialStateBorderSide();
/// Returns a [BorderSide] that's to be used when a Material component is /// Returns a [BorderSide] that's to be used when a Material component is
...@@ -393,7 +396,8 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta ...@@ -393,7 +396,8 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta
/// ///
/// * [ShapeBorder] the base class for shape outlines. /// * [ShapeBorder] the base class for shape outlines.
abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements MaterialStateProperty<OutlinedBorder?> { abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements MaterialStateProperty<OutlinedBorder?> {
/// Creates a [MaterialStateOutlinedBorder]. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const MaterialStateOutlinedBorder(); const MaterialStateOutlinedBorder();
/// Returns an [OutlinedBorder] that's to be used when a Material component is /// Returns an [OutlinedBorder] that's to be used when a Material component is
......
...@@ -434,7 +434,7 @@ abstract class PageTransitionsBuilder { ...@@ -434,7 +434,7 @@ abstract class PageTransitionsBuilder {
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
/// transition that matches native iOS page transitions. /// transition that matches native iOS page transitions.
class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
/// Construct a [FadeUpwardsPageTransitionsBuilder]. /// Constructs a page transition animation that slides the page up.
const FadeUpwardsPageTransitionsBuilder(); const FadeUpwardsPageTransitionsBuilder();
@override @override
...@@ -461,7 +461,8 @@ class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { ...@@ -461,7 +461,8 @@ class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
/// transition that matches native iOS page transitions. /// transition that matches native iOS page transitions.
class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
/// Construct a [OpenUpwardsPageTransitionsBuilder]. /// Constructs a page transition animation that matches the transition used on
/// Android P.
const OpenUpwardsPageTransitionsBuilder(); const OpenUpwardsPageTransitionsBuilder();
@override @override
...@@ -492,7 +493,8 @@ class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { ...@@ -492,7 +493,8 @@ class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
/// transition that matches native iOS page transitions. /// transition that matches native iOS page transitions.
class ZoomPageTransitionsBuilder extends PageTransitionsBuilder { class ZoomPageTransitionsBuilder extends PageTransitionsBuilder {
/// Construct a [ZoomPageTransitionsBuilder]. /// Constructs a page transition animation that matches the transition used on
/// Android 10.
const ZoomPageTransitionsBuilder(); const ZoomPageTransitionsBuilder();
@override @override
...@@ -522,7 +524,7 @@ class ZoomPageTransitionsBuilder extends PageTransitionsBuilder { ...@@ -522,7 +524,7 @@ class ZoomPageTransitionsBuilder extends PageTransitionsBuilder {
/// * [ZoomPageTransitionsBuilder], which defines a page transition similar /// * [ZoomPageTransitionsBuilder], which defines a page transition similar
/// to the one provided in Android 10. /// to the one provided in Android 10.
class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder { class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
/// Construct a [CupertinoPageTransitionsBuilder]. /// Constructs a page transition animation that matches the iOS transition.
const CupertinoPageTransitionsBuilder(); const CupertinoPageTransitionsBuilder();
@override @override
...@@ -558,12 +560,12 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder { ...@@ -558,12 +560,12 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
/// transition that matches native iOS page transitions. /// transition that matches native iOS page transitions.
@immutable @immutable
class PageTransitionsTheme with Diagnosticable { class PageTransitionsTheme with Diagnosticable {
/// Construct a PageTransitionsTheme. /// Constructs an object that selects a transition based on the platform.
/// ///
/// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder] /// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder]
/// for [TargetPlatform.android], and [CupertinoPageTransitionsBuilder] for /// for [TargetPlatform.android], and [CupertinoPageTransitionsBuilder] for
/// [TargetPlatform.iOS] and [TargetPlatform.macOS]. /// [TargetPlatform.iOS] and [TargetPlatform.macOS].
const PageTransitionsTheme({ Map<TargetPlatform, PageTransitionsBuilder>? builders }) : _builders = builders; const PageTransitionsTheme({ Map<TargetPlatform, PageTransitionsBuilder> builders = _defaultBuilders }) : _builders = builders;
static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{ static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
...@@ -574,8 +576,8 @@ class PageTransitionsTheme with Diagnosticable { ...@@ -574,8 +576,8 @@ class PageTransitionsTheme with Diagnosticable {
}; };
/// The [PageTransitionsBuilder]s supported by this theme. /// The [PageTransitionsBuilder]s supported by this theme.
Map<TargetPlatform, PageTransitionsBuilder> get builders => _builders ?? _defaultBuilders; Map<TargetPlatform, PageTransitionsBuilder> get builders => _builders;
final Map<TargetPlatform, PageTransitionsBuilder>? _builders; final Map<TargetPlatform, PageTransitionsBuilder> _builders;
/// Delegates to the builder for the current [ThemeData.platform] /// Delegates to the builder for the current [ThemeData.platform]
/// or [FadeUpwardsPageTransitionsBuilder]. /// or [FadeUpwardsPageTransitionsBuilder].
......
...@@ -68,7 +68,8 @@ _ColorsAndStops _interpolateColorsAndStops( ...@@ -68,7 +68,8 @@ _ColorsAndStops _interpolateColorsAndStops(
/// a [GradientRotation] of `pi/4` radians (i.e. 45 degrees). /// a [GradientRotation] of `pi/4` radians (i.e. 45 degrees).
@immutable @immutable
abstract class GradientTransform { abstract class GradientTransform {
/// A const constructor so that subclasses may be const. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const GradientTransform(); const GradientTransform();
/// When a [Gradient] creates its [Shader], it will call this method to /// When a [Gradient] creates its [Shader], it will call this method to
......
...@@ -287,7 +287,6 @@ abstract class CustomPainter extends Listenable { ...@@ -287,7 +287,6 @@ abstract class CustomPainter extends Listenable {
/// * [CustomPainter], which creates instances of this class. /// * [CustomPainter], which creates instances of this class.
@immutable @immutable
class CustomPainterSemantics { class CustomPainterSemantics {
/// Creates semantics information describing a rectangle on a canvas. /// Creates semantics information describing a rectangle on a canvas.
/// ///
/// Arguments `rect` and `properties` must not be null. /// Arguments `rect` and `properties` must not be null.
......
...@@ -99,7 +99,6 @@ abstract class RenderAbstractViewport extends RenderObject { ...@@ -99,7 +99,6 @@ abstract class RenderAbstractViewport extends RenderObject {
/// the [rect] position said element would have in the viewport at that /// the [rect] position said element would have in the viewport at that
/// [offset]. /// [offset].
class RevealedOffset { class RevealedOffset {
/// Instantiates a return value for [RenderAbstractViewport.getOffsetToReveal]. /// Instantiates a return value for [RenderAbstractViewport.getOffsetToReveal].
const RevealedOffset({ const RevealedOffset({
required this.offset, required this.offset,
......
...@@ -95,7 +95,6 @@ class AnnounceSemanticsEvent extends SemanticsEvent { ...@@ -95,7 +95,6 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
/// ///
/// This is only used by Android to announce tooltip values. /// This is only used by Android to announce tooltip values.
class TooltipSemanticsEvent extends SemanticsEvent { class TooltipSemanticsEvent extends SemanticsEvent {
/// Constructs an event that triggers a tooltip announcement by the platform. /// Constructs an event that triggers a tooltip announcement by the platform.
const TooltipSemanticsEvent(this.message) : super('tooltip'); const TooltipSemanticsEvent(this.message) : super('tooltip');
...@@ -115,7 +114,6 @@ class TooltipSemanticsEvent extends SemanticsEvent { ...@@ -115,7 +114,6 @@ class TooltipSemanticsEvent extends SemanticsEvent {
/// Currently only honored on Android. Triggers a long-press specific sound /// Currently only honored on Android. Triggers a long-press specific sound
/// when TalkBack is enabled. /// when TalkBack is enabled.
class LongPressSemanticsEvent extends SemanticsEvent { class LongPressSemanticsEvent extends SemanticsEvent {
/// Constructs an event that triggers a long-press semantic feedback by the platform. /// Constructs an event that triggers a long-press semantic feedback by the platform.
const LongPressSemanticsEvent() : super('longPress'); const LongPressSemanticsEvent() : super('longPress');
...@@ -128,7 +126,6 @@ class LongPressSemanticsEvent extends SemanticsEvent { ...@@ -128,7 +126,6 @@ class LongPressSemanticsEvent extends SemanticsEvent {
/// Currently only honored on Android. Triggers a tap specific sound when /// Currently only honored on Android. Triggers a tap specific sound when
/// TalkBack is enabled. /// TalkBack is enabled.
class TapSemanticEvent extends SemanticsEvent { class TapSemanticEvent extends SemanticsEvent {
/// Constructs an event that triggers a long-press semantic feedback by the platform. /// Constructs an event that triggers a long-press semantic feedback by the platform.
const TapSemanticEvent() : super('tap'); const TapSemanticEvent() : super('tap');
......
...@@ -15,7 +15,8 @@ typedef MessageHandler = Future<ByteData?>? Function(ByteData? message); ...@@ -15,7 +15,8 @@ typedef MessageHandler = Future<ByteData?>? Function(ByteData? message);
/// ///
/// This class also registers handlers for incoming messages. /// This class also registers handlers for incoming messages.
abstract class BinaryMessenger { abstract class BinaryMessenger {
/// A const constructor to allow subclasses to be const. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const BinaryMessenger(); const BinaryMessenger();
/// Calls the handler registered for the given channel. /// Calls the handler registered for the given channel.
......
...@@ -20,7 +20,8 @@ import 'package:flutter/foundation.dart'; ...@@ -20,7 +20,8 @@ import 'package:flutter/foundation.dart';
/// * [LogicalKeyboardKey], a class with static values that describe the keys /// * [LogicalKeyboardKey], a class with static values that describe the keys
/// that are returned from [RawKeyEvent.logicalKey]. /// that are returned from [RawKeyEvent.logicalKey].
abstract class KeyboardKey with Diagnosticable { abstract class KeyboardKey with Diagnosticable {
/// A const constructor so that subclasses may be const. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const KeyboardKey(); const KeyboardKey();
} }
......
...@@ -223,7 +223,7 @@ class PlatformViewsService { ...@@ -223,7 +223,7 @@ class PlatformViewsService {
/// ///
/// A Dart version of Android's [MotionEvent.PointerProperties](https://developer.android.com/reference/android/view/MotionEvent.PointerProperties). /// A Dart version of Android's [MotionEvent.PointerProperties](https://developer.android.com/reference/android/view/MotionEvent.PointerProperties).
class AndroidPointerProperties { class AndroidPointerProperties {
/// Creates an AndroidPointerProperties. /// Creates an [AndroidPointerProperties] object.
/// ///
/// All parameters must not be null. /// All parameters must not be null.
const AndroidPointerProperties({ const AndroidPointerProperties({
......
...@@ -114,10 +114,8 @@ enum ModifierKey { ...@@ -114,10 +114,8 @@ enum ModifierKey {
/// * [RawKeyboard], which uses these interfaces to expose key data. /// * [RawKeyboard], which uses these interfaces to expose key data.
@immutable @immutable
abstract class RawKeyEventData { abstract class RawKeyEventData {
/// Abstract const constructor. /// Abstract const constructor. This constructor enables subclasses to provide
/// /// const constructors so that they can be used in const expressions.
/// This constructor enables subclasses to provide const constructors so that
/// they can be used in const expressions.
const RawKeyEventData(); const RawKeyEventData();
/// Returns true if the given [ModifierKey] was pressed at the time of this /// Returns true if the given [ModifierKey] was pressed at the time of this
...@@ -255,8 +253,8 @@ abstract class RawKeyEventData { ...@@ -255,8 +253,8 @@ abstract class RawKeyEventData {
/// * [RawKeyboardListener], a widget that listens for raw key events. /// * [RawKeyboardListener], a widget that listens for raw key events.
@immutable @immutable
abstract class RawKeyEvent with Diagnosticable { abstract class RawKeyEvent with Diagnosticable {
/// Initializes fields for subclasses, and provides a const constructor for /// Abstract const constructor. This constructor enables subclasses to provide
/// const subclasses. /// const constructors so that they can be used in const expressions.
const RawKeyEvent({ const RawKeyEvent({
required this.data, required this.data,
this.character, this.character,
......
...@@ -42,7 +42,8 @@ BuildContext _getParent(BuildContext context) { ...@@ -42,7 +42,8 @@ BuildContext _getParent(BuildContext context) {
/// [BuildContext]. /// [BuildContext].
@immutable @immutable
abstract class Intent with Diagnosticable { abstract class Intent with Diagnosticable {
/// A const constructor for an [Intent]. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const Intent(); const Intent();
/// An intent that is mapped to a [DoNothingAction], which, as the name /// An intent that is mapped to a [DoNothingAction], which, as the name
...@@ -485,7 +486,7 @@ class CallbackAction<T extends Intent> extends Action<T> { ...@@ -485,7 +486,7 @@ class CallbackAction<T extends Intent> extends Action<T> {
/// - [Actions] widget, which defines a mapping between a in [Intent] type and /// - [Actions] widget, which defines a mapping between a in [Intent] type and
/// an [Action]. /// an [Action].
class ActionDispatcher with Diagnosticable { class ActionDispatcher with Diagnosticable {
/// Const constructor so that subclasses can be immutable. /// Creates an action dispatcher that invokes actions directly.
const ActionDispatcher(); const ActionDispatcher();
/// Invokes the given `action`, passing it the given `intent`. /// Invokes the given `action`, passing it the given `intent`.
...@@ -1561,7 +1562,7 @@ class DoNothingAction extends Action<Intent> { ...@@ -1561,7 +1562,7 @@ class DoNothingAction extends Action<Intent> {
/// * [WidgetsApp.shortcuts], which defines the shortcuts to use in an /// * [WidgetsApp.shortcuts], which defines the shortcuts to use in an
/// application (and defaults to [WidgetsApp.defaultShortcuts]). /// application (and defaults to [WidgetsApp.defaultShortcuts]).
class ActivateIntent extends Intent { class ActivateIntent extends Intent {
/// Creates a const [ActivateIntent] so subclasses can be const. /// Creates an intent that activates the currently focused control.
const ActivateIntent(); const ActivateIntent();
} }
...@@ -1578,7 +1579,7 @@ class ActivateIntent extends Intent { ...@@ -1578,7 +1579,7 @@ class ActivateIntent extends Intent {
/// * [WidgetsApp.shortcuts], which defines the shortcuts to use in an /// * [WidgetsApp.shortcuts], which defines the shortcuts to use in an
/// application (and defaults to [WidgetsApp.defaultShortcuts]). /// application (and defaults to [WidgetsApp.defaultShortcuts]).
class ButtonActivateIntent extends Intent { class ButtonActivateIntent extends Intent {
/// Creates a const [ButtonActivateIntent] so subclasses can be const. /// Creates an intent that the currently focused control, if it's a button.
const ButtonActivateIntent(); const ButtonActivateIntent();
} }
...@@ -1608,7 +1609,7 @@ abstract class SelectAction extends Action<SelectIntent> {} ...@@ -1608,7 +1609,7 @@ abstract class SelectAction extends Action<SelectIntent> {}
/// - [ModalRoute] which listens for this intent to dismiss modal routes /// - [ModalRoute] which listens for this intent to dismiss modal routes
/// (dialogs, pop-up menus, drawers, etc). /// (dialogs, pop-up menus, drawers, etc).
class DismissIntent extends Intent { class DismissIntent extends Intent {
/// Creates a const [DismissIntent]. /// Creates an intent that dismisses the currently focused widget.
const DismissIntent(); const DismissIntent();
} }
...@@ -1619,8 +1620,11 @@ abstract class DismissAction extends Action<DismissIntent> {} ...@@ -1619,8 +1620,11 @@ abstract class DismissAction extends Action<DismissIntent> {}
/// An [Intent] that evaluates a series of specified [orderedIntents] for /// An [Intent] that evaluates a series of specified [orderedIntents] for
/// execution. /// execution.
///
/// The first intent that matches an enabled action is used.
class PrioritizedIntents extends Intent { class PrioritizedIntents extends Intent {
/// Creates a set of const [PrioritizedIntents]. /// Creates an intent that is used with [PrioritizedAction] to specify a list
/// of intents, the first available of which will be used.
const PrioritizedIntents({ const PrioritizedIntents({
required this.orderedIntents, required this.orderedIntents,
}) : assert(orderedIntents != null); }) : assert(orderedIntents != null);
......
...@@ -113,7 +113,8 @@ enum TraversalDirection { ...@@ -113,7 +113,8 @@ enum TraversalDirection {
/// focus traversal in a direction. /// focus traversal in a direction.
@immutable @immutable
abstract class FocusTraversalPolicy with Diagnosticable { abstract class FocusTraversalPolicy with Diagnosticable {
/// A const constructor so subclasses can be const. /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions.
const FocusTraversalPolicy(); const FocusTraversalPolicy();
/// Returns the node that should receive focus if focus is traversing /// Returns the node that should receive focus if focus is traversing
...@@ -1190,8 +1191,7 @@ abstract class FocusOrder with Diagnosticable implements Comparable<FocusOrder> ...@@ -1190,8 +1191,7 @@ abstract class FocusOrder with Diagnosticable implements Comparable<FocusOrder>
/// * [FocusTraversalOrder], a widget that assigns an order to a widget subtree /// * [FocusTraversalOrder], a widget that assigns an order to a widget subtree
/// for the [OrderedTraversalPolicy] to use. /// for the [OrderedTraversalPolicy] to use.
class NumericFocusOrder extends FocusOrder { class NumericFocusOrder extends FocusOrder {
/// Const constructor. This constructor enables subclasses to provide /// Creates an object that describes a focus traversal order numerically.
/// const constructors so that they can be used in const expressions.
const NumericFocusOrder(this.order) : assert(order != null); const NumericFocusOrder(this.order) : assert(order != null);
/// The numerical order to assign to the widget subtree using /// The numerical order to assign to the widget subtree using
...@@ -1219,7 +1219,7 @@ class NumericFocusOrder extends FocusOrder { ...@@ -1219,7 +1219,7 @@ class NumericFocusOrder extends FocusOrder {
/// traversed with the keyboard. /// traversed with the keyboard.
/// ///
/// This sorts strings using Dart's default string comparison, which is not /// This sorts strings using Dart's default string comparison, which is not
/// locale specific. /// locale-specific.
/// ///
/// {@macro flutter.widgets.FocusOrder.comparable} /// {@macro flutter.widgets.FocusOrder.comparable}
/// ///
...@@ -1228,8 +1228,7 @@ class NumericFocusOrder extends FocusOrder { ...@@ -1228,8 +1228,7 @@ class NumericFocusOrder extends FocusOrder {
/// * [FocusTraversalOrder], a widget that assigns an order to a widget subtree /// * [FocusTraversalOrder], a widget that assigns an order to a widget subtree
/// for the [OrderedTraversalPolicy] to use. /// for the [OrderedTraversalPolicy] to use.
class LexicalFocusOrder extends FocusOrder { class LexicalFocusOrder extends FocusOrder {
/// Const constructor. This constructor enables subclasses to provide /// Creates an object that describes a focus traversal order lexically.
/// const constructors so that they can be used in const expressions.
const LexicalFocusOrder(this.order) : assert(order != null); const LexicalFocusOrder(this.order) : assert(order != null);
/// The String that defines the lexical order to assign to the widget subtree /// The String that defines the lexical order to assign to the widget subtree
...@@ -1406,7 +1405,8 @@ class OrderedTraversalPolicy extends FocusTraversalPolicy with DirectionalFocusT ...@@ -1406,7 +1405,8 @@ class OrderedTraversalPolicy extends FocusTraversalPolicy with DirectionalFocusT
/// The order for a widget is determined by the [FocusOrder] returned by /// The order for a widget is determined by the [FocusOrder] returned by
/// [FocusTraversalOrder.of] for a particular context. /// [FocusTraversalOrder.of] for a particular context.
class FocusTraversalOrder extends InheritedWidget { class FocusTraversalOrder extends InheritedWidget {
/// A const constructor so that subclasses can be const. /// Creates an inherited widget used to describe the focus order of
/// the [child] subtree.
const FocusTraversalOrder({Key? key, required this.order, required Widget child}) : super(key: key, child: child); const FocusTraversalOrder({Key? key, required this.order, required Widget child}) : super(key: key, child: child);
/// The order for the widget descendants of this [FocusTraversalOrder]. /// The order for the widget descendants of this [FocusTraversalOrder].
...@@ -1819,8 +1819,9 @@ class _FocusTraversalGroupMarker extends InheritedWidget { ...@@ -1819,8 +1819,9 @@ class _FocusTraversalGroupMarker extends InheritedWidget {
/// An intent for use with the [RequestFocusAction], which supplies the /// An intent for use with the [RequestFocusAction], which supplies the
/// [FocusNode] that should be focused. /// [FocusNode] that should be focused.
class RequestFocusIntent extends Intent { class RequestFocusIntent extends Intent {
/// A const constructor for a [RequestFocusIntent], so that subclasses may be /// Creates an intent used with [RequestFocusAction].
/// const. ///
/// The argument must not be null.
const RequestFocusIntent(this.focusNode) const RequestFocusIntent(this.focusNode)
: assert(focusNode != null); : assert(focusNode != null);
...@@ -1864,7 +1865,7 @@ class RequestFocusAction extends Action<RequestFocusIntent> { ...@@ -1864,7 +1865,7 @@ class RequestFocusAction extends Action<RequestFocusIntent> {
/// ///
/// See [FocusTraversalPolicy] for more information about focus traversal. /// See [FocusTraversalPolicy] for more information about focus traversal.
class NextFocusIntent extends Intent { class NextFocusIntent extends Intent {
/// Creates a const [NextFocusIntent] so subclasses can be const. /// Creates an intent that is used with [NextFocusAction].
const NextFocusIntent(); const NextFocusIntent();
} }
...@@ -1887,7 +1888,7 @@ class NextFocusAction extends Action<NextFocusIntent> { ...@@ -1887,7 +1888,7 @@ class NextFocusAction extends Action<NextFocusIntent> {
/// ///
/// See [FocusTraversalPolicy] for more information about focus traversal. /// See [FocusTraversalPolicy] for more information about focus traversal.
class PreviousFocusIntent extends Intent { class PreviousFocusIntent extends Intent {
/// Creates a const [PreviousFocusIntent] so subclasses can be const. /// Creates an intent that is used with [PreviousFocusAction].
const PreviousFocusIntent(); const PreviousFocusIntent();
} }
...@@ -1916,8 +1917,7 @@ class PreviousFocusAction extends Action<PreviousFocusIntent> { ...@@ -1916,8 +1917,7 @@ class PreviousFocusAction extends Action<PreviousFocusIntent> {
/// ///
/// See [FocusTraversalPolicy] for more information about focus traversal. /// See [FocusTraversalPolicy] for more information about focus traversal.
class DirectionalFocusIntent extends Intent { class DirectionalFocusIntent extends Intent {
/// Creates a [DirectionalFocusIntent] intending to move the focus in the /// Creates an intent used to move the focus in the given [direction].
/// given [direction].
const DirectionalFocusIntent(this.direction, {this.ignoreTextFields = true}) const DirectionalFocusIntent(this.direction, {this.ignoreTextFields = true})
: assert(ignoreTextFields != null); : assert(ignoreTextFields != null);
......
...@@ -16,6 +16,10 @@ import 'framework.dart'; ...@@ -16,6 +16,10 @@ import 'framework.dart';
/// [Scaffold] sets its app bar height to the app bar's preferred height /// [Scaffold] sets its app bar height to the app bar's preferred height
/// plus the height of the system status bar. /// plus the height of the system status bar.
/// ///
/// Widgets that need to know the preferred size of their child can require
/// that their child implement this interface by using this class rather
/// than [Widget] as the type of their `child` property.
///
/// Use [PreferredSize] to give a preferred size to an arbitrary widget. /// Use [PreferredSize] to give a preferred size to an arbitrary widget.
abstract class PreferredSizeWidget implements Widget { abstract class PreferredSizeWidget implements Widget {
/// The size this widget would prefer if it were otherwise unconstrained. /// The size this widget would prefer if it were otherwise unconstrained.
...@@ -33,7 +37,13 @@ abstract class PreferredSizeWidget implements Widget { ...@@ -33,7 +37,13 @@ abstract class PreferredSizeWidget implements Widget {
/// affect the child's layout in any way. It just advertises a preferred size /// affect the child's layout in any way. It just advertises a preferred size
/// which can be used by the parent. /// which can be used by the parent.
/// ///
/// Widgets like [AppBar] implement a [PreferredSizeWidget]. /// Parents like [Scaffold] use [PreferredSizeWidget] to require that their
/// children implement that interface. To give a preferred size to an arbitrary
/// widget so that it can be used in a `child` property of that type, this
/// widget, [PreferredSize], can be used.
///
/// Widgets like [AppBar] implement a [PreferredSizeWidget], so that this
/// [PreferredSize] widget is not necessary for them.
/// ///
/// {@tool dartpad --template=stateless_widget_material} /// {@tool dartpad --template=stateless_widget_material}
/// ///
...@@ -111,7 +121,7 @@ abstract class PreferredSizeWidget implements Widget { ...@@ -111,7 +121,7 @@ abstract class PreferredSizeWidget implements Widget {
/// its preferred size. /// its preferred size.
/// * [AppBar] and [TabBar], which implement PreferredSizeWidget. /// * [AppBar] and [TabBar], which implement PreferredSizeWidget.
class PreferredSize extends StatelessWidget implements PreferredSizeWidget { class PreferredSize extends StatelessWidget implements PreferredSizeWidget {
/// Creates a widget that has a preferred size. /// Creates a widget that has a preferred size that the parent can query.
const PreferredSize({ const PreferredSize({
Key? key, Key? key,
required this.child, required this.child,
......
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