diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index b4984e04f5..00acbe6715 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -209,7 +209,9 @@ class DropDownButton extends StatefulComponent { this.value, this.onChanged, this.elevation: 8 - }) : super(key: key); + }) : super(key: key) { + assert(items.where((DropDownMenuItem item) => item.value == value).length == 1); + } final List> items; final T value; @@ -225,6 +227,7 @@ class _DropDownButtonState extends State> { void initState() { super.initState(); _updateSelectedIndex(); + assert(_selectedIndex != null); } void didUpdateConfig(DropDownButton oldConfig) { diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index cf31f1fd40..67e75bbe57 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -433,7 +433,8 @@ class RenderStack extends RenderStackBase { /// Implements the same layout algorithm as RenderStack but only paints the child /// specified by index. -/// Note: although only one child is displayed, the cost of the layout algorithm is +/// +/// Although only one child is displayed, the cost of the layout algorithm is /// still O(N), like an ordinary stack. class RenderIndexedStack extends RenderStackBase { RenderIndexedStack({ @@ -443,11 +444,14 @@ class RenderIndexedStack extends RenderStackBase { }) : _index = index, super( children: children, alignment: alignment - ); + ) { + assert(index != null); + } int get index => _index; int _index; void set index (int value) { + assert(value != null); if (_index != value) { _index = value; markNeedsLayout(); diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index c6ffb64254..ba9188c91a 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -962,7 +962,9 @@ class IndexedStack extends MultiChildRenderObjectWidget { Key key, this.alignment: const FractionalOffset(0.0, 0.0), this.index: 0 - }) : super(key: key, children: children); + }) : super(key: key, children: children) { + assert(index != null); + } /// The index of the child to show. final int index;