mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-02-22 12:30:40 +00:00
overriden ==
for MeasuredState
This commit is contained in:
parent
422ac9d528
commit
7fdacfac37
2 changed files with 26 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
abstract class MeteringCommunicationState {
|
sealed class MeteringCommunicationState {
|
||||||
const MeteringCommunicationState();
|
const MeteringCommunicationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ class InitState extends MeteringCommunicationState {
|
||||||
const InitState();
|
const InitState();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class SourceState extends MeteringCommunicationState {
|
sealed class SourceState extends MeteringCommunicationState {
|
||||||
const SourceState();
|
const SourceState();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ScreenState extends MeteringCommunicationState {
|
sealed class ScreenState extends MeteringCommunicationState {
|
||||||
const ScreenState();
|
const ScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class MeasureState extends SourceState {
|
||||||
const MeasureState();
|
const MeasureState();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MeasuredState extends ScreenState {
|
sealed class MeasuredState extends ScreenState {
|
||||||
final double? ev100;
|
final double? ev100;
|
||||||
|
|
||||||
const MeasuredState(this.ev100);
|
const MeasuredState(this.ev100);
|
||||||
|
@ -26,8 +26,28 @@ abstract class MeasuredState extends ScreenState {
|
||||||
|
|
||||||
class MeteringInProgressState extends MeasuredState {
|
class MeteringInProgressState extends MeasuredState {
|
||||||
const MeteringInProgressState(super.ev100);
|
const MeteringInProgressState(super.ev100);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
if (other.runtimeType != runtimeType) return false;
|
||||||
|
return other is MeteringInProgressState && other.ev100 == ev100;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(ev100, runtimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MeteringEndedState extends MeasuredState {
|
class MeteringEndedState extends MeasuredState {
|
||||||
const MeteringEndedState(super.ev100);
|
const MeteringEndedState(super.ev100);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
if (other.runtimeType != runtimeType) return false;
|
||||||
|
return other is MeteringEndedState && other.ev100 == ev100;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(ev100, runtimeType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ void main() {
|
||||||
'Multiple consequtive in progress events',
|
'Multiple consequtive in progress events',
|
||||||
build: () => bloc,
|
build: () => bloc,
|
||||||
act: (bloc) async {
|
act: (bloc) async {
|
||||||
|
bloc.add(const MeteringInProgressEvent(1));
|
||||||
|
bloc.add(const MeteringInProgressEvent(1));
|
||||||
bloc.add(const MeteringInProgressEvent(1));
|
bloc.add(const MeteringInProgressEvent(1));
|
||||||
bloc.add(const MeteringInProgressEvent(null));
|
bloc.add(const MeteringInProgressEvent(null));
|
||||||
bloc.add(const MeteringInProgressEvent(null));
|
bloc.add(const MeteringInProgressEvent(null));
|
||||||
|
@ -75,7 +77,6 @@ void main() {
|
||||||
expect: () => [
|
expect: () => [
|
||||||
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 1),
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 1),
|
||||||
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', null),
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', null),
|
||||||
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', null),
|
|
||||||
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 2),
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 2),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue