【发布时间】:2021-08-06 18:57:29
【问题描述】:
我有我的小部件,我需要像拖放一样使用它。就像我可以将其位置替换为一到二或二到四并重新排序索引。
我的代码
var BlocksList = [
{'Name': 'Get Out', 'Link': 'https://google.com'},
{'Name': 'Get IN', 'Link': 'https://google.com'}
];
ListView.builder(
shrinkWrap: true,
itemCount: BlocksList.length,
itemBuilder: (context, i) {
return Padding(
padding: const EdgeInsets.only(
left: 13, right: 13, bottom: 13),
child: Container(
child: Row(
children: [
Container(
child: SvgPicture.asset(
'images/menu.svg')),
SizedBox(
width: 14,
),
Expanded(
child: Container(
height: Height * 0.07,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5),
border: Border.all(
color: Color(0xffE6E6E6))),
child: Padding(
padding: const EdgeInsets.only(
left: 13, right: 13),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
children: [
Container(
child: SvgPicture.asset(
'images/clip.svg')),
SizedBox(
width: 7,
),
Column(
mainAxisAlignment:
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
BlocksList[i]['Name'].toString(),
style: TextStyle(
fontSize: 16,
fontFamily:
'SegoeUI-SemiBold',
color:
textGreyColor,
),
),
SizedBox(
height: 4,
),
Text(
BlocksList[i]['Link'].toString(),
style: TextStyle(
fontSize: 12,
fontFamily:
'SemiBold',
color:
textGreyColor),
)
],
),
],
),
FlutterSwitch(
width: 52,
height: 32.5,
valueFontSize: 12.0,
toggleSize: 20.0,
toggleColor: _switchValue
? Colors.white
: Color(0xffE6E6E6),
switchBorder: Border.all(
color: Color(0xffE6E6E6),
width: _switchValue
? 0
: 1.0,
),
activeColor: kPrimaryColor,
inactiveColor: Colors.white,
value: _switchValue,
onToggle: (val) {
setState(() {
_switchValue = val;
});
},
)
]),
),
),
),
],
),
),
);
})
它看起来像这样
我需要做的是添加 drop 和 drop,以便我可以将第二个容器移动到第一个容器,依此类推。找不到任何只是拖动自定义容器的小部件
【问题讨论】: