// import 'package:image_picker_web/image_picker_web.dart';
// import 'dart:typed_data';

// class ImagePickerHelper {
//   Future<dynamic> pickImage() async {
//     Uint8List? bytesFromPicker = await ImagePickerWeb.getImageAsBytes();
//     if (bytesFromPicker != null) {
//       return bytesFromPicker;
//     }
//   }
// }

import 'dart:typed_data';
import 'dart:html' as html;

class ImagePickerHelper {
  Future<void> pickImage() async {
    html.FileUploadInputElement uploadInput = html.FileUploadInputElement();
    uploadInput.accept = 'image/*';
    uploadInput.click();

    uploadInput.onChange.listen((event) async {
      final file = uploadInput.files!.first;
      final reader = html.FileReader();

      reader.readAsArrayBuffer(file);
      reader.onLoadEnd.listen((event) {
        Uint8List imageBytes = reader.result as Uint8List;
        if (imageBytes != null) {
          return imageBytes;
        } 
      });
    });
  }
}