-
Notifications
You must be signed in to change notification settings - Fork 371
Fix nullability mismatch in saveVideo and saveImageWithPath title parameter #1334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ndroid Co-authored-by: AlexV525 <[email protected]>
|
@copilot Could you investigate if the title field is necessary when saving? I don't want to make mistakes if it's a required field on supported platforms. You need to go deeper |
… or empty Co-authored-by: AlexV525 <[email protected]>
I investigated the title field usage across Android and iOS platforms. The title field is necessary on Android: Critical usage on Android:
On iOS:
Solution implemented:
Applied to both Commit: 8efacef |
|
@copilot Instead of using |
Co-authored-by: AlexV525 <[email protected]>
Implemented using
The logic now uses: final String effectiveTitle = (title?.isNotEmpty ?? false)
? title!
: path.basename(inputFile.absolute.path);Commit: 140cef4 |
b0f6ed9 to
394ae57
Compare
|
@copilot Update the top comment to reflect all changes in this PR |
The PR description should be updated to reflect the final implementation after the code improvements. Here's the updated version: ProblemThe InvestigationThe title field is required on Android:
On iOS, the title is optional and passed as Solution
Applied to both This ensures proper MediaStore metadata, prevents directory creation issues on Android API 28 and below, and maintains cleaner separation of concerns. |
The
saveVideoandsaveImageWithPathmethods'titleparameter is nullable in Dart (String?) but used non-null assertion (!!) in Kotlin, causing crashes when null is passed.Investigation
The title field is required on Android because:
TITLEandDISPLAY_NAMEfields in MediaStoreFile(albumDir, title).path.checkDirs()- an empty string would create invalid pathsOn iOS, the title is optional and passed as
originalFilenameto PHAssetResourceCreationOptions.Solution
path: ^1.8.3for cross-platform path manipulationplugin.dart):title?.trim()to normalize whitespacepath.basename()when title is null or emptysaveVideoandsaveImageWithPathmethodsPhotoManagerPlugin.kt):!!for title parameter (safe since Dart guarantees non-null value)String?type for optional parameters likedescandrelativePathThis approach:
Fixes #1318
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.