in example/lib/pages/link/link_page.dart [112:163]
Widget _buildContentBody() {
return ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 固定长度的文字
Text(
item.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
// 输入框和扫码按钮
Row(
children: [
Expanded(
child: TextField(
controller: _controllers[index],
onChanged: (value) => updateLink(index, value),
decoration: InputDecoration(
hintText: '请输入链接',
suffixIcon: IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
_controllers[index].clear(); // 清空输入框
updateLink(index, '');
},
),
),
),
),
const SizedBox(width: 8),
ElevatedButton.icon(
onPressed: () => onQrCodePressed(index), // 传递当前 item 的索引
icon: const Icon(Icons.qr_code_rounded),
label: const Text('扫码'),
),
],
),
],
),
);
},
);
}