You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #252. Once native compress failures propagate to Dart as CompressError instead of a silent null return (Step 1 — see the tracking work following that issue), the currently-nullable APIs have no legitimate "returns null on success" cases left. Every remaining null path is a failure signal that would be more accurately expressed as an exception.
Proposal
Tighten these signatures from Future<T?> to Future<T>:
compressWithList is already non-nullable and stays that way.
Null-source inventory
For reference — every existing null-return path is either dead code, a failure signal, or a latent bug:
API
Null source (pre-Step-1)
After Step 1
compressWithFile
if (!support) return null; — dead code (checkSupportPlatform throws); native reply(null)/result(nil) on failure
Both paths gone: dead code removed, native failure translates to CompressError
compressAndGetFile
Same as above
Same
compressAssetImage
Same, plus uint8List.isEmpty → return null on empty asset bundle
Empty-bundle case becomes throw CompressError('Empty asset bundle bytes for \$assetName')
compressWithList (common)
Was already non-nullable but silently propagated null → runtime TypeError
Fixed in Step 1
Why this is breaking
Any caller doing if (result == null) or result?.path breaks compilation. Migration is straightforward — replace null-checks with try/catch (CompressError) — but needs a major-version bump and a migrate.md section.
Not blocked on anything but coordination
Technically ready to land once Step 1 is in. Waiting on:
Motivation
Follow-up to #252. Once native compress failures propagate to Dart as
CompressErrorinstead of a silentnullreturn (Step 1 — see the tracking work following that issue), the currently-nullable APIs have no legitimate "returns null on success" cases left. Every remainingnullpath is a failure signal that would be more accurately expressed as an exception.Proposal
Tighten these signatures from
Future<T?>toFuture<T>:FlutterImageCompress.compressWithFile—Future<Uint8List?> → Future<Uint8List>FlutterImageCompress.compressAndGetFile—Future<XFile?> → Future<XFile>FlutterImageCompress.compressAssetImage—Future<Uint8List?> → Future<Uint8List>(empty asset bundle bytes →throw CompressError(...))compressWithListis already non-nullable and stays that way.Null-source inventory
For reference — every existing null-return path is either dead code, a failure signal, or a latent bug:
compressWithFileif (!support) return null;— dead code (checkSupportPlatform throws); nativereply(null)/result(nil)on failureCompressErrorcompressAndGetFilecompressAssetImageuint8List.isEmpty → return nullon empty asset bundlethrow CompressError('Empty asset bundle bytes for \$assetName')compressWithList(common)TypeErrorWhy this is breaking
Any caller doing
if (result == null)orresult?.pathbreaks compilation. Migration is straightforward — replace null-checks withtry/catch (CompressError)— but needs a major-version bump and amigrate.mdsection.Not blocked on anything but coordination
Technically ready to land once Step 1 is in. Waiting on:
compressAndGetFileshape from [Feature request] Return XFile or Path instead of Uint8List for compressions #281 discussion) into the same release.Filing this as a tracking issue so we don't lose the reasoning.