我对 ReorderableListView 有一些问题。
我想从拖动的项目中删除背景(参见图片1 )。我尝试在 ReorderableListView 周围添加主题小部件以解决此问题。它可以工作,但现在我的卡片侧面边框较浅(参见图2)您也可以在DarPad中尝试这个问题
您知道如何解决它吗?
这是我的代码:
Expanded(
child: Theme(
data: ThemeData(canvasColor: Colors.transparent),
child: ReorderableListView(
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 16.0),
children: <Widget>[
for (final items in homeButtons)
Card(
key: ValueKey(items),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
child: Container(
clipBehavior: Clip.antiAlias,
alignment: Alignment.center,
height: 50.0,
width: double.infinity,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [
Color(0xFF3b474f),
Color(0xFF232b32),
],
stops: [0, 1],
begin: AlignmentDirectional(1, -1),
end: AlignmentDirectional(-1, 1),
),
borderRadius: BorderRadius.circular(10),
),
child: ListTile(
title: Text(
'${items.toString().replaceAll('_', ' ')}',
textAlign: TextAlign.center,
style: GoogleFonts.outfit(
textStyle: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w100,
),
),
),
leading: SvgPicture.asset(
'assets/icons/$items.svg',
color: Color(0xFFF0154B),
height: 24.0,
width: 24.0,
),
trailing: Icon(
Icons.navigate_next,
color: Colors.white,
),
),
),
),
],
onReorder: (oldIndex, newIndex) async {
setState(() {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final items = homeButtons.removeAt(oldIndex);
homeButtons.insert(newIndex, items);
box.remove(key);
box.write(key, homeButtons);
});
},
),
),
),
Run Code Online (Sandbox Code Playgroud)
尝试下面的代码并设置shadowColor
Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.transparent,
shadowColor: Colors.transparent,
),
child: ReorderableListView(),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1614 次 |
| 最近记录: |