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 {
219
219
void releasedBy (Arena arena) => arena.onReleaseAll (release);
220
220
}
221
221
222
- extension JObjectUseExtension <T extends JObject > on T {
222
+ extension JObjectUseExtension <T extends JObject ? > on T {
223
223
/// Applies [callback] on this object and then delete the underlying JNI
224
224
/// reference, returning the result of [callback] .
225
225
R use <R >(R Function (T ) callback) {
226
226
try {
227
227
final result = callback (this );
228
228
return result;
229
229
} finally {
230
- release ();
230
+ this ? . release ();
231
231
}
232
232
}
233
233
}
Original file line number Diff line number Diff line change @@ -175,6 +175,8 @@ void run({required TestRunnerCallback testRunner}) {
175
175
});
176
176
});
177
177
expect (randomInt, lessThan (15 ));
178
+ const JObject ? nullableJObject = null ;
179
+ expect (nullableJObject.use ((_) => 'foo' ), equals ('foo' ));
178
180
});
179
181
180
182
// The JObject and JClass have NativeFinalizer. However, it's possible to
You can’t perform that action at this time.
0 commit comments