diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index 6cae0c91e4..3167e759eb 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -1342,7 +1342,7 @@ class VoidCallbackAction extends Action { /// handlers in the focus chain. class DoNothingIntent extends Intent { /// Creates a const [DoNothingIntent]. - factory DoNothingIntent() => const DoNothingIntent._(); + const factory DoNothingIntent() = DoNothingIntent._; // Make DoNothingIntent constructor private so it can't be subclassed. const DoNothingIntent._(); @@ -1367,7 +1367,7 @@ class DoNothingIntent extends Intent { /// * [DoNothingIntent], a similar intent that will handle the key event. class DoNothingAndStopPropagationIntent extends Intent { /// Creates a const [DoNothingAndStopPropagationIntent]. - factory DoNothingAndStopPropagationIntent() => const DoNothingAndStopPropagationIntent._(); + const factory DoNothingAndStopPropagationIntent() = DoNothingAndStopPropagationIntent._; // Make DoNothingAndStopPropagationIntent constructor private so it can't be subclassed. const DoNothingAndStopPropagationIntent._(); diff --git a/packages/flutter/test/widgets/actions_test.dart b/packages/flutter/test/widgets/actions_test.dart index a9c058014d..24d1f6fbb8 100644 --- a/packages/flutter/test/widgets/actions_test.dart +++ b/packages/flutter/test/widgets/actions_test.dart @@ -120,7 +120,7 @@ void main() { await tester.pump(); final Object? result = Actions.maybeInvoke( containerKey.currentContext!, - DoNothingIntent(), + const DoNothingIntent(), ); expect(result, isNull); expect(invoked, isFalse); @@ -146,7 +146,7 @@ void main() { await tester.pump(); final Object? result = Actions.maybeInvoke( containerKey.currentContext!, - DoNothingIntent(), + const DoNothingIntent(), ); expect(result, isNull); expect(invoked, isFalse); diff --git a/packages/flutter/test/widgets/shortcuts_test.dart b/packages/flutter/test/widgets/shortcuts_test.dart index 4d63ae48c6..d4214ca841 100644 --- a/packages/flutter/test/widgets/shortcuts_test.dart +++ b/packages/flutter/test/widgets/shortcuts_test.dart @@ -871,7 +871,7 @@ void main() { }, child: Shortcuts( shortcuts: { - LogicalKeySet(LogicalKeyboardKey.keyA): DoNothingAndStopPropagationIntent(), + LogicalKeySet(LogicalKeyboardKey.keyA): const DoNothingAndStopPropagationIntent(), }, child: TextField(key: textFieldKey, autofocus: true), ), @@ -1710,8 +1710,8 @@ void main() { testWidgets('using a disposed token asserts', (WidgetTester tester) async { final ShortcutRegistry registry = ShortcutRegistry(); - final ShortcutRegistryEntry token = registry.addAll({ - const SingleActivator(LogicalKeyboardKey.keyA): DoNothingIntent(), + final ShortcutRegistryEntry token = registry.addAll(const { + SingleActivator(LogicalKeyboardKey.keyA): DoNothingIntent(), }); token.dispose(); expect(() {token.replaceAll({}); }, throwsFlutterError); @@ -1719,8 +1719,8 @@ void main() { testWidgets('setting duplicate bindings asserts', (WidgetTester tester) async { final ShortcutRegistry registry = ShortcutRegistry(); - final ShortcutRegistryEntry token = registry.addAll({ - const SingleActivator(LogicalKeyboardKey.keyA): DoNothingIntent(), + final ShortcutRegistryEntry token = registry.addAll(const { + SingleActivator(LogicalKeyboardKey.keyA): DoNothingIntent(), }); expect(() { final ShortcutRegistryEntry token2 = registry.addAll(const {