import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
import 'package:file_picker/file_picker.dart';

Future<String?> pickAndStoreImage(File file, int productId) async {
  Directory appDocDir = await getApplicationDocumentsDirectory();
  String productsDirectoryPath = path.join(appDocDir.path, 'productosC');
  await Directory(productsDirectoryPath).create(recursive: true);
  String fileExtension = path.extension(file.path);
  String newFileName = "$productId$fileExtension";
  String finalPath = path.join(productsDirectoryPath, newFileName);

  await file.copy(finalPath);

  return finalPath;
}
