Add Gamepad support for the activation action (#49987)
This commit is contained in:
parent
52d5744ea2
commit
7467bde424
@ -847,6 +847,7 @@ class WidgetsApp extends StatefulWidget {
|
||||
// Activation
|
||||
LogicalKeySet(LogicalKeyboardKey.enter): const Intent(ActivateAction.key),
|
||||
LogicalKeySet(LogicalKeyboardKey.space): const Intent(ActivateAction.key),
|
||||
LogicalKeySet(LogicalKeyboardKey.gameButtonA): const Intent(ActivateAction.key),
|
||||
|
||||
// Keyboard traversal.
|
||||
LogicalKeySet(LogicalKeyboardKey.tab): const Intent(NextFocusAction.key),
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@ -96,6 +97,48 @@ void main() {
|
||||
expect(action.calls, equals(1));
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp default activation key mappings work', (WidgetTester tester) async {
|
||||
bool checked = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
WidgetsApp(
|
||||
builder: (BuildContext context, Widget child) {
|
||||
return Material(
|
||||
child: Checkbox(
|
||||
value: checked,
|
||||
autofocus: true,
|
||||
onChanged: (bool value) {
|
||||
checked = value;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
color: const Color(0xFF123456),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
// Test three default buttons for the activation action.
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
||||
await tester.pumpAndSettle();
|
||||
expect(checked, isTrue);
|
||||
|
||||
// Only space is used as an activation key on web.
|
||||
if (kIsWeb) {
|
||||
return;
|
||||
}
|
||||
|
||||
checked = false;
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
||||
await tester.pumpAndSettle();
|
||||
expect(checked, isTrue);
|
||||
|
||||
checked = false;
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonA);
|
||||
await tester.pumpAndSettle();
|
||||
expect(checked, isTrue);
|
||||
});
|
||||
|
||||
group('error control test', () {
|
||||
Future<void> expectFlutterError({
|
||||
GlobalKey<NavigatorState> key,
|
||||
|
Loading…
x
Reference in New Issue
Block a user