大家好,我正在尝试删除或隐藏 List 中的最后一个字母
有什么可能的方法吗?
Text(list[i].name,
style: GoogleFonts.poppins(
fontWeight: FontWeight.w400,
color:
list[i].isBook == "0"
? selectedTimingSlot[i] ? WHITE : BLACK
: Colors.grey.withOpacity(0.5),
fontSize: 15,
),
),
Run Code Online (Sandbox Code Playgroud)
**Above code shows= "12:00 AM" I need to hide or remove "AM"**
使用substring方法:
main() {
print("12:00 AM".substring(0,5));
}
Run Code Online (Sandbox Code Playgroud)
或使用replaceAll方法:
main() {
print("12:00 AM".replaceAll("AM","").replaceAll("PM",""));
}
Run Code Online (Sandbox Code Playgroud)
使用正则表达式:
main() {
var regex = new RegExp(r'[a-zA-Z]');
print("02:00 AM".replaceAll(regex,""));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
82 次 |
| 最近记录: |