Flutter Web:堆叠和光斑问题 [英] Flutter Web: Stack and Flare Issue

查看:68
本文介绍了Flutter Web:堆叠和光斑问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Flutter Web上创建一个简单的网页(开发频道-v1.13.2),并且发生了这个奇怪的问题.当我尝试将Flare动画放置在具有2个附加小部件(分别是背景和居中文本)的堆栈小部件中时,Flare似乎没有出现.但是,当我移除背景容器时,耀斑可以正常工作并且定位完美.这是代码;

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"),
            ),
          )
        ],
      ),
    );
  }
}

推荐答案

我认为您正在看到此错误.同时查看 RepaintBoundary 解决方法是否对您有用.

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

这篇关于Flutter Web:堆叠和光斑问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆