invalidates cachednetworkimage when new profile photo is uploaded
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
@@ -72,7 +73,7 @@ class UploadProfileImageState {
|
||||
|
||||
class UploadProfileImageNotifier
|
||||
extends StateNotifier<UploadProfileImageState> {
|
||||
UploadProfileImageNotifier(this._userSErvice)
|
||||
UploadProfileImageNotifier(this._userService)
|
||||
: super(
|
||||
UploadProfileImageState(
|
||||
profileImagePath: '',
|
||||
@@ -80,12 +81,17 @@ class UploadProfileImageNotifier
|
||||
),
|
||||
);
|
||||
|
||||
final UserService _userSErvice;
|
||||
final UserService _userService;
|
||||
|
||||
Future<bool> upload(XFile file) async {
|
||||
Future<bool> upload(XFile file, {
|
||||
String? invalidateUrl,
|
||||
}) async {
|
||||
state = state.copyWith(status: UploadProfileStatus.loading);
|
||||
|
||||
var res = await _userSErvice.uploadProfileImage(file);
|
||||
var res = await _userService.uploadProfileImage(file);
|
||||
if (invalidateUrl != null) {
|
||||
await CachedNetworkImage.evictFromCache(invalidateUrl);
|
||||
}
|
||||
|
||||
if (res != null) {
|
||||
debugPrint("Succesfully upload profile image");
|
||||
|
||||
Reference in New Issue
Block a user