我想以類似英雄的方式為串列視圖的單個容器設定影片,但可以更好地控制顏色、字體大小等的變化。因此我使用了 AnimatedContainer 但我現在遇到的問題是藍色容器沒有填滿所以整個螢屏,只有螢屏的右側,其余部分被推出。如何實作藍色 Container 正在使用整個螢屏,從而將紅色 Container 推開?
import 'package:flutter/material.dart';
class AnimationTestView extends StatefulWidget {
const AnimationTestView({Key? key}) : super(key: key);
@override
State<AnimationTestView> createState() => _AnimationTestViewState();
}
class _AnimationTestViewState extends State<AnimationTestView> {
bool isBig = false;
@override
Widget build(BuildContext context) {
var padding = MediaQuery.of(context).padding;
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
double newHeight = height - padding.top - padding.bottom;
return Scaffold(
body: ListView(
scrollDirection: Axis.horizontal,
children: [
Center(
child: Container(
height: newHeight / 2,
width: width / 2,
color: Colors.red,
),
),
Center(
child: GestureDetector(
onTap: () {
setState(() {
isBig = !isBig;
});
},
child: AnimatedContainer(
duration: const Duration(seconds: 1),
height: isBig ? newHeight : newHeight / 2,
width: isBig ? width : width / 2,
color: Colors.blue,
),
),
)
],
));
}
}

uj5u.com熱心網友回復:
您可以使用 pub.dev 中的影片包并將影片容器包裝在 openContainer 中。要了解如何使用此軟體包,您將在 YouTube 上獲得許多視頻。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/518656.html
標籤:扑镖动画
