|
@@ -1,13 +1,12 @@
|
|
import 'dart:convert';
|
|
import 'dart:convert';
|
|
-
|
|
|
|
-import 'package:dio/dio.dart';
|
|
|
|
|
|
+// import 'package:date_format/date_format.dart';
|
|
|
|
+// import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
+import 'package:http/http.dart' as http;
|
|
// import 'package:go_router/go_router.dart';
|
|
// import 'package:go_router/go_router.dart';
|
|
import 'package:namer_app/footer.dart';
|
|
import 'package:namer_app/footer.dart';
|
|
import 'package:namer_app/head.dart';
|
|
import 'package:namer_app/head.dart';
|
|
-// import 'package:dio/dio.dart';
|
|
|
|
-// import 'package:namer_app/models/user_model.dart';
|
|
|
|
-// import 'package:namer_app/services/login_service.dart';
|
|
|
|
|
|
+// import 'package:namer_app/services/signIn.dart';
|
|
// import 'package:namer_app/header.dart';
|
|
// import 'package:namer_app/header.dart';
|
|
|
|
|
|
class LoginPage extends StatelessWidget {
|
|
class LoginPage extends StatelessWidget {
|
|
@@ -15,12 +14,12 @@ class LoginPage extends StatelessWidget {
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- var dio = Dio();
|
|
|
|
- Response response;
|
|
|
|
|
|
+ // var dio = Dio();
|
|
|
|
+ // Response response;
|
|
final usernameController = TextEditingController();
|
|
final usernameController = TextEditingController();
|
|
final passwordController = TextEditingController();
|
|
final passwordController = TextEditingController();
|
|
- var auth =
|
|
|
|
- 'Basic ${base64Encode(utf8.encode('$usernameController:$passwordController'))}';
|
|
|
|
|
|
+ // var auth =
|
|
|
|
+ // 'Basic ${base64Encode(utf8.encode('$usernameController:$passwordController'))}';
|
|
return Scaffold(
|
|
return Scaffold(
|
|
// appBar: Header(
|
|
// appBar: Header(
|
|
// title: Text('title'),
|
|
// title: Text('title'),
|
|
@@ -99,11 +98,15 @@ class LoginPage extends StatelessWidget {
|
|
width: 396,
|
|
width: 396,
|
|
height: 61,
|
|
height: 61,
|
|
child: ElevatedButton(
|
|
child: ElevatedButton(
|
|
- onPressed: () async {
|
|
|
|
- response = await dio.post('http://localhost:8080/api/v1',
|
|
|
|
- options: Options(headers: <String, String>{
|
|
|
|
- 'authorization': auth
|
|
|
|
- }));
|
|
|
|
|
|
+ onPressed: () async{
|
|
|
|
+ String basicAuth = 'Basic ${base64.encode('usernameController:passwordController' as List<int>)}';
|
|
|
|
+ var response = await http.post(
|
|
|
|
+ 'http://localhost:8080/api/v1' as Uri,
|
|
|
|
+ headers: <String, String>{'authorization': basicAuth},
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ print('Response status: ${response.statusCode}');
|
|
|
|
+ print('Response body: ${response.body}');
|
|
},
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.black, //todo putih lage
|
|
backgroundColor: Colors.black, //todo putih lage
|