Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Q
queue_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
Ernanda
queue_flutter
Commits
cd608f41
Commit
cd608f41
authored
Apr 21, 2022
by
valdi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get device session to login
parent
3085cab4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
splash.dart
lib/splash.dart
+25
-5
No files found.
lib/splash.dart
View file @
cd608f41
// ignore_for_file: unused_import
// ignore_for_file: unused_import
, avoid_print, unused_catch_clause
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'dart:io'
;
...
@@ -13,7 +13,6 @@ import 'package:manager_queue/api.dart';
...
@@ -13,7 +13,6 @@ import 'package:manager_queue/api.dart';
import
'package:manager_queue/bloc/queue_bloc.dart'
;
import
'package:manager_queue/bloc/queue_bloc.dart'
;
import
'package:manager_queue/helper/config.dart'
;
import
'package:manager_queue/helper/config.dart'
;
import
'package:manager_queue/main.dart'
;
import
'package:manager_queue/main.dart'
;
import
'package:manager_queue/helper/config.dart'
;
import
'package:manager_queue/main_page.dart'
;
import
'package:manager_queue/main_page.dart'
;
import
'package:uuid/uuid.dart'
;
import
'package:uuid/uuid.dart'
;
import
'package:flutter/services.dart'
as
bundel_root
;
import
'package:flutter/services.dart'
as
bundel_root
;
...
@@ -27,6 +26,22 @@ class Splash extends StatefulWidget {
...
@@ -27,6 +26,22 @@ class Splash extends StatefulWidget {
}
}
class
_SplashState
extends
State
<
Splash
>
{
class
_SplashState
extends
State
<
Splash
>
{
Future
<
String
>
getDeviceSession
()
async
{
String
apiUrl
=
baseUrlApi
+
apiCheckDevice
;
try
{
Map
data
=
{};
var
dataApi
=
jsonEncode
(
data
);
var
apiresults
=
await
http
.
post
(
Uri
.
parse
(
apiUrl
),
body:
dataApi
);
var
sessionKey
=
jsonDecode
(
apiresults
.
body
)[
'data'
][
'session_key'
];
await
prefs
.
setString
(
'session_key'
,
sessionKey
);
// print("ini session keeeeeyy dari splash $sessionKey");
return
sessionKey
;
}
catch
(
e
)
{
Navigator
.
pushNamed
(
context
,
'/error'
);
return
''
;
}
}
Future
<
List
<
ConfigApl
>>
config
({
url
=
""
})
async
{
Future
<
List
<
ConfigApl
>>
config
({
url
=
""
})
async
{
// String? base_urlapi = prefs.getString('base_url');
// String? base_urlapi = prefs.getString('base_url');
List
<
ConfigApl
>
apiConfigs
=
[];
List
<
ConfigApl
>
apiConfigs
=
[];
...
@@ -116,12 +131,13 @@ class _SplashState extends State<Splash> {
...
@@ -116,12 +131,13 @@ class _SplashState extends State<Splash> {
void
initState
()
{
void
initState
()
{
loadBaseUrl
().
then
((
value
)
async
{
loadBaseUrl
().
then
((
value
)
async
{
await
prefs
.
setString
(
'base_url'
,
value
);
await
prefs
.
setString
(
'base_url'
,
value
);
print
(
value
);
//
print(value);
// await prefs.setString('uuid', uuidUnique.v4());
// await prefs.setString('uuid', uuidUnique.v4());
// await prefs.setString('mqtt_url', value[0].mqtt_url);
// await prefs.setString('mqtt_url', value[0].mqtt_url);
// await prefs.setInt('mqtt_port', value[0].mqtt_port);
// await prefs.setInt('mqtt_port', value[0].mqtt_port);
// await prefs.setString('mqtt_queue_topic', value[0].mqtt_queue_topic);
// await prefs.setString('mqtt_queue_topic', value[0].mqtt_queue_topic);
// await prefs.setString('mqtt_queue_message', value[0].mqtt_queue_message);
// await prefs.setString('mqtt_queue_message', value[0].mqtt_queue_message);
getDeviceSession
();
config
(
url:
value
).
then
((
value
)
async
{
config
(
url:
value
).
then
((
value
)
async
{
await
prefs
.
setString
(
'mqtt_url'
,
value
[
0
].
mqtt_url
);
await
prefs
.
setString
(
'mqtt_url'
,
value
[
0
].
mqtt_url
);
await
prefs
.
setInt
(
'mqtt_port'
,
value
[
0
].
mqtt_port
);
await
prefs
.
setInt
(
'mqtt_port'
,
value
[
0
].
mqtt_port
);
...
@@ -132,8 +148,12 @@ class _SplashState extends State<Splash> {
...
@@ -132,8 +148,12 @@ class _SplashState extends State<Splash> {
runMqTT
();
runMqTT
();
Future
.
delayed
(
const
Duration
(
seconds:
3
),
()
{
Future
.
delayed
(
const
Duration
(
seconds:
3
),
()
{
Navigator
.
push
(
final
String
?
userPin
=
prefs
.
getString
(
'pin_user'
);
context
,
MaterialPageRoute
(
builder:
(
_
)
=>
MainPage
()));
if
(
userPin
!=
null
)
{
Navigator
.
pushNamed
(
context
,
'/home'
);
}
else
{
Navigator
.
pushNamed
(
context
,
'/login'
);
}
});
});
});
});
...
...
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