user_dao.dart 665 B

1234567891011121314151617181920212223
  1. import 'package:dio/dio.dart';
  2. import 'package:flutter_provider_demo/model/api.dart';
  3. import 'package:flutter_provider_demo/model/user_model.dart';
  4. class UserDao {
  5. Future<UserModel> login(String username, String pwd) async {
  6. Map<String, dynamic> params = {"username": username, "pwd": pwd};
  7. Response response = await Dio().post(
  8. Api.login,
  9. data: params,
  10. );
  11. return UserModel.fromJson(response.data);
  12. }
  13. Future<bool> logout(String token) async {
  14. Map<String, dynamic> params = {"token": token};
  15. Response response = await Dio().post(
  16. Api.logout,
  17. data: params,
  18. );
  19. return response.data["code"] == 200;
  20. }
  21. }