颤动问题:如何删除列表数据的括号
flutter problem : how to remove brackets of list data
这是我的邮递员回复,在这个回复中我有一个“areaOfMentoring”键在指导键区域我有两个数据我想显示这两个数据。
但是当获取 areaOfMentoring 的数据时,它的显示是这样的
areaOfMentoring 的数据是糖尿病和心脏健康在 abhijeet vijayvargiya 之后显示
也有括号,那么如何在没有括号的情况下只显示 areaOfMentoring 的数据
这是我的卡片密码
Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: (index % 2) == 0
? Color(0xFFC691D3).withOpacity(0.2)
: Color(0xFFF6931E).withOpacity(0.2),
borderRadius: BorderRadius.only(
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0),
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0)),
),
height: 290,
width: 160,
child: Column(
children: [
Image.asset(
'assets/herogirl.png',
height: 154,
width: 142,
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Text(
'${healthHeroesListData[index]['name']}',
overflow: TextOverflow.ellipsis,
maxLines: 1,
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xff444444),
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Text(
'${healthHeroesListData[index]['areaOfMentoring']}',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
maxLines: 2,
style: GoogleFonts.poppins(
fontSize: 12,
color: (index % 2) == 0
? Color(0xffC691D3)
: Color(0xffF6931E),
),
),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: (index % 2) == 0
? MaterialStateProperty.all(Color(0xFFC691D3))
: MaterialStateProperty.all(Color(0xFFF6931E)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
// side: BorderSide(color: Colors.teal, width: 0.0),
),
),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ApplySession(healthHeroesListData:healthHeroesListData[index])));
},
child: Text('View Details'))
],
),
);
你有很多方法,最简单的是:
healthHeroesListData[index]['areaOfMentoring'].join(', ') // with comas
healthHeroesListData[index]['areaOfMentoring'].join(' ') // no comas
您正在让 dart 在数组上应用 toString
方法,从而将其显示为原始 JSON 字符串。
您只需要以某种方式迭代您的条目或加入它们:
'${healthHeroesListData[index]['areaOfMentoring'].join(', ')}'
这是我的邮递员回复,在这个回复中我有一个“areaOfMentoring”键在指导键区域我有两个数据我想显示这两个数据。
但是当获取 areaOfMentoring 的数据时,它的显示是这样的
areaOfMentoring 的数据是糖尿病和心脏健康在 abhijeet vijayvargiya 之后显示 也有括号,那么如何在没有括号的情况下只显示 areaOfMentoring 的数据
这是我的卡片密码
Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: (index % 2) == 0
? Color(0xFFC691D3).withOpacity(0.2)
: Color(0xFFF6931E).withOpacity(0.2),
borderRadius: BorderRadius.only(
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0),
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0)),
),
height: 290,
width: 160,
child: Column(
children: [
Image.asset(
'assets/herogirl.png',
height: 154,
width: 142,
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Text(
'${healthHeroesListData[index]['name']}',
overflow: TextOverflow.ellipsis,
maxLines: 1,
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xff444444),
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Text(
'${healthHeroesListData[index]['areaOfMentoring']}',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
maxLines: 2,
style: GoogleFonts.poppins(
fontSize: 12,
color: (index % 2) == 0
? Color(0xffC691D3)
: Color(0xffF6931E),
),
),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: (index % 2) == 0
? MaterialStateProperty.all(Color(0xFFC691D3))
: MaterialStateProperty.all(Color(0xFFF6931E)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
// side: BorderSide(color: Colors.teal, width: 0.0),
),
),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ApplySession(healthHeroesListData:healthHeroesListData[index])));
},
child: Text('View Details'))
],
),
);
你有很多方法,最简单的是:
healthHeroesListData[index]['areaOfMentoring'].join(', ') // with comas
healthHeroesListData[index]['areaOfMentoring'].join(' ') // no comas
您正在让 dart 在数组上应用 toString
方法,从而将其显示为原始 JSON 字符串。
您只需要以某种方式迭代您的条目或加入它们:
'${healthHeroesListData[index]['areaOfMentoring'].join(', ')}'