selected ListTile is selected (#13676)
* selected ListTile is selected * review comment * analyzer fix
This commit is contained in:
committed by
GitHub
parent
31418570a2
commit
52ebff721a
@@ -451,19 +451,22 @@ class ListTile extends StatelessWidget {
|
||||
return new InkWell(
|
||||
onTap: enabled ? onTap : null,
|
||||
onLongPress: enabled ? onLongPress : null,
|
||||
child: new ConstrainedBox(
|
||||
constraints: new BoxConstraints(minHeight: tileHeight),
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new UnconstrainedBox(
|
||||
constrainedAxis: Axis.horizontal,
|
||||
child: new SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Row(children: children),
|
||||
child: new Semantics(
|
||||
selected: selected,
|
||||
child: new ConstrainedBox(
|
||||
constraints: new BoxConstraints(minHeight: tileHeight),
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new UnconstrainedBox(
|
||||
constrainedAxis: Axis.horizontal,
|
||||
child: new SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: new Row(children: children),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' show SemanticsFlags;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../widgets/semantics_tester.dart';
|
||||
|
||||
class TestIcon extends StatefulWidget {
|
||||
const TestIcon({ Key key }) : super(key: key);
|
||||
|
||||
@@ -322,4 +327,52 @@ void main() {
|
||||
expect(textColor(subtitleKey), theme.disabledColor);
|
||||
});
|
||||
|
||||
testWidgets('ListTile semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = new SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(
|
||||
new Material(
|
||||
child: new Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: new MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
const ListTile(
|
||||
title: const Text('one'),
|
||||
),
|
||||
const ListTile(
|
||||
title: const Text('two'),
|
||||
selected: true,
|
||||
),
|
||||
const ListTile(
|
||||
title: const Text('three'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
expect(semantics, hasSemantics(
|
||||
new TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
new TestSemantics.rootChild(
|
||||
label: 'one',
|
||||
),
|
||||
new TestSemantics.rootChild(
|
||||
label: 'two',
|
||||
flags: <SemanticsFlags>[SemanticsFlags.isSelected],
|
||||
),
|
||||
new TestSemantics.rootChild(
|
||||
label: 'three',
|
||||
),
|
||||
]
|
||||
),
|
||||
ignoreTransform: true, ignoreId: true, ignoreRect: true),
|
||||
);
|
||||
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user