diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index 2847c79cd5..02f2c38287 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:collection' show HashSet; import 'package:flutter/material.dart'; @@ -265,8 +264,7 @@ class ProductItem extends StatelessWidget { height: 144.0, padding: const EdgeInsets.symmetric(horizontal: 8.0), child: new Hero( - tag: productHeroTag, - key: new ObjectKey(product), + tag: product.tag, child: new Image.asset(product.imageAsset, fit: ImageFit.contain) ) ), @@ -306,12 +304,8 @@ class _ShrineHomeState extends State { void showOrderPage(Product product) { final Order order = _shoppingCart[product] ?? new Order(product: product); final Completer completer = new Completer(); - final Key productKey = new ObjectKey(product); - final Set mostValuableKeys = new HashSet(); - mostValuableKeys.add(productKey); Navigator.push(context, new ShrineOrderRoute( order: order, - settings: new RouteSettings(mostValuableKeys: mostValuableKeys), completer: completer, builder: (BuildContext context) { return new OrderPage( diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index 359b59ebab..2607df58e1 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -40,7 +40,7 @@ class OrderItem extends StatelessWidget { width: 248.0, height: 248.0, child: new Hero( - tag: productHeroTag, + tag: product.tag, child: new Image.asset(product.imageAsset, fit: ImageFit.contain) ) ) diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart index d412350936..06381c1bfa 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart @@ -4,8 +4,6 @@ import 'dart:ui' show hashValues; -const String productHeroTag = 'Product'; - class Vendor { const Vendor({ this.name, @@ -48,6 +46,7 @@ class Product { final double price; final Vendor vendor; + String get tag => name; // Unique value for Heroes String get priceString => '\$${price.floor()}'; bool isValid() { diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index aa7ac7cd61..80a4b5d28b 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -387,7 +387,7 @@ class HeroParty { assert(to == null || to.sourceStates.length == 1); assert(to == null || to.currentTurns.floor() == to.currentTurns); HeroState targetState = to != null ? to.sourceStates.elementAt(0) : null; - Set sourceStates = from != null ? from.sourceStates : new HashSet(); + Set sourceStates = from?.sourceStates ?? new HashSet(); sourceStates.remove(targetState); Rect sourceRect = from?.currentRect ?? to.currentRect.center & Size.zero; Rect targetRect = to?.currentRect ?? from.currentRect.center & Size.zero; @@ -545,7 +545,7 @@ class HeroController extends NavigatorObserver { void _updateQuest(Duration timeStamp) { if (navigator == null) { - // The navigator has been removed for this end-of-frame callback was called. + // The navigator was removed before this end-of-frame callback was called. return; } Set mostValuableKeys = _getMostValuableKeys();