Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit76d82ee

Browse files
committed
query page
1 parent95f30e1 commit76d82ee

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

‎study-ai/myappflutter/lib/presentation/pages/app_version_page.dart‎

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class _AppVersionPageState extends State<AppVersionPage> {
1919
bool _isLoading=false;
2020
bool _hasMore=true;
2121
int _currentPage=0;
22-
finalint _pageSize=5;
22+
int _totalPages=1;
23+
finalint _pageSize=3;
2324

2425
@override
2526
voidinitState() {
@@ -44,15 +45,21 @@ class _AppVersionPageState extends State<AppVersionPage> {
4445
);
4546

4647
if (response['code']==200&& response['data']!=null) {
47-
finalList<dynamic> versionData= response['data']['versions']?? [];
48+
final data= response['data'];
49+
finalList<dynamic> versionData= data['versions']?? [];
4850
finalList<Version> newVersions= versionData
4951
.map<Version>((item)=>Version.fromJson(item))
5052
.toList();
5153

54+
// 从响应中获取分页信息
55+
_totalPages= data['totalPages']??1;
56+
finalint currentPage= (data['currentPage']??0)+1;// 后端从0开始,前端从1开始
57+
finalint totalElements= data['totalElements']??0;
58+
5259
setState(() {
5360
_versions= newVersions;
54-
_currentPage=page;
55-
_hasMore=newVersions.length== _pageSize;
61+
_currentPage=currentPage;
62+
_hasMore=currentPage< _totalPages;
5663
});
5764
}else {
5865
Get.snackbar(
@@ -181,25 +188,34 @@ class _AppVersionPageState extends State<AppVersionPage> {
181188
icon:constIcon(Icons.arrow_back),
182189
label:Text('previous_page'.tr),
183190
style:ElevatedButton.styleFrom(
184-
backgroundColor: _currentPage>1?Colors.blue:Colors.grey,
191+
backgroundColor: _currentPage>1
192+
?Colors.blue
193+
:Colors.grey,
185194
),
186195
),
187196

188197
// 页码显示
189-
Container(
190-
padding:constEdgeInsets.symmetric(horizontal:16, vertical:8),
191-
decoration:BoxDecoration(
192-
color:Colors.blue.withOpacity(0.1),
193-
borderRadius:BorderRadius.circular(8),
194-
),
195-
child:Text(
196-
'${'page'.tr} $_currentPage',
197-
style:constTextStyle(
198-
fontSize:16,
199-
fontWeight:FontWeight.bold,
200-
color:Colors.blue,
198+
Column(
199+
children: [
200+
Container(
201+
padding:constEdgeInsets.symmetric(
202+
horizontal:16,
203+
vertical:8,
204+
),
205+
decoration:BoxDecoration(
206+
color:Colors.blue.withOpacity(0.1),
207+
borderRadius:BorderRadius.circular(8),
208+
),
209+
child:Text(
210+
'$_currentPage / $_totalPages',
211+
style:constTextStyle(
212+
fontSize:16,
213+
fontWeight:FontWeight.bold,
214+
color:Colors.blue,
215+
),
216+
),
201217
),
202-
),
218+
],
203219
),
204220

205221
// 下一页按钮

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp