1234567891011121314151617181920212223 |
- import 'package:dio/dio.dart';
- import 'package:flutter_provider_demo/model/api.dart';
- import 'package:flutter_provider_demo/model/user_model.dart';
- class UserDao {
- Future<UserModel> login(String username, String pwd) async {
- Map<String, dynamic> params = {"username": username, "pwd": pwd};
- Response response = await Dio().post(
- Api.login,
- data: params,
- );
- return UserModel.fromJson(response.data);
- }
- Future<bool> logout(String token) async {
- Map<String, dynamic> params = {"token": token};
- Response response = await Dio().post(
- Api.logout,
- data: params,
- );
- return response.data["code"] == 200;
- }
- }
|