Created
May 9, 2019 00:10
-
-
Save skabber/8dbf7cdee1431b13d8b87d8ff9075fa3 to your computer and use it in GitHub Desktop.
Hero Widget transitionOnUserGestures bug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:cached_network_image/cached_network_image.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return CupertinoApp( | |
title: 'Flutter Demo', | |
home: MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return CupertinoPageScaffold( | |
child: CupertinoScrollbar( | |
child: CustomScrollView( | |
slivers: <Widget>[ | |
CupertinoSliverNavigationBar( | |
largeTitle: Text("Hero"), | |
), | |
SliverList( | |
delegate: SliverChildBuilderDelegate((context, num) { | |
return Row( | |
children: <Widget>[ | |
GestureDetector( | |
onTap: () { | |
print("object"); | |
Navigator.of(context) | |
.push(CupertinoPageRoute(builder: (context) { | |
return PageTwo(); | |
})); | |
}, | |
child: Hero( | |
tag: "hero1", | |
transitionOnUserGestures: true, | |
child: ClipPath( | |
clipper: RightSlantClipper(), | |
child: Container( | |
color: Colors.green, | |
width: 80.0, | |
child: CachedNetworkImage( | |
imageUrl: | |
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSMwv2FT4pkFYxy6H1BuRK0W-DiNTmm0jwXTyJpjNzbXdUvDttB", | |
alignment: Alignment(0.2, -0.7), | |
fit: BoxFit.none, | |
), | |
), | |
), | |
), | |
), | |
Text("Flutter'n") | |
], | |
); | |
}, childCount: 1), | |
) | |
], | |
), | |
), | |
); | |
} | |
} | |
class RightSlantClipper extends CustomClipper<Path> { | |
@override | |
getClip(Size size) { | |
var path = Path(); | |
path.lineTo(0.0, size.height); | |
path.lineTo(size.width, size.height); | |
path.lineTo(size.width - 20, 0.0); | |
path.close(); | |
return path; | |
} | |
@override | |
bool shouldReclip(CustomClipper oldClipper) => true; | |
} | |
class PageTwo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return CupertinoPageScaffold( | |
child: CupertinoScrollbar( | |
child: CustomScrollView( | |
slivers: <Widget>[ | |
CupertinoSliverNavigationBar( | |
largeTitle: Text("page 2"), | |
), | |
SliverFillRemaining( | |
child: Hero( | |
transitionOnUserGestures: true, | |
tag: "hero1", | |
child: CachedNetworkImage( | |
imageUrl: | |
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSMwv2FT4pkFYxy6H1BuRK0W-DiNTmm0jwXTyJpjNzbXdUvDttB"), | |
), | |
) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment