Reland "Mixin for slotted RenderObjectWidgets and RenderBox (#94077)" (#94632)

This commit is contained in:
Michael Goderbauer
2021-12-03 14:39:02 -08:00
committed by GitHub
parent 612c5f58fd
commit f4a44a9d68
11 changed files with 1002 additions and 629 deletions

View File

@@ -0,0 +1,41 @@
// 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/widgets.dart';
import 'package:flutter_api_samples/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('shows two widgets arranged diagonally', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ExampleWidget(),
);
expect(find.text('topLeft'), findsOneWidget);
expect(find.text('bottomRight'), findsOneWidget);
expect(
tester.getBottomRight(findContainerWithText('topLeft')),
tester.getTopLeft(findContainerWithText('bottomRight')),
);
expect(
tester.getSize(findContainerWithText('topLeft')),
const Size(200, 100),
);
expect(
tester.getSize(findContainerWithText('bottomRight')),
const Size(30, 60),
);
expect(
tester.getSize(find.byType(example.Diagonal)),
const Size(200 + 30, 100 + 60),
);
});
}
Finder findContainerWithText(String text) {
return find.ancestor(of: find.text(text), matching: find.byType(Container));
}