add variable global for adress api
This commit is contained in:
parent
e4540dd3e5
commit
7750126ee4
@ -8,6 +8,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'variable/globals.dart' as globals;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
@ -65,7 +67,7 @@ class _MyHomePageState extends State<MyHomePage> with ShowErrorDialog {
|
|||||||
String former = "";
|
String former = "";
|
||||||
|
|
||||||
if ((user.isNotEmpty) && (jwt.isNotEmpty)) {
|
if ((user.isNotEmpty) && (jwt.isNotEmpty)) {
|
||||||
var urlGet = Uri.parse("http://localhost:8083/api/users");
|
var urlGet = Uri.parse("http://${globals.api}/users");
|
||||||
|
|
||||||
var responseGet = await http
|
var responseGet = await http
|
||||||
.get(urlGet, headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'});
|
.get(urlGet, headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'});
|
||||||
|
@ -9,6 +9,8 @@ import 'MyHomePage.dart';
|
|||||||
|
|
||||||
import 'classes/alert.dart';
|
import 'classes/alert.dart';
|
||||||
|
|
||||||
|
import 'variable/globals.dart' as globals;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(MyApp());
|
runApp(MyApp());
|
||||||
}
|
}
|
||||||
@ -32,7 +34,7 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
|||||||
TextEditingController inputPseudo = TextEditingController();
|
TextEditingController inputPseudo = TextEditingController();
|
||||||
TextEditingController inputPassword = TextEditingController();
|
TextEditingController inputPassword = TextEditingController();
|
||||||
Future<void> _login(BuildContext context) async {
|
Future<void> _login(BuildContext context) async {
|
||||||
var url = Uri.parse("http://localhost:8083/api/token");
|
var url = Uri.parse("http://${globals.api}/token");
|
||||||
var pseudo = inputPseudo.text;
|
var pseudo = inputPseudo.text;
|
||||||
var password = inputPassword.text;
|
var password = inputPassword.text;
|
||||||
if ((pseudo.isNotEmpty) && (password.isNotEmpty)) {
|
if ((pseudo.isNotEmpty) && (password.isNotEmpty)) {
|
||||||
@ -125,7 +127,7 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
|||||||
var jwt = prefs.getString("jwt") ?? "";
|
var jwt = prefs.getString("jwt") ?? "";
|
||||||
var user = prefs.getString("user") ?? "";
|
var user = prefs.getString("user") ?? "";
|
||||||
if ((jwt.isNotEmpty) && (user.isNotEmpty)) {
|
if ((jwt.isNotEmpty) && (user.isNotEmpty)) {
|
||||||
var urlToken = Uri.parse("http://localhost:8083/api/token");
|
var urlToken = Uri.parse("http://${globals.api}/token");
|
||||||
|
|
||||||
var responseToken = await http.get(urlToken,
|
var responseToken = await http.get(urlToken,
|
||||||
headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'});
|
headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'});
|
||||||
|
1
covas_mobile/lib/variable/globals.dart
Normal file
1
covas_mobile/lib/variable/globals.dart
Normal file
@ -0,0 +1 @@
|
|||||||
|
String api = "10.0.2.2:8083/api";
|
Loading…
x
Reference in New Issue
Block a user