blob: ebbf032aa67365bb143867d1655d082a59a3164e [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'instance_manager.dart';
import 'web_kit.pigeon.dart';
/// Flutter api to dispose functions.
class FunctionFlutterApiImpl extends FunctionFlutterApi {
/// Constructs a [FunctionFlutterApiImpl].
FunctionFlutterApiImpl({InstanceManager? instanceManager}) {
this.instanceManager = instanceManager ?? InstanceManager.instance;
}
/// Maintains instances stored to communicate with native language objects.
late final InstanceManager instanceManager;
@override
void dispose(int identifier) {
final Function? function = instanceManager.getInstance(identifier);
if (function != null) {
instanceManager.removeWeakReference(function);
}
}
}