Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ahmed Fwela
2021-07-22 17:44:31 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
445d74aff2acd4e89faf75e5a1b5ca4fb36c70f1
445d74af
1 parent
4ae9f717
Added splash screen example
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
0 deletions
example_nav2/lib/app/modules/splash/controllers/splash_service.dart
example_nav2/lib/app/modules/splash/views/splash_view.dart
example_nav2/lib/main.dart
example_nav2/lib/app/modules/splash/controllers/splash_service.dart
0 → 100644
View file @
445d74a
import
'dart:async'
;
import
'package:get/get.dart'
;
import
'package:async/async.dart'
;
class
SplashService
extends
GetxService
{
final
welcomeStr
=
[
'GetX'
,
'Rules!'
];
final
activeStr
=
0
.
obs
;
final
memo
=
AsyncMemoizer
<
void
>();
Future
<
void
>
init
()
{
return
memo
.
runOnce
(
_initFunction
);
}
void
_changeActiveString
()
{
activeStr
.
value
=
(
activeStr
.
value
+
1
)
%
welcomeStr
.
length
;
}
Future
<
void
>
_initFunction
()
async
{
final
t
=
Timer
.
periodic
(
Duration
(
milliseconds:
500
),
(
t
)
=>
_changeActiveString
(),
);
//simulate some long running operation
await
Future
.
delayed
(
Duration
(
seconds:
5
));
//cancel the timer once we are done
t
.
cancel
();
}
}
...
...
example_nav2/lib/app/modules/splash/views/splash_view.dart
0 → 100644
View file @
445d74a
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'../controllers/splash_service.dart'
;
class
SplashView
extends
GetView
<
SplashService
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Center
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
Obx
(
()
=>
Text
(
controller
.
welcomeStr
[
controller
.
activeStr
.
value
],
style:
TextStyle
(
fontSize:
20
),
),
),
CircularProgressIndicator
(),
],
),
),
);
}
}
...
...
example_nav2/lib/main.dart
View file @
445d74a
import
'package:example_nav2/app/modules/splash/controllers/splash_service.dart'
;
import
'package:example_nav2/app/modules/splash/views/splash_view.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
...
...
@@ -10,10 +12,23 @@ void main() {
title:
"Application"
,
initialBinding:
BindingsBuilder
(
()
{
Get
.
put
(
SplashService
());
Get
.
put
(
AuthService
());
},
),
getPages:
AppPages
.
routes
,
builder:
(
context
,
child
)
{
return
FutureBuilder
<
void
>(
key:
ValueKey
(
'initFuture'
),
future:
Get
.
find
<
SplashService
>().
init
(),
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
connectionState
==
ConnectionState
.
done
)
{
return
child
??
SizedBox
.
shrink
();
}
return
SplashView
();
},
);
},
// routeInformationParser: GetInformationParser(
// // initialRoute: Routes.HOME,
// ),
...
...
Please
register
or
login
to post a comment