updateUser method

  1. @override
Future<User> updateUser(
  1. String token,
  2. User user
)
override

Updates the data for a given user and returns the updated user confirmed by the server.

Implementation

@override
Future<User> updateUser(String token, User user) async {
  final response = await _api.callFunction(
    function: 'local_lbplanner_user_update_user',
    token: token,
    body: Map.fromEntries(
      user.toJson().entries.where(
            (e) => [
              'lang',
              'theme',
              'colorblindness',
              'displaytaskcount',
            ].contains(e.key),
          ),
    ),
  );

  response.assertJson();

  return User.fromJson(response.asJson);
}