简体   繁体   English

如何在 Flutter 中对 API 数据中的数据进行排序

[英]How to sort data from API data in Flutter

Im trying to sort the data from api to Ascending & Descending inside Datatable Widget i follow the code and implementation however it doesn't work in my end Im using FutureBuilder to call the data any idea and help will be appreciated.我试图将数据从 api 排序到Datatable Widget中的 Ascending & Descending 我遵循代码和实现,但是它最终不起作用我使用FutureBuilder调用数据任何想法和帮助将不胜感激。

kindly see the link i post it to my personal github account as i have struggle to post the code here is the link : https://github.com/shanjoh/sorting-code/tree/6029c07e53921e96c8b6d6e218329e13246d2370请查看我将其发布到我的个人 github 帐户的链接,因为我很难将代码发布在这里是链接: https ://github.com/shanjoh/sorting-code/tree/6029c07e53921e96c8b6d6e218329e13246d2370

if you store value like this如果你像这样存储价值

    `List<YourModel> sortdata =  snapshot.data!.sort((a, b) => -a.ccy.compareTo(b.ccy));`

then you assign sortData in your card然后你在你的卡中分配 sortData

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM