【发布时间】:2021-07-26 07:54:02
【问题描述】:
我想按降序排列 View .builder 你能帮我吗?
List View .builder(
item Count: ..,
item Builder: (Build Context context , int i){..}
)
【问题讨论】:
我想按降序排列 View .builder 你能帮我吗?
List View .builder(
item Count: ..,
item Builder: (Build Context context , int i){..}
)
【问题讨论】:
.sort 方法
示例 1
var numbers = ['two', 'three', 'four'];
// Sort from shortest to longest.
numbers.sort((a, b) =>
a.length.compareTo(b.length));
print(numbers); // [two, four, three]
示例 2
List<int> nums = [13, 2, -11];
nums.sort();
print(nums); // [-11, 2, 13]
【讨论】:
试试这个,这里 entries 是我的列表名称
final List<String> entries = <String>['A','B','C'];
int length = entries.length;
return ListView.builder(
padding: const EdgeInsets.all(8),
itemCount: entries.length,
itemBuilder: (BuildContext context, int index) {
return Container(
height: 50,
child: Center(child: Text('Entry ${entries[length - 1 - index]}')),
);
});
【讨论】: