Closes https://github.com/flutter/flutter/issues/92040
- Adds `expanded` semantics flag support to Android
- Adds `onExpand` and `onCollapse` semantics actions
- Updates `robolectric` library
- Adds java and dart tests
#### Why were `onExpand` and `onCollapse` actions added?
It turned out that TalkBack doesn't announce the `expanded` state if
`expand/collapse` action is not set for the accessibility node.
#### Why was the `robolectric` library updated?
The `expanded` state support in Android was introduced in API 36. The
`roboelectric: 4.14.1` doesn't support API 36. To run tests for a newly
added functionality `roboelectric` library was updated to `4.16`, which
supports the latest Android version
(https://github.com/robolectric/robolectric/releases/tag/robolectric-4.16).
In case you think it would be better to update the `roboelectric` in a
separate PR, please let me know.
<br/>
<details>
<summary>Example Source Code</summary>
```dart
import 'package:flutter/material.dart';
void main() {
runApp(const App());
}
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
final _controller = ExpansibleController();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 24,
children: [
Text('Expansible Example'),
ListenableBuilder(
listenable: _controller,
builder: (context, child) {
return Semantics(
expanded: _controller.isExpanded,
onExpand: () {
print(' \n onExpand \n ');
_controller.expand();
},
onCollapse: () {
print(' \n onCollapse \n ');
_controller.collapse();
},
child: child,
);
},
child: Expansible(
headerBuilder: (context, _) => ListTile(
tileColor: Colors.blue.shade100,
leading: Text(
'Expansible',
style: TextStyle(fontSize: 20),
),
trailing: Icon(
_controller.isExpanded
? Icons.arrow_upward
: Icons.arrow_downward,
semanticLabel: _controller.isExpanded
? 'Arrow Up icon'
: 'Arrow Down icon',
),
),
bodyBuilder: (context, _) {
return Container(
color: Colors.blue,
height: 200,
width: 200,
);
},
controller: _controller,
),
),
],
),
),
);
}
}
```
</details>
https://github.com/user-attachments/assets/256c4182-a1e3-44fc-b028-5e6c9ec05ad7
## Pre-launch Checklist
- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
---------
Co-authored-by: ash2moon <muhatashim@google.com>
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.
**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.
---------
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
Set the `hasSelectedState` flag in all selectable widgets. This happens automatically because only selectable widgets have `Semantics.selected` set to a non-null value. When the value is propagated to `SemanticsConfiguration.isSelected`, it sets both `hasSelectedState` to true and `isSelected` as appropriate.
More progress towards https://github.com/flutter/flutter/issues/66673
Wire up `SemanticsAction.focus` to `Semantics` and `CustomPaint`. Reenable respective tests, and add `focus` tests to them.
Contributes to a fix for https://github.com/flutter/flutter/issues/83809
These tests essentially count the number of values in the engine enums. https://github.com/flutter/engine/pull/53094 is adding a new value, which causes these tests to fail. Temporarily disabling these tests so that the engine change can proceed.
* Honor mixed state
* Prepare for change to engine
* Unused vars
* Remove comments
* Skip test for now
* Comment for skip
* Compartmentalize changes
* Justification comments
* Adds a semantics node flag to identify sliders.
* [fuchsia] Fix roll of engine PR #25167
This changes fixes tests failing due to new isKeyboardKey semantics
flag.
* Fix typo
Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com>
* Adds set text semantics action to render editable
* addressing comments
* re-enable test
* fix test
* fix more test
* fix bad merge
* addressing comment
* update dynamic to Object?