From ce722f55bb8c314dd3b0f7857d9bc17ec6016d39 Mon Sep 17 00:00:00 2001 From: Jaspreet Singh Date: Fri, 16 Sep 2022 10:05:28 +0400 Subject: [PATCH] Make MediaDevice data class (#174) --- lib/src/hardware/hardware.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/src/hardware/hardware.dart b/lib/src/hardware/hardware.dart index 21e4b93..129a729 100644 --- a/lib/src/hardware/hardware.dart +++ b/lib/src/hardware/hardware.dart @@ -3,12 +3,26 @@ import 'dart:async'; import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc; class MediaDevice { - MediaDevice(this.deviceId, this.label, this.kind); + const MediaDevice(this.deviceId, this.label, this.kind); final String deviceId; final String label; final String kind; + @override + bool operator ==(covariant MediaDevice other) { + if (identical(this, other)) return true; + + return other.deviceId == deviceId && + other.kind == kind && + other.label == label; + } + + @override + int get hashCode { + return deviceId.hashCode ^ kind.hashCode ^ label.hashCode; + } + @override String toString() { return 'MediaDevice{deviceId: $deviceId, label: $label, kind: $kind}';