[flutter] Allow ViewCollection to start empty. (#140532)
This enables multi-view apps to start with zero views.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user