Commit 4dacd69b authored by Hixie's avatar Hixie

Don't set keys on images, etc, pre-emptively.

In theory, before, if you had the same image twice in a scrolling container, you'd get an assertion with no way around it.
This makes those nodes not bother making keys by default, which is cheaper and more correct.
parent 3d0b82eb
...@@ -488,9 +488,7 @@ class Text extends Component { ...@@ -488,9 +488,7 @@ class Text extends Component {
} }
class Image extends LeafRenderObjectWrapper { class Image extends LeafRenderObjectWrapper {
Image({ sky.Image image, this.width, this.height, this.colorFilter }) Image({ Key key, this.image, this.width, this.height, this.colorFilter }) : super(key: key);
: image = image,
super(key: new Key.fromObjectIdentity(image));
final sky.Image image; final sky.Image image;
final double width; final double width;
...@@ -510,8 +508,7 @@ class Image extends LeafRenderObjectWrapper { ...@@ -510,8 +508,7 @@ class Image extends LeafRenderObjectWrapper {
} }
class FutureImage extends StatefulComponent { class FutureImage extends StatefulComponent {
FutureImage({ Key key, this.image, this.width, this.height, this.colorFilter }) FutureImage({ Key key, this.image, this.width, this.height, this.colorFilter }) : super(key: key);
: super(key: key);
Future<sky.Image> image; Future<sky.Image> image;
double width; double width;
...@@ -555,9 +552,7 @@ class FutureImage extends StatefulComponent { ...@@ -555,9 +552,7 @@ class FutureImage extends StatefulComponent {
} }
class NetworkImage extends Component { class NetworkImage extends Component {
NetworkImage({ String src, this.width, this.height, this.colorFilter }) NetworkImage({ Key key, this.src, this.width, this.height, this.colorFilter }) : super(key: key);
: src = src,
super(key: new Key(src));
final String src; final String src;
final double width; final double width;
...@@ -575,9 +570,7 @@ class NetworkImage extends Component { ...@@ -575,9 +570,7 @@ class NetworkImage extends Component {
} }
class AssetImage extends Component { class AssetImage extends Component {
AssetImage({ String name, this.bundle, this.width, this.height, this.colorFilter }) AssetImage({ Key key, this.name, this.bundle, this.width, this.height, this.colorFilter }) : super(key: key);
: name = name,
super(key: new Key(name));
final String name; final String name;
final AssetBundle bundle; final AssetBundle bundle;
......
...@@ -11,8 +11,7 @@ import 'package:sky/widgets/widget.dart'; ...@@ -11,8 +11,7 @@ import 'package:sky/widgets/widget.dart';
class IconButton extends Component { class IconButton extends Component {
IconButton({ String icon: '', this.onPressed, this.color }) IconButton({ Key key, this.icon, this.onPressed, this.color }) : super(key: key);
: super(key: new Key(icon)), icon = icon;
final String icon; final String icon;
final Function onPressed; final Function onPressed;
......
...@@ -249,14 +249,14 @@ class RenderTabBar extends RenderBox with ...@@ -249,14 +249,14 @@ class RenderTabBar extends RenderBox with
class TabBarWrapper extends MultiChildRenderObjectWrapper { class TabBarWrapper extends MultiChildRenderObjectWrapper {
TabBarWrapper({ TabBarWrapper({
Key key,
List<Widget> children, List<Widget> children,
this.selectedIndex, this.selectedIndex,
this.backgroundColor, this.backgroundColor,
this.indicatorColor, this.indicatorColor,
this.textAndIcons, this.textAndIcons,
this.scrollable: false, this.scrollable: false,
this.onLayoutChanged, this.onLayoutChanged
Key key
}) : super(key: key, children: children); }) : super(key: key, children: children);
final int selectedIndex; final int selectedIndex;
...@@ -378,13 +378,11 @@ class TabBar extends Scrollable { ...@@ -378,13 +378,11 @@ class TabBar extends Scrollable {
} }
Widget _toTab(TabLabel label, int tabIndex) { Widget _toTab(TabLabel label, int tabIndex) {
Tab tab = new Tab(
label: label,
selected: tabIndex == selectedIndex,
key: new Key(label.text == null ? label.icon : label.text)
);
return new Listener( return new Listener(
child: tab, child: new Tab(
label: label,
selected: tabIndex == selectedIndex
),
onGestureTap: (_) => _handleTap(tabIndex) onGestureTap: (_) => _handleTap(tabIndex)
); );
} }
......
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