79351327

Date: 2025-01-13 06:32:04
Score: 2.5
Natty:
Report link

Facing same issue.

 Future<void> pickFile() async {
final result = await FilePicker.platform.pickFiles(
  allowMultiple: false,
  type: FileType.image, // Ensure image files are selected
);

if (result != null && result.files.isNotEmpty) {
  setState(() {
    selectedFile = result.files.first;
    if (selectedFile != null) {
      print('Selected file path: ${selectedFile!.path}');
      
      // Load file bytes explicitly
      _loadFileBytes(selectedFile!.path);
      
      widget.onFilePicked(selectedFile!);
    } else {
      print('No file selected!');
    }
  });
} else {
  print('No file picked!');
}}

Future<void> _loadFileBytes(String? path) async {
if (path != null) {
  final file = File(path);
  final bytes = await file.readAsBytes();
  setState(() {
    imageBytes = bytes;
  });
  print('Image bytes length: ${bytes.length}');
}

}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): Facing same issue
  • Low reputation (1):
Posted by: Adarsh K A Mfluid