允许溢出容器超过屏幕
Allow overflow container more than screen
我在 Stack
小部件中有 AnimatedContainer
。我想更改 MyAnimatedContainer
的比例并使其大于屏幕,如下图所示:
我该怎么做?
代码:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
AnimatedContainer(
height: _width,
width: _height,
duration: const Duration(milliseconds: 500),
child: Image.asset('assets/Asset 2.png'),
),
],
),
);
}
我尝试更改 width/height 但它不起作用。
使用 stackfit.expand
收紧了从其父级传递到 Stack
的约束,
所以我希望您使用 stackfit.loose
而不是更改 width
和 height
。
试一试它是否适合你。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.loose,
children: [
AnimatedContainer(
height: _width,
width: _height,
duration: const Duration(milliseconds: 500),
child: Image.asset('assets/Asset 2.png'),
),
],
),
);
}
我在 Stack
小部件中有 AnimatedContainer
。我想更改 MyAnimatedContainer
的比例并使其大于屏幕,如下图所示:
我该怎么做?
代码:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
AnimatedContainer(
height: _width,
width: _height,
duration: const Duration(milliseconds: 500),
child: Image.asset('assets/Asset 2.png'),
),
],
),
);
}
我尝试更改 width/height 但它不起作用。
使用 stackfit.expand
收紧了从其父级传递到 Stack
的约束,
所以我希望您使用 stackfit.loose
而不是更改 width
和 height
。
试一试它是否适合你。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.loose,
children: [
AnimatedContainer(
height: _width,
width: _height,
duration: const Duration(milliseconds: 500),
child: Image.asset('assets/Asset 2.png'),
),
],
),
);
}