Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
许晓慧
flutter_Intermediary
Commits
44a1d5de
Commit
44a1d5de
authored
7 months ago
by
xuxiaohuis
Browse files
Options
Download
Patches
Plain Diff
add sendRequest loading
parent
4250951d
master
feature/login
zyn
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/common/base/base_controller.dart
+20
-2
lib/common/base/base_controller.dart
with
20 additions
and
2 deletions
+20
-2
lib/common/base/base_controller.dart
+
20
−
2
View file @
44a1d5de
...
...
@@ -52,17 +52,23 @@ abstract class BaseController<M> extends SuperController{
VoidCallback
?
failCallback
,
})
{
if
(
bindViewState
&&
showLoadingDialog
)
{
if
(
bindViewState
)
{
LogD
(
"showLoadingDialog"
);
viewState
.
value
=
ViewStateLoading
();
}
if
(
showLoadingDialog
)
{
Get
.
showLoading
();
}
sendRequestBlock
.
then
((
result
)
{
if
(
result
.
isSuccess
())
{
bool
isEmpty
=
(
judgeEmptyCallback
!=
null
)
?
judgeEmptyCallback
(
result
)
:
result
.
isEmpty
();
if
(
showLoadingDialog
)
{
Get
.
hideLoading
();
}
if
(
!
isEmpty
||
(
emptyAsSuccess
&&
isEmpty
))
{
if
(
bindViewState
)
{
viewState
.
value
=
ViewStateSuccess
(
result
.
data
);
...
...
@@ -74,6 +80,10 @@ abstract class BaseController<M> extends SuperController{
if
(
bindViewState
)
{
viewState
.
value
=
ViewStateEmpty
();
}
if
(
showLoadingDialog
)
{
Get
.
hideLoading
();
showToast
(
"
${result.msg}
(
${result.code}
)"
);
}
if
(
emptyCallback
!=
null
)
{
emptyCallback
();
}
...
...
@@ -82,6 +92,10 @@ abstract class BaseController<M> extends SuperController{
if
(
bindViewState
)
{
viewState
.
value
=
ViewStateFail
(
result
.
code
,
result
.
msg
);
}
if
(
showLoadingDialog
)
{
Get
.
hideLoading
();
showToast
(
"
${result.msg}
(
${result.code}
)"
);
}
if
(
failCallback
!=
null
)
{
failCallback
();
}
...
...
@@ -92,6 +106,10 @@ abstract class BaseController<M> extends SuperController{
viewState
.
value
=
ViewStateError
(
requestException
.
code
,
requestException
.
message
);
}
if
(
showLoadingDialog
)
{
Get
.
hideLoading
();
showToast
(
"
${requestException.message}
(
${requestException.code}
)"
);
}
if
(
failCallback
!=
null
)
{
failCallback
();
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets