Flutter 颤振从复制相同项的api加载更多listview数据

Flutter 颤振从复制相同项的api加载更多listview数据,flutter,Flutter,//这是我从API加载数据的dart代码 class ManageInvoice extends StatefulWidget { @override _ManageInvoiceState createState() => _ManageInvoiceState(); } class _ManageInvoiceState extends State<ManageInvoice> { int _selectedIndex = 0; int currentPag

//这是我从API加载数据的dart代码

class ManageInvoice extends StatefulWidget {
  @override
  _ManageInvoiceState createState() => _ManageInvoiceState();
}
class _ManageInvoiceState extends State<ManageInvoice> {
  int _selectedIndex = 0;
  int currentPage = 1;
  bool isLoading = false;

  Widget appBarTitle = new Text("Manage Invoice");
  Icon actionIcon = new Icon(Icons.search);
  List<Datum> invoiceList = [];
  List<Datum> items = [];

  @override
  void initState() {
    super.initState();
    String page = currentPage.toString();
    ManageInvoiceApi.getInvoiceList(page).then((value) {
      if (value != null) {
        setState(() {
          invoiceList = value.data;
          items.addAll(invoiceList);
        });
      }
    });
  }
 Future _loadData() async {
    // perform fetching data delay
    // await new Future.delayed(new Duration(seconds: 2));
    // update data and loading status
    setState(() {
      currentPage++;

      String page = currentPage.toString();
      ManageInvoiceApi.getInvoiceList(page).then((value) {
        if (value != null) {
          invoiceList = value.data;
          items.addAll(invoiceList);
          isLoading = false;
        }
      });
    });
  }
 @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NotificationListener<ScrollNotification>(
        onNotification: (ScrollNotification scrollInfo) {
          if (scrollInfo.metrics.pixels == scrollInfo.metrics.maxScrollExtent) {
            setState(() {
              isLoading = true;
            });
            _loadData();
          }
        },
        child: SafeArea(
          child: Column(
            children: <Widget>[
              AppBar(
                automaticallyImplyLeading: true,
                title: Text(
                  'Manage Invoice',
                  style: TextStyle(
                      fontWeight: FontWeight.bold,
                      color: Colors.white,
                      fontSize: 20.0),
                ),               
              ),
              Padding(padding: EdgeInsets.only(top: 5.0, bottom: 5.0)),
              Expanded(
                child: ListView.builder(
                  itemCount: items.length,
                  itemBuilder: (context, index) {
                    return Container(
                      padding: EdgeInsets.only(
                          top: 5.0, left: 20.0, right: 20.0, bottom: 10.0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: <Widget>[
                                  Text(
                                    items[index].custName.toString(),
                                    style: TextStyle(
                                        fontSize: 13.0,
                                        color: Colors.black,
                                        fontWeight: FontWeight.bold),
                                  ),
                                  Padding(
                                      padding: EdgeInsets.only(
                                          top: 2.0, bottom: 2.0)),
                                  Text(
                                    'abc-' + items[index].abc,
                                    style: TextStyle(
                                        fontSize: 12.0, color: Colors.black),
                                  ),
                                ],
                              ),
                            ],
                          ),
                        ],
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
类ManageInvoice扩展StatefulWidget{
@凌驾
_ManageInvoiceState createState()=>\u ManageInvoiceState();
}
类_ManageInvoiceState扩展状态{
int _selectedIndex=0;
int currentPage=1;
bool isLoading=false;
Widget appBarTitle=新文本(“管理发票”);
图标操作图标=新图标(Icons.search);
列表发票列表=[];
列表项=[];
@凌驾
void initState(){
super.initState();
String page=currentPage.toString();
ManageInvoiceApi.getInvoiceList(第页)。然后((值){
if(值!=null){
设置状态(){
发票列表=value.data;
items.addAll(发票列表);
});
}
});
}
Future\u loadData()异步{
//执行抓取数据延迟
//等待新的未来。延迟(新的持续时间(秒:2));
//更新数据和加载状态
设置状态(){
currentPage++;
String page=currentPage.toString();
ManageInvoiceApi.getInvoiceList(第页)。然后((值){
if(值!=null){
发票列表=value.data;
items.addAll(发票列表);
isLoading=false;
}
});
});
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:NotificationListener(
onNotification:(滚动通知滚动信息){
if(scrollInfo.metrics.pixels==scrollInfo.metrics.maxScrollExtent){
设置状态(){
isLoading=true;
});
_loadData();
}
},
儿童:安全区(
子:列(
儿童:[
AppBar(
自动嵌入:正确,
标题:正文(
“管理发票”,
样式:TextStyle(
fontWeight:fontWeight.bold,
颜色:颜色,白色,
字体大小:20.0),
),               
),
填充(填充:仅限边集(顶部:5.0,底部:5.0)),
扩大(
子项:ListView.builder(
itemCount:items.length,
itemBuilder:(上下文,索引){
返回容器(
填充:仅限边缘设置(
顶部:5.0,左侧:20.0,右侧:20.0,底部:10.0),
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
划船(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
纵队(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
items[index].custName.toString(),
样式:TextStyle(
字体大小:13.0,
颜色:颜色,黑色,
fontWeight:fontWeight.bold),
),
填充物(
填充:仅限边缘设置(
顶部:2.0,底部:2.0),
正文(
“abc-”+项目[索引]。abc,
样式:TextStyle(
字体大小:12.0,颜色:颜色。黑色),
),
],
),
],
),
],
),
);
},
),
),
],
),
),
),
);
}
从api获取数据后,数据被添加到列表中,但问题是当我滚动listview时加载的数据是相同的。假设我正在获取前10个值,称为A、B、C、D、E、F、F、G、G、H、i、J,之后如果我滚动列表,其加载相同的A、B、C、D、E、F、G、H、i、J,而不是K、L、M、N、O、p、Q、R、s等

请帮我解决这个问题