因此,我試圖在頂部有一個影像,下面是一個串列。最初,該串列是收縮的。當串列展開時,我希望它能與圖片重疊。
問題是--如果我將圖片定位到頂部,串列也會移動到頂部(在初始位置),這不是我想要的。此外,如果我使用一個列將影像定位在頂部(以及它下面的串列),那么串列不會一直擴展到頂部;它停留在(并擴展)影像下面。
@override
Widget build(BuildContext context) {
double maxHeight = MediaQuery.of(context).size.height;
return Scaffold(
//resizeToAvoidBottomInset: false,
//backgroundColor: Color(0xFFd8e3e3),
身體。Align(
child: SingleChildScrollView(
//避免底部溢位錯誤。
child: Padding(
padding: const EdgeInsets.fromLTRB(5, 20, 5, 0) 。
孩子。列(
mainAxisAlignment: MainAxisAlignment.center,
children: [
堆疊(
//fit: StackFit.loose,
//alignment: Alignment.center,
兒童。[
//Positioned()
// top: 0,
// left: 0,
// right: 0, // right: 0,
對齊(
對齊。Alignment(0, -1) 。
孩子。Hero(
標簽。"imageHero"。
孩子。ClipRRect(
borderRadius: borderRadius.only(
bottomLeft: Radius.round(30)。
右邊底部。Radius.circular(30)。
),
孩子。Image.asset(
'assets/images/punjabi_egg_curry1.jpeg'/span>。
//height: screenHeight * 0.3,。
//width: double.infinity,。
對齊。Alignment.topCenter,
),
),
),
),
//),
中心(
孩子。new ClipRect(
child: new BackdropFilter(
過濾器。
new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0)。)
孩子。new Card(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: borderRadius.round(20.0),
),
孩子。new Center(
//child: GestureDetector()
//onTap: _updateSize,/span>
孩子。padding(
padding: const EdgeInsets.only(bottom: 10) 。
兒童。列(
兒童。[
AnimatedContainer(
約束。BoxConstraints(
maxHeight: maxHeight * 0.85)。)
高度。_height,
持續時間。Duration(msiseconds: 300)。
裝飾。new BoxDecoration(
color: Colors.transparent,
borderRadius: borderRadius.round(20)。
//border: border.all(color: Colors.black),
),
孩子。Steps()。
),
//),
提升按鈕(ElevatedButton)
onPressed: _updateSize,
孩子。Text(buttonText),
樣式。ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(
垂直。10,
水平的。20,
),
primary: kSilver,
形狀。RoundedRectangleBorder(
borderRadius:
borderRadius.circular(20)。
),
onPrimary: Colors.black,
textStyle: TextStyle(
color: Colors.black,
字體大小。22,
),
),
),
],
),
),
),
),
),
),
),
// ),.
],
),
],
),
),
),
),
//),.
);
}
}
uj5u.com熱心網友回復:
用Positioned(top:5, child: // your widget )包裝該部件,
uj5u.com熱心網友回復:
試試下面的代碼吧,希望它能幫助你。
試試下面的代碼,希望它能幫助你根據你的需要改變你的影像
。 Container(
高度。500,
孩子。堆疊(
兒童。[
容器(
width: 150,
高度。150。
邊緣。EdgeInsets.symmetric(horizontal: 10)。
裝飾。BoxDecoration(
borderRadius: borderRadius.circular(10)。
影像。DecorationImage(
適合。BoxFit.cover,
影像。資產影像(
'assets/images/cycle.png'。
),
),
),
),
定位(
頂部。120,
左邊。0,
右邊。0,
孩子。容器(
高度。100,
孩子。ListView.builder(
itemCount: 20,
itemBuilder。(BuildContext context, int index) {
return ListTile(
標題。Text("List - $index")。)
);
},
),
),
),
],
),
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/309075.html
標籤:



