Flutter_file_picker: Size getter for PlatformFile returns in Kilobytes whereas documentation says Bytes

Created on 8 Jan 2021  Â·  2Comments  Â·  Source: miguelpruivo/flutter_file_picker

Describe the bug
I'm not sure if this is a bug or a typo.

Docs for platform_file.dart:

  /// The file size in bytes.
  final int size;

Behavior in Flutter Web (the one I tested by picking an 8kb image):

FilePickerResult result = await FilePicker.platform.pickFiles(type: FileType.image);
print("size ${result.files.single.size}"); // prints: 8 
print("bytes length ${result.files.single.bytes.length}"); // prints: 8795

Version = file_picker: ^2.1.5

Flutter Version details

Click To Expand


[✓] Flutter (Channel master, 1.26.0-2.0.pre.145, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en)
    • Flutter version 1.26.0-2.0.pre.145 at /Users/osaxma/fvm/versions/master
    • Framework revision 38fe7e2b1c (11 days ago), 2020-12-28 21:39:03 -0500
    • Engine revision 892034dc6a
    • Dart version 2.12.0 (build 2.12.0-179.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/osaxma/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0, Build version 12A7209
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.1

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141

• No issues found!

bug web

All 2 comments

Hi! This is a bug. I refactored to be in bytes instead of kB a few days ago, but forgot the web platform.

Thank you for pointing out.

Fixed with 2.1.5+1.

Thank you once again.

Was this page helpful?
0 / 5 - 0 ratings