【发布时间】:2021-10-03 00:18:01
【问题描述】:
我有超过 10 个按钮需要在我的颤振中显示。这是我的 2 个重复按钮的示例代码:
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
clipBehavior: Clip.antiAlias,
shape: const StadiumBorder(),
child: Ink(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.black,
Colors.grey,
Colors.white,
],
),
),
width: double.infinity,
height: 60,
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => PrivacyRoute()),
);
},
child: ListTile(
leading: Icon(
Icons.menu_book,
color: Colors.white,
),
title: Text('Bahasa Melayu',
style: TextStyle(
color: Colors.white,
fontSize: 20,
)),
),
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
clipBehavior: Clip.antiAlias,
shape: const StadiumBorder(),
child: Ink(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.black,
Colors.grey,
Colors.white,
],
),
),
width: double.infinity,
height: 60,
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => PrivacyRoute()),
);
},
child: ListTile(
leading: Icon(
Icons.menu_book,
color: Colors.white,
),
title: Text('English',
style: TextStyle(
color: Colors.white,
fontSize: 20,
)),
),
),
),
),
),
不重复的只有linear-gradient、onTap、icon和文字的颜色。知道怎么做吗?我尝试使用 void 功能,但无法实现可用功能。希望能得到你们的一些见解。
【问题讨论】: