未確認だが問題回避のためプッシュ

This commit is contained in:
2024-04-09 01:58:25 +09:00
parent dd9dd0d087
commit 1b4073f690
59 changed files with 2384 additions and 410 deletions

View File

@ -1,6 +1,8 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:rogapp/model/auth_user.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import '../utils/const.dart';
@ -90,16 +92,35 @@ class AuthService {
String url = '$serverUrl/api/login/';
//print('++++++++$url');
//String url = 'http://localhost:8100/api/login/';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{'email': email, 'password': password}),
);
try {
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(
<String, String>{'email': email, 'password': password}),
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
} else {
print('Login failed with status code: ${response.statusCode}');
cats = {};
}
} catch( e ){
print('Error in login: $e');
Get.snackbar("通信エラーがおきました", "サーバーと通信できませんでした");
Get.snackbar(
"通信エラーがおきました",
"サーバーと通信できませんでした",
icon: const Icon(
Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow,
);
cats = {};
}
return cats;
}