Flutter Web:Stack 和 Flare 问题
Flutter Web: Stack and Flare Issue
我试图在 Flutter Web(开发频道 - v1.13.2)上创建一个简单的网页,但出现了这个奇怪的问题。当我试图在堆栈小部件中放置一个 Flare 动画时,它分别有 2 个额外的小部件、一个背景和一个居中的文本,Flare 似乎没有出现。但是当我移除背景容器时,耀斑可以正常工作并完美定位。这是代码;
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"),
),
)
],
),
);
}
}
我想你看到了 this bug。看看 RepaintBoundary
解决方法是否同时适用于您。
我试图在 Flutter Web(开发频道 - v1.13.2)上创建一个简单的网页,但出现了这个奇怪的问题。当我试图在堆栈小部件中放置一个 Flare 动画时,它分别有 2 个额外的小部件、一个背景和一个居中的文本,Flare 似乎没有出现。但是当我移除背景容器时,耀斑可以正常工作并完美定位。这是代码;
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"),
),
)
],
),
);
}
}
我想你看到了 this bug。看看 RepaintBoundary
解决方法是否同时适用于您。