展开的耀斑动画,现在运行应用程序时动画和文本均不显示

问题描述 投票:1回答:1

我正在尝试在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,
                        ),
flutter dart flare
1个回答
0
投票

我认为没有必要用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,
      ),
    ],
  ),
)
© www.soinside.com 2019 - 2024. All rights reserved.