blob: 6c836fa58fcb33ae085fb02f0b8aeb8a318fe93a [file] [log] [blame]
// Copyright 2021 The Fuchsia 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 'package:fidl_fuchsia_ui_views/fidl_async.dart';
/// A helper class that wraps [ViewRef] and provides convenient accessors.
class ViewHandle {
final ViewRef viewRef;
ViewHandle(this.viewRef);
/// Two [ViewHandle] objects are equal if their [koid]s match.
@override
bool operator ==(Object other) {
return other is ViewHandle && koid == other.koid ||
other is ViewRef && koid == other.reference.handle?.koid;
}
@override
int get hashCode => koid.hashCode;
@override
String toString() => 'ViewRef[koid: $koid]';
int get koid => viewRef.reference.handle?.koid ?? -1;
int get handle => viewRef.reference.handle?.handle ?? -1;
}