Skip to content

Document that Hero needs everything present and ready on frame zero of the transition animation #15586

@smkhalsa

Description

@smkhalsa

Steps to Reproduce

When navigating from a list view which displays the below CollectionPhoto to the CollectionDetails screen, the Hero animation is not shown. However, when I press the back button from the CollectionDetails page, the animation shows the image moving back into the list.

class CollectionPhoto extends StatelessWidget {
  CollectionPhoto({ Key key, this.imageName, this.collectionId,  }) : super(key: key);

  final String imageName;
  final String collectionId;

  @override
  Widget build(BuildContext context) {
    return new Material(
      color: Colors.transparent,
      child: new InkWell(
        onTap: () {
          Application.router.navigateTo(context, '/collections/$collectionId', transition: TransitionType.native);
        },
        child: new Hero(
          tag: '$collectionId-image',
          child: new Image.network(URLS.getCollectionImageURL(imageName)),
        )
      )
    );
  }
}
class CollectionDetails extends StatelessWidget {
  CollectionDetails({ Key key, this.id }) : super(key: key);
  
  final String id;

  @override
  Widget build(BuildContext context) {
    return new StreamBuilder(
      stream: Firestore.instance.collection('collections')
        .document(id)
        .snapshots,
      builder: (context, snapshot) {
        if (!snapshot.hasData) return new Text('Loading...');
        return new Scaffold(
          appBar: new AppBar(
            title: new Text(snapshot.data.data['name']),
          ),
          body: new Hero(
            tag: '$id-image',
            child: new Image.network(URLS.getCollectionImageURL(snapshot.data.data['imageName'])),
          )
        );
      },
    );
  }
}

Metadata

Metadata

Assignees

Labels

d: api docsIssues with https://api.flutter.dev/f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions