在使用DIO获取服务器的数据后,页面显示正常,但是后台持续请求服务器的数据,正常应该只请求一次,但是现在实际中是持续请求服务器,问:为什么会持续加载 日志如下:
Initializing
Syncing files to device
Reloaded 4 of 554 libraries in 499ms.
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
I/flutter ( 4306): {code: SUCCESS, params: null, message: null, data: [{problemID: 017f67fdf2ec465f8e1468582dc5601c, userID: null, proConent: 哈哈哈, problemDes: 暂无答案}, {problemID: 06ba5cacdec44a33aa1275f043f91beb, userID: null, proConent: 88, problemDes: 暂无答案}, {problemID: 12b35b6678c94d7da0a7c5b55e025d37, userID: null, proConent: 11对战平台, problemDes: 暂无答案}, {problemID: 25e85364ce5f41f78b5c19e49a08675b, userID: null, proConent: 为什么SQL报错, problemDes: 暂无答案}, {problemID: 26759f45a00440bcabb839cf14793243, userID: null, proConent: 1, problemDes: null}, {problemID: 766d543199344557829df76ad4dc5962, userID: null, proConent: 恩恩恩, problemDes: 暂无答案}, {problemID: 90d31efcdd7a48c889e911b5badce545, userID: null, proConent: 2, problemDes: null}, {problemID: ca69b0613cad480b9d0b33394c0f5c65, userID: null, proConent: 测试, problemDes: 暂无答案}]}
I/flutter ( 4306): [Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData', Instance of 'ProListData']
I/flutter ( 4306): 请求
import 'package:dio/dio.dart';
import 'package:essay/component/Mystaticval.dart';
import 'package:essay/dto/ProListEntity.dart';
import 'package:essay/pages/my_page/DetailedQuestions.dart';
import 'package:flutter/material.dart';class AllProblem extends StatefulWidget {AllProblem({Key key}) : super(key: key);_AllProblem createState() => _AllProblem();
}class _AllProblem extends State<AllProblem> {List<ProListData> result = List<ProListData>();@overrideWidget build(BuildContext content) {queryProblemByNet('001');return Scaffold(appBar: AppBar(title: Text("问题编辑"),),body: ListView.builder(itemCount: result.length,itemBuilder: (content, index) {return ListTile(title: new Text('${result[index].proConent}'),subtitle: new Text('${result[index].problemDes}'),trailing: Icon(Icons.arrow_right),onTap: () {Navigator.of(context).push(MaterialPageRoute(builder: (context) => DetailedQuestions()));},);}),);}void queryProblemByNet(String userID) async {Map<String, String> parameters = {"userID": "$userID"};var response = await Dio().post("$essayUrl/study/query/problem", data: parameters) as Response;var res = response.data;print("请求");String());ProListEntity problemDTO = ProListEntity.fromJson(res);setState(() {sult = problemDTO.data;});String());}
}
数据请求放在初始化时完成
@overridevoid initState() {super.initState();queryProblemByNet("001");}
把原本放在buid中的请求
queryProblemByNet("001");
放到初始化即可解决这个问题
本文发布于:2024-01-28 10:01:18,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17064072826626.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |