Update ListTile docs for color animation issues and add example (#106955)

This commit is contained in:
Taha Tesser
2022-07-13 11:09:07 +03:00
committed by GitHub
parent c7ce24d345
commit c251856c89
5 changed files with 302 additions and 52 deletions

View File

@@ -0,0 +1,31 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/list_tile/list_tile.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('ListTile with Hero does not throw', (WidgetTester tester) async {
const int totalTiles = 3;
await tester.pumpWidget(
const example.ListTileApp(),
);
expect(find.byType(ListTile), findsNWidgets(totalTiles));
const String heroTransitionText = 'Tap here for Hero transition';
const String goBackText = 'Tap here to go back';
expect(find.text(heroTransitionText), findsOneWidget);
expect(find.text(goBackText), findsNothing);
await tester.tap(find.text(heroTransitionText));
await tester.pumpAndSettle();
expect(find.text(heroTransitionText), findsNothing);
expect(find.text(goBackText), findsOneWidget);
expect(tester.takeException(), null);
});
}

View File

@@ -0,0 +1,29 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/list_tile/list_tile.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('ListTiles wrapped in Card widgets', (WidgetTester tester) async {
const int totalTiles = 7;
await tester.pumpWidget(
const example.ListTileApp(),
);
expect(find.byType(ListTile), findsNWidgets(totalTiles));
for (int i = 0; i < totalTiles; i++) {
expect(
find.ancestor(
of: find.byType(ListTile).at(i),
matching: find.byType(Card).at(i),
),
findsOneWidget,
);
}
});
}