Accessibility: repeated label on BottomNavigationBar fixed (#71587)
This commit is contained in:
parent
ea7017d3a8
commit
7ce8f4abae
@ -492,6 +492,7 @@ class _BottomNavigationTile extends StatelessWidget {
|
|||||||
message: item.label!,
|
message: item.label!,
|
||||||
preferBelow: false,
|
preferBelow: false,
|
||||||
verticalOffset: selectedIconSize + selectedFontSize,
|
verticalOffset: selectedIconSize + selectedFontSize,
|
||||||
|
excludeFromSemantics: true,
|
||||||
child: result,
|
child: result,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:vector_math/vector_math_64.dart' show Vector3;
|
import 'package:vector_math/vector_math_64.dart' show Vector3;
|
||||||
|
|
||||||
import '../rendering/mock_canvas.dart';
|
import '../rendering/mock_canvas.dart';
|
||||||
|
import '../widgets/semantics_tester.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('BottomNavigationBar callback test', (WidgetTester tester) async {
|
testWidgets('BottomNavigationBar callback test', (WidgetTester tester) async {
|
||||||
@ -1786,6 +1787,78 @@ void main() {
|
|||||||
|
|
||||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('BottomNavigationBar excludes semantics',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
final SemanticsTester semantics = SemanticsTester(tester);
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
|
items: const <BottomNavigationBarItem>[
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
label: 'A',
|
||||||
|
icon: Icon(Icons.ac_unit),
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
label: 'B',
|
||||||
|
icon: Icon(Icons.battery_alert),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
semantics,
|
||||||
|
hasSemantics(
|
||||||
|
TestSemantics.root(
|
||||||
|
children: <TestSemantics>[
|
||||||
|
TestSemantics(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
children: <TestSemantics>[
|
||||||
|
TestSemantics(
|
||||||
|
children: <TestSemantics>[
|
||||||
|
TestSemantics(
|
||||||
|
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
|
||||||
|
children: <TestSemantics>[
|
||||||
|
TestSemantics(
|
||||||
|
children: <TestSemantics>[
|
||||||
|
TestSemantics(
|
||||||
|
flags: <SemanticsFlag>[
|
||||||
|
SemanticsFlag.isSelected,
|
||||||
|
SemanticsFlag.isFocusable
|
||||||
|
],
|
||||||
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
|
label: 'A\nTab 1 of 2',
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
),
|
||||||
|
TestSemantics(
|
||||||
|
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
|
||||||
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
|
label: 'B\nTab 2 of 2',
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ignoreId: true,
|
||||||
|
ignoreRect: true,
|
||||||
|
ignoreTransform: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
semantics.dispose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget boilerplate({ Widget? bottomNavigationBar, required TextDirection textDirection }) {
|
Widget boilerplate({ Widget? bottomNavigationBar, required TextDirection textDirection }) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user