我正在使用带有颤动的Hero动画来动画化从一条路线到另一条路线的过渡。英雄对象是图像。
我的问题:动画开始时,我还可以看到基本的抖动侧动画。因此,我的导航闪烁绿色。看起来不太好。
英雄-1号公路
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onLongPress: () => _onDeleteAlbum(snapshot.data[index]),
onTap: () =>
_onNavigateToAlbum(snapshot.data[index], index),
child: Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 10),
child: Card(
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Hero(
tag: "open_gallery" + index.toString(),
child: Image.network(
'https://placeimg.com/640/480/any',
fit: BoxFit.fill,
),
),
Positioned.fill(
child: Container(
color: Colors.black.withOpacity(.5),
alignment: Alignment.center,
child: Text(snapshot.data[index].value,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onPrimary,
fontSize: Theme.of(context)
.textTheme
.headline1
.fontSize))),
)
],
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
elevation: 5,
),
),
);
});
}
英雄-2号公路
FlexibleSpaceBar(
centerTitle: false,
background: Container(
color: Colors.transparent,
child: Hero(
tag: "open_gallery" + index.toString(),
child: Image(
image:
NetworkImage('https://placeimg.com/640/480/any'),
fit: BoxFit.cover,
),
),
)),
我是否以错误的方式使用了Hero动画?对于导航,我在routes
中使用带有MaterialApp
参数的namedRoutes:
routes: <String, WidgetBuilder>{
AlbumDetail.routeName: (BuildContext context) => AlbumDetail()
},
感谢您的帮助!