[Re-Land] Implement focus traversal for desktop platforms. (#31614)

This re-lands the Focus changes in #30040. Correctness changes in routes.dart, and removes the automatic requesting of focus on reparent when there is no current focus, which caused undesirable selections.

Addresses #11344, #1608, #13264, and #1678
Fixes #30084
Fixes #26704
This commit is contained in:
Greg Spencer
2019-04-25 16:26:58 -07:00
committed by GitHub
parent fdae7bb871
commit 7775c23784
23 changed files with 2836 additions and 1162 deletions

View File

@@ -62,7 +62,7 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
if (!_focusNode.hasFocus) {
return GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(_focusNode);
_focusNode.requestFocus();
},
child: Text('Tap to focus', style: textTheme.display1),
);

View File

@@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: Text(_title)),
appBar: AppBar(title: const Text(_title)),
body: MyStatefulWidget(),
),
);

View File

@@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: Text(_title)),
appBar: AppBar(title: const Text(_title)),
body: MyStatelessWidget(),
),
);

View File

@@ -90,7 +90,7 @@ import 'package:flutter/foundation.dart';
/// onTap: () {
/// FocusScope.of(context).requestFocus(_focusNode);
/// },
/// child: Text('Tap to focus'),
/// child: const Text('Tap to focus'),
/// );
/// }
/// return Text(_message ?? 'Press a key');