如何在列表中的项目之间添加小部件?

How can I add a Widget between items in a list?

问题:

Hi everyone! I have this "problem" that I want to add a Widget between the elements but I can't... idk why, here's an example of my List type ChatMessage:

List<ChatMessage> messages = [
 ChatMessage(content: 'Hi!', type: 'sent', date: DateTime(2022, 5, 7)),
 ChatMessage(content: 'Hello!', type: 'received', date: DateTime(2022, 5, 8)),
 ChatMessage(content: 'How are you?', type: 'received', date: DateTime(2022, 5, 8)),
 ChatMessage(content: 'Im good', type: 'sent', date: DateTime(2022, 5, 9)),
];

预计:

The result that I want it's similar in the below block (Separated by DateTime dynamically, basically add this "Widget" between them automatically just with the DateTime condition)

List<ChatMessage> messages = [
 ChatMessage(content: 'Hi!', type: 'sent', date: DateTime(2022, 5, 7)), // Day 7
 // Some Widget...
 ChatMessage(content: 'Hello!', type: 'received', date: DateTime(2022, 5, 8)), // Day 8
 ChatMessage(content: 'How are you?', type: 'received', date: DateTime(2022, 5, 8)), // Day 8
 // Some Widget...
 ChatMessage(content: 'Im good', type: 'sent', date: DateTime(2022, 5, 9)), // Day 9
];

更改箭头括号中指定的列表类型 <>

来自这里:

List<ChatMessage> messages = [
 ChatMessage(content: 'Hi!', type: 'sent', date: DateTime(2022, 5, 7)),
 ChatMessage(content: 'Hello!', type: 'received', date: DateTime(2022, 5, 8)),
 ChatMessage(content: 'How are you?', type: 'received', date: DateTime(2022, 5, 8)),
 ChatMessage(content: 'Im good', type: 'sent', date: DateTime(2022, 5, 9)),
];

为此:

List<Widget> messages = [
 ChatMessage(content: 'Hi!', type: 'sent', date: DateTime(2022, 5, 7)), // Day 7
 // Some Widget...
 ChatMessage(content: 'Hello!', type: 'received', date: DateTime(2022, 5, 8)), // Day 8
 ChatMessage(content: 'How are you?', type: 'received', date: DateTime(2022, 5, 8)), // Day 8
 // Some Widget...
 ChatMessage(content: 'Im good', type: 'sent', date: DateTime(2022, 5, 9)), // Day 9
];