flutter-form-builder-ecosystem / form_builder_file_picker

File picker field widget for FlutterFormBuilder.
https://pub.dev/packages/form_builder_file_picker
BSD 3-Clause "New" or "Revised" License
15 stars 33 forks source link

Attempt to resolve null safety issues #13

Closed tafaust closed 2 years ago

tafaust commented 3 years ago

Hey, I encountered null safety related issues and the compilation of my app fails. The error message read:

Launching lib/main.dart on Chrome in debug mode...
../../.pub-cache/hosted/pub.dartlang.org/form_builder_file_picker-1.2.0-nullsafety.0/lib/src/form_builder_file_picke
r.dart:161:36: Error: The argument type 'bool?' can't be assigned to the parameter type 'bool' because 'bool?' is
nullable and 'bool' isn't.
          allowCompression: widget.allowCompression,                    
                                   ^                                    
../../.pub-cache/hosted/pub.dartlang.org/form_builder_file_picker-1.2.0-nullsafety.0/lib/src/form_builder_file_picke
r.dart:242:38: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
                        files[index].name!,                             
                                     ^                                  
Waiting for connection from debug service on Chrome...             28.1s
Failed to compile application.

This PR provides a fix to the errors I encountered. Please also see: https://github.com/danvick/form_builder_file_picker/issues/12#issuecomment-855335765

tafaust commented 3 years ago

@danvick FYI file_picker@3.0.2 introduced the PlatformFile name field with String type (see: https://pub.dev/documentation/file_picker/latest/file_picker/PlatformFile/name.html) while file_picker@3.0.1 provides the nullable String type (see: https://pub.dev/documentation/file_picker/3.0.1/file_picker/PlatformFile/name.html).