
誰能解釋一下如何在 Flutter 中獲得這種影像著色效果。
uj5u.com熱心網友回復:
我假設你想得到淡出的背景。最好的方法是使用堆疊,將背景影像放在底部,從背景顏色到其上方的透明漸變,然后是其上方的 UI 元素。這是一個作業示例構建:
@override
Widget build(BuildContext context) {
return Material(
child: Stack(
fit: StackFit.expand,
children: [
Image.asset('assets/background.jpg', fit: BoxFit.cover,),
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter, end: Alignment.bottomCenter,
colors: [Colors.transparent, Colors.white],
stops: [0, .4]
)
),
),
Padding(padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: const [
Icon(Icons.arrow_back),
Expanded(child: Center(child: Text('Steve Johnson',
style: TextStyle(fontSize: 18)
))),
Icon(Icons.remove_circle_outline_sharp)
],
),
const SizedBox(height: 32,),
Container(
height: 96, width: 96,
decoration: BoxDecoration(
border: Border.all(color: Colors.deepOrange, width: 4),
color: Colors.white,
),
child: Image.asset('assets/profile.jpg',
alignment: Alignment.topCenter,
fit: BoxFit.fitWidth,),
),
],
)
)
]
)
);
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/399782.html
上一篇:操作無法完成。應用程式資訊提供程式(FBSApplicationLibrary)為“io.dopple.Dopple”回傳nil
下一篇:包裝陣列方法更干凈更干代碼
