网络请求使用FutureBuilder来处理

import 'dart:convert';

  Widget build(BuildContext context) {
    return FutureBuilder(
      future: httpReq.get(sevicePath['homeArticle']+'${widget.id}'),
      builder: (context,snapshot){
        if (snapshot.hasData){
              var data = jsonDecode(snapshot.data.toString());
              datas = (data['data'] as List).cast();
              return SingleChildScrollView(
                child: _cellList(),
              );
        }else{
          return Center(
            child: Text('加载中...'),
          );
        }
      },
    );
  }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2023-01-11
  • 2022-12-23
  • 2022-12-23
  • 2021-04-25
  • 2021-11-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2021-09-06
  • 2021-08-02
  • 2022-12-23
相关资源
相似解决方案