我有一個主螢屏,我想在影像和文本中應用淡入影片我在中心有一個影像,然后是兩行文本,我只想讓它們淡入一次我已經經歷了一些不同的例子,但是它們都包含淡入和淡出我只想向用戶和暫停顯示那些影像和文本。
uj5u.com熱心網友回復:
試試這個,它會從 initState 淡入,我延遲 1 秒你可以修改它。
bool _visible = false;
@override
void initState() {
Future.delayed(const Duration(seconds: 1), () {
setState(() {
_visible = !_visible;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: AnimatedOpacity(
// If the widget is visible, animate to 0.0 (invisible).
// If the widget is hidden, animate to 1.0 (fully visible).
opacity: _visible ? 1.0 : 0.0,
duration: const Duration(milliseconds: 500),
// The green box must be a child of the AnimatedOpacity widget.
child:Column(
children:[
Image.network("https://cdn0.iconfinder.com/data/icons/business-startup-10/50/5-256.png")
,
const Text("Your text")
])
),
),
);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/420867.html
標籤:
