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 { ...@@ -475,9 +475,7 @@ class _MultiChildComponentWidget extends Widget {
/// * [WidgetsBinding] for an explanation of rendering and non-rendering zones. /// * [WidgetsBinding] for an explanation of rendering and non-rendering zones.
class ViewCollection extends _MultiChildComponentWidget { class ViewCollection extends _MultiChildComponentWidget {
/// Creates a [ViewCollection] widget. /// Creates a [ViewCollection] widget.
/// const ViewCollection({super.key, required super.views});
/// The provided list of [views] must contain at least one widget.
const ViewCollection({super.key, required super.views}) : assert(views.length > 0);
/// The [View] descendants of this widget. /// The [View] descendants of this widget.
/// ///
......
...@@ -293,8 +293,8 @@ void main() { ...@@ -293,8 +293,8 @@ void main() {
testWidgets('ViewCollection cannot have render object widgets as children', (WidgetTester tester) async { testWidgets('ViewCollection cannot have render object widgets as children', (WidgetTester tester) async {
await pumpWidgetWithoutViewWrapper( await pumpWidgetWithoutViewWrapper(
tester: tester, tester: tester,
widget: ViewCollection( widget: const ViewCollection(
views: const <Widget>[ views: <Widget>[
ColoredBox(color: Colors.red), ColoredBox(color: Colors.red),
], ],
), ),
......
...@@ -140,8 +140,8 @@ void main() { ...@@ -140,8 +140,8 @@ void main() {
); );
}); });
testWidgets('ViewCollection must have one view', (WidgetTester tester) async { testWidgets('ViewCollection may start with zero views', (WidgetTester tester) async {
expect(() => ViewCollection(views: const <Widget>[]), throwsAssertionError); expect(() => const ViewCollection(views: <Widget>[]), returnsNormally);
}); });
testWidgets('ViewAnchor.child does not see surrounding view', (WidgetTester tester) async { 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