if (item.createTime.substring(5,11) == "05-29") Text("05-29的数据"),【(5,11) == "05-29")是动态的数据】
时间: 2024-02-23 12:00:13 浏览: 18
如果`(5, 11)`是动态的数据,你可以把它定义成一个变量,然后在判断语句中使用这个变量。具体代码如下:
```
String date = "05-29"; // 定义一个变量,存储需要判断的日期
Widget Maxcenter(RecordResultRecords item){
return Container(
color: Color.fromRGBO(248,249,253,1),
child: Column(
children: [
MyDimens.height(height: 8),
Text(item.createTime.substring(5,11) ?? "10/20", style: MyStyle.text_style_14_119, ),
Container(
width: MyDimens.getWidth(343),
height: MyDimens.getHeight(109),
margin: EdgeInsets.only( top: MyDimens.getHeight(10), right: MyDimens.getWidth(16), left: MyDimens.getWidth(16)),
padding: EdgeInsets.only( top: MyDimens.getHeight(20), right: MyDimens.getWidth(16), left: MyDimens.getWidth(20) ),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('举报用户', style: MyStyle.text_style_16_0, ),
Text('用户名称', style: MyStyle.text_style_16_254,),
],
),
MyDimens.height(height: 14),
Text(item.tmrDesc??'暂无数据', maxLines: 3, overflow: TextOverflow.ellipsis, style: MyStyle.text_style_12_102,textAlign: TextAlign.left, ),
if (item.createTime.substring(5,11) == date) Text("$date的数据"), // 使用变量进行判断
],
),
onTap: (){ RouteUtil.startActivity(context, Reportdetal()); },
)
],
),
);
}
```
这样,你只需要在需要判断的地方修改`date`变量的值,就可以实现动态判断。