Flutter Web: Stack and Flare Issue

随声附和 提交于 2021-01-27 19:40:53

问题


I was trying to create a simple web page on Flutter Web (dev channel - v1.13.2) and this weird issue occured. When I tried to place a Flare animation in stack widget which have 2 additional widget, a background and a centered text respectively, the Flare didn't seems to appear. But when I remove the background container, flare works and positioned perfectly. Here is the code;

    import 'package:flutter/material.dart';
    import "package:flare_flutter/flare_actor.dart";

    void main() => runApp(MyApp());

    class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.green,
      ),
      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 new Scaffold(
      body: new Stack(
        children: <Widget>[
          new Container(
            decoration: new BoxDecoration(
                image: new DecorationImage(
                    image: new AssetImage('images/bckg.jpeg'),
                    fit: BoxFit.cover)),
          ),
          new Center(
            child: new Text('TEST',
                style: new TextStyle(
                    color: Colors.white,
                    fontSize: 200.0,
                    fontWeight: FontWeight.bold,
                    letterSpacing: 5.0)),
          ),
          new Align(
            alignment: Alignment.bottomCenter,
            child: new ConstrainedBox(
              constraints: new BoxConstraints(
                maxHeight: 100,
                maxWidth: 100,
              ),
              child: new FlareActor("images/arrowdown.flr",
                  color: Colors.white,
                  alignment: Alignment.center,
                  fit: BoxFit.contain,
                  animation: "idle"),
            ),
          )
        ],
      ),
    );
  }
}

回答1:


I think you're seeing this bug. See if the RepaintBoundary workaround works for you in the meantime.



来源:https://stackoverflow.com/questions/59416872/flutter-web-stack-and-flare-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!