我正在尝试在flutter应用程序中运行flare动画,但由于某种原因,它没有显示。我没有掉毛/运行时错误,所以我一直无法找出问题所在。我是错误地实现了此动画还是在“容器”中使用“扩展”放置了问题?
@override
Widget build(BuildContext context) {
double deviceWidth = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: Text('Let\'s Start Eating!'),
),
drawer: DrawerPage(),
body: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Expanded(
flex: 1,
child:
FlareActor(
"assets/animations/finding-pizza.flr",
alignment: Alignment.center,
fit: BoxFit.contain,
animation: _animationName,
),
),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).size.height/35,
),
Text(
"Got a question?",
style: Theme.of(context).textTheme.title.copyWith(fontSize: 0.1 * deviceWidth),
textAlign: TextAlign.center,
softWrap: true,
),
我认为没有必要用Column
包裹Container
,然后再用Column
包裹。
尝试一下:
Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
Expanded(
child: FlareActor(
"assets/animations/finding-pizza.flr",
alignment: Alignment.center,
fit: BoxFit.contain,
animation: _animationName,
),
),
SizedBox(
height: MediaQuery.of(context).size.height / 35,
),
Text(
"Got a question?",
style: Theme.of(context)
.textTheme
.title
.copyWith(fontSize: 0.1 * deviceWidth),
textAlign: TextAlign.center,
softWrap: true,
),
],
),
)