import 'dart:io';

import 'package:flutter/material.dart';
import 'package:initial_folder/models/profile_image_post_model.dart';
import 'package:initial_folder/services/profile_image_service.dart';

class ProfileImageProvider with ChangeNotifier {
  ProfileImagePostModel? _imageModel;
  File? _imageFile;

  ProfileImagePostModel? get imageModel => _imageModel;
  File? get imageFile => _imageFile;

  set imageModel(ProfileImagePostModel? _imageModel) {
    _imageModel = imageModel;
    notifyListeners();
  }

  void setImageFile(File? file) {
    _imageFile = file;
    notifyListeners();
  }

  Future<bool> addProfileImage({required File pckFile}) async {
    try {
      ProfileImagePostModel? imageModel =
          await ProfileImageService().addProfileImage(pckFile: pckFile);
      _imageModel = imageModel;
      return true;
    } catch (e) {
      return false;
    }
  }
}
