Make the focus node on SelectableRegion optional. (#158994)

## Description

This makes the `focusNode`  for `SelectableRegion` optional so that:
- Users of the widget are no longer required to use `SelectableRegion`
from within a `StatefulWidget`
- They aren't likely to forget to dispose of a node they didn't supply.
- Simpler to use, and the node is not used very often anyhow.

Also made the `SelectableRegion` sample actually use `SelectableRegion`.

## Tests
- Modified all the `SelectableRegion` tests to remove 3 identical lines
of boilerplate from each (except 2, which actually used their focus
nodes).
This commit is contained in:
Greg Spencer
2024-11-15 14:39:41 -08:00
committed by GitHub
parent 917b48d942
commit 4d3bbf30c8
5 changed files with 28 additions and 313 deletions

View File

@@ -15,7 +15,8 @@ class SelectableRegionExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SelectionArea(
home: SelectableRegion(
selectionControls: materialTextSelectionControls,
child: Scaffold(
appBar: AppBar(title: const Text('SelectableRegion Sample')),
body: const Center(