import 'package:dio/dio.dart'; import 'package:flutter_tracker/dio/api.dart'; import 'package:flutter_tracker/model/user_model.dart'; class LoginDao { static Map params = Map(); static Future login(String username, String password) async { params.addAll({"username": username, "password": password}); Response response = await Dio().post(Api.login, queryParameters: params); return UserModel.fromJson(response.data); } static Future logout(String token) async { params.addAll({"token": token}); Response response = await Dio().get(Api.logout); return true; } static Future register(String username, String password) async { params.addAll({"username": username, "password": password}); Response response = await Dio().post(Api.register, queryParameters: params); return UserModel.fromJson(response.data); } static Future getUserInfo(String token) async { params.addAll({"token": token}); Response response = await Dio().get(Api.getUserInfo, queryParameters: params); return UserModel.fromJson(response.data); } }