gpt4 book ai didi

android-studio - 如何在Flutter中使用容器内的扩展 block ?

转载 作者:行者123 更新时间:2023-12-03 03:48:18 25 4
gpt4 key购买 nike

enter image description here enter image description here这是扩展图块的集合。在这里,我想在容器内扭曲扩展图块,以便为图块赋予边框,形状和阴影。也
我想要像这样的扩展结果。我该如何实现。请帮我
我尝试了以下模式。但是当我扩展时,我得到了渲染溢出错误

              Container(
height: 80,
width: MediaQuery.of(context).size.width - 10,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Theme.of(context).hintColor.withOpacity(0.2),
spreadRadius: 2,
blurRadius: 5)
],
),
child:
ExpansionTile(
backgroundColor: Colors.white,
trailing: Icon(Icons.arrow_forward_ios_rounded),
initiallyExpanded: false,
title: Text(
'Messages',
style: Theme.of(context)
.textTheme
.subtitle),

children: List.generate(
3, (indexProduct) {
return Text("terwyteuwte");
}),
)
),
请帮我..

最佳答案

您可以做以下事情
根据您的用途在ListView()中添加以下小部件

class ItemTile extends StatefulWidget {
// final OrderItem orderItem;

// OrderItemTile(this.title);

@override
_ItemTileState createState() => _ItemTileState();
}

class _ItemTileState extends State<ItemTile> {
bool _expanded = false;

@override
Widget build(BuildContext context) {
return AnimatedContainer(
duration: Duration(milliseconds: 300),
height: _expanded
? 350
: 100,
child: Card(
elevation: 10,
color: Theme.of(context).canvasColor,
margin: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Column(
children: <Widget>[
ListTile(
title: (Text(
'File',
style: TextStyle(
fontSize: 22, fontWeight: FontWeight.bold),
)),
trailing: IconButton(
icon: _expanded
? Icon(Icons.expand_less)
: Icon(Icons.expand_more),
onPressed: () {
setState(() {
_expanded = !_expanded;
});
}),
),
AnimatedContainer(
duration: Duration(milliseconds: 300),
height: _expanded
? 300
: 0,
width: MediaQuery.of(context).size.width,
child: ItemExpandedTile(),
)
],
),
),
);
}
}
展开后显示的小部件
class ItemExpandedTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Stack(
children: <Widget>[
Positioned(
top: 5,
child: Container(
height: 90,
width: MediaQuery.of(context).size.width - 75,
padding: EdgeInsets.all(10),
decoration: new BoxDecoration(
color: Theme.of(context).canvasColor,
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 15.0,
spreadRadius: 0.5,
offset: Offset(
1.0,
1.0,
),
)
],
),
child: Row(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(
'Title',
style: TextStyle(
fontSize: 12, fontWeight: FontWeight.bold),
),
],
),
],
),
),
),
],
),
);
}
}
结果:
List With Expansion

关于android-studio - 如何在Flutter中使用容器内的扩展 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64709744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com