Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gmalpha_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile
gmalpha_flutter
Commits
82e751f9
Commit
82e751f9
authored
Jul 16, 2019
by
jinzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成 上拉下拉刷新页面
parent
321694ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
66 deletions
+37
-66
message_home.dart
lib/pages/message/home/message_home.dart
+37
-66
No files found.
lib/pages/message/home/message_home.dart
View file @
82e751f9
...
@@ -17,33 +17,34 @@ class _MessageHomePageState extends State<MessageHomePage> {
...
@@ -17,33 +17,34 @@ class _MessageHomePageState extends State<MessageHomePage> {
List
<
ListItem
>
messageList
=
List
<
ListItem
>();
List
<
ListItem
>
messageList
=
List
<
ListItem
>();
List
<
ListItem
>
dataArr
=
List
<
ListItem
>();
List
<
ListItem
>
dataArr
=
List
<
ListItem
>();
int
pageIndex
=
1
;
int
pageIndex
=
1
;
List
<
String
>
data1
=
[];
RefreshController
_refreshController
=
RefreshController
_refreshController
=
RefreshController
(
initialRefresh:
true
);
RefreshController
(
initialRefresh:
true
);
void
_onRefresh
()
async
{
void
_onRefresh
()
async
{
// dataArr = await _fetchListData();
pageIndex
=
1
;
// if (mounted) setState(() {
List
<
ListItem
>
newdataArr
=
List
<
ListItem
>();
// dataArr = dataArr;
newdataArr
=
await
_fetchListData
();
// });
if
(
mounted
)
setState
(()
{
// _refreshController.refreshCompleted();
dataArr
=
newdataArr
;
});
_refreshController
.
refreshCompleted
();
}
}
void
_onLoading
()
async
{
void
_onLoading
()
async
{
// monitor network fetch
pageIndex
++;
// pageIndex ++;
List
<
ListItem
>
newData
=
List
<
ListItem
>();
// List<ListItem> newData = List<ListItem>();
newData
=
await
_fetchMesssageList
();
// newData = await _fetchMesssageList();
if
(
mounted
)
setState
(()
{
// this.dataArr.addAll(newData);
this
.
dataArr
.
addAll
(
newData
);
// if (mounted) setState(() {
});
// dataArr = dataArr;
_refreshController
.
loadComplete
();
// });
// _refreshController.loadComplete();
}
}
Future
<
List
<
ListItem
>>
_fetchMesssageList
()
async
{
Future
<
List
<
ListItem
>>
_fetchMesssageList
()
async
{
List
<
Message
>
messageList
=
List
<
Message
>();
List
<
Message
>
messageList
=
List
<
Message
>();
BaseResp
<
List
>
baseresp
=
await
DioUtil
().
request
<
List
>(
Method
.
get
,
"api/v1/reply/my"
,
queryParameters:
{
'page'
:
1
,
'count'
:
10
});
BaseResp
<
List
>
baseresp
=
await
DioUtil
().
request
<
List
>(
Method
.
get
,
"api/v1/reply/my"
,
queryParameters:
{
'page'
:
pageIndex
,
'count'
:
10
});
if
(
baseresp
.
code
!=
0
)
{
if
(
baseresp
.
code
!=
0
)
{
return
new
Future
.
error
(
baseresp
.
msg
);
return
new
Future
.
error
(
baseresp
.
msg
);
}
}
...
@@ -99,59 +100,31 @@ class _MessageHomePageState extends State<MessageHomePage> {
...
@@ -99,59 +100,31 @@ class _MessageHomePageState extends State<MessageHomePage> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
return
Scaffold
(
// appBar: new AppBar(
appBar:
new
AppBar
(
// title: new Text('消息'),
title:
new
Text
(
'消息'
),
// ),
),
// floatingActionButton: new FloatingActionButton(
body:
new
Container
(
// onPressed: () {
child:
SmartRefresher
(
// _fetchListData();
child:
_createListView
(),
// },
// child: new Icon(Icons.add_box),
// elevation: 3.0,
// highlightElevation: 2.0,
// backgroundColor: Colors.red, // 红色
// ),
body:
new
Container
(
child:
SmartRefresher
(
// enablePullDown: false,
enablePullUp:
true
,
// header: WaterDropHeader(),
controller:
_refreshController
,
controller:
_refreshController
,
// onRefresh: _onRefresh,
enablePullDown:
true
,
onLoading:
_onLoading
,
enablePullUp:
true
,
header:
WaterDropHeader
(),
// footer: ClassicFooter(),
onRefresh:
(){
child:
FutureBuilder
(
_onRefresh
();
future:
_fetchListData
(),
},
builder:
(
context
,
snapshot
)
{
onLoading:
()
{
switch
(
snapshot
.
connectionState
)
{
_onLoading
();
case
ConnectionState
.
none
:
}
return
new
Container
(
height:
0.0
,
width:
0.0
);
),
break
;
)
case
ConnectionState
.
waiting
:
return
new
Container
(
height:
0.0
,
width:
0.0
);
break
;
case
ConnectionState
.
active
:
return
new
Container
(
height:
0.0
,
width:
0.0
);
break
;
default
:
if
(
snapshot
.
hasData
)
{
return
_createListView
(
context
,
snapshot
);
}
else
{
return
new
Container
(
height:
0.0
,
width:
0.0
);
}
}
},
),
),
)
);
);
}
}
Widget
_createListView
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
Widget
_createListView
()
{
List
<
ListItem
>
dataArr
=
snapshot
.
data
;
List
<
ListItem
>
dataArr
=
this
.
dataArr
;
return
ListView
.
builder
(
return
ListView
.
builder
(
shrinkWrap:
true
,
shrinkWrap:
true
,
key:
new
PageStorageKey
(
'message-list'
),
key:
new
PageStorageKey
(
'message-list'
),
...
@@ -168,5 +141,4 @@ class _MessageHomePageState extends State<MessageHomePage> {
...
@@ -168,5 +141,4 @@ class _MessageHomePageState extends State<MessageHomePage> {
},
},
);
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment