fix: MaterialColor Swatch Map comparison (#61974)
This commit is contained in:
@@ -450,7 +450,7 @@ class ColorSwatch<T> extends Color {
|
||||
return false;
|
||||
return super == other
|
||||
&& other is ColorSwatch<T>
|
||||
&& other._swatch == _swatch;
|
||||
&& mapEquals<T, Color>(other._swatch, _swatch);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const double _doubleColorPrecision = 0.01;
|
||||
|
||||
@@ -440,4 +441,22 @@ void main() {
|
||||
final Map<String, Object> json = property.toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
expect(json.containsKey('valueProperties'), isFalse);
|
||||
});
|
||||
|
||||
test('MaterialColor swatch comparison', () {
|
||||
const Map<int, MaterialColor> sampleMap = <int, MaterialColor>{
|
||||
0: Colors.lightBlue,
|
||||
1: Colors.deepOrange,
|
||||
2: Colors.blueGrey,
|
||||
};
|
||||
const MaterialColor first = MaterialColor(0, sampleMap);
|
||||
const MaterialColor second = MaterialColor(0, sampleMap);
|
||||
const MaterialColor third = MaterialColor(
|
||||
0, <int, MaterialColor>{
|
||||
0: Colors.lightBlue,
|
||||
1: Colors.deepOrange,
|
||||
2: Colors.blueGrey,
|
||||
});
|
||||
expect(first == second, true);
|
||||
expect(first == third, true);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user