Unverified Commit 6b4f0d57 authored by David Iglesias's avatar David Iglesias Committed by GitHub

[flutter] Allow ViewCollection to start empty. (#140532)

This enables multi-view apps to start with zero views.
parent 3ac2dba5
......@@ -475,9 +475,7 @@ class _MultiChildComponentWidget extends Widget {
/// * [WidgetsBinding] for an explanation of rendering and non-rendering zones.
class ViewCollection extends _MultiChildComponentWidget {
/// Creates a [ViewCollection] widget.
///
/// The provided list of [views] must contain at least one widget.
const ViewCollection({super.key, required super.views}) : assert(views.length > 0);
const ViewCollection({super.key, required super.views});
/// The [View] descendants of this widget.
///
......
......@@ -293,8 +293,8 @@ void main() {
testWidgets('ViewCollection cannot have render object widgets as children', (WidgetTester tester) async {
await pumpWidgetWithoutViewWrapper(
tester: tester,
widget: ViewCollection(
views: const <Widget>[
widget: const ViewCollection(
views: <Widget>[
ColoredBox(color: Colors.red),
],
),
......
......@@ -140,8 +140,8 @@ void main() {
);
});
testWidgets('ViewCollection must have one view', (WidgetTester tester) async {
expect(() => ViewCollection(views: const <Widget>[]), throwsAssertionError);
testWidgets('ViewCollection may start with zero views', (WidgetTester tester) async {
expect(() => const ViewCollection(views: <Widget>[]), returnsNormally);
});
testWidgets('ViewAnchor.child does not see surrounding view', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment