File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -219,15 +219,15 @@ class JObject {
219219 void releasedBy (Arena arena) => arena.onReleaseAll (release);
220220}
221221
222- extension JObjectUseExtension <T extends JObject > on T {
222+ extension JObjectUseExtension <T extends JObject ? > on T {
223223 /// Applies [callback] on this object and then delete the underlying JNI
224224 /// reference, returning the result of [callback] .
225225 R use <R >(R Function (T ) callback) {
226226 try {
227227 final result = callback (this );
228228 return result;
229229 } finally {
230- release ();
230+ this ? . release ();
231231 }
232232 }
233233}
Original file line number Diff line number Diff line change @@ -175,6 +175,8 @@ void run({required TestRunnerCallback testRunner}) {
175175 });
176176 });
177177 expect (randomInt, lessThan (15 ));
178+ const JObject ? nullableJObject = null ;
179+ expect (nullableJObject.use ((_) => 'foo' ), equals ('foo' ));
178180 });
179181
180182 // The JObject and JClass have NativeFinalizer. However, it's possible to
You can’t perform that action at this time.
0 commit comments