Unverified Commit 4680ff3a authored by Ayaan Khan's avatar Ayaan Khan Committed by GitHub

fix: MaterialColor Swatch Map comparison (#61974)

parent 4c3a14c9
...@@ -450,7 +450,7 @@ class ColorSwatch<T> extends Color { ...@@ -450,7 +450,7 @@ class ColorSwatch<T> extends Color {
return false; return false;
return super == other return super == other
&& other is ColorSwatch<T> && other is ColorSwatch<T>
&& other._swatch == _swatch; && mapEquals<T, Color>(other._swatch, _swatch);
} }
@override @override
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
const double _doubleColorPrecision = 0.01; const double _doubleColorPrecision = 0.01;
...@@ -440,4 +441,22 @@ void main() { ...@@ -440,4 +441,22 @@ void main() {
final Map<String, Object> json = property.toJsonMap(const DiagnosticsSerializationDelegate()); final Map<String, Object> json = property.toJsonMap(const DiagnosticsSerializationDelegate());
expect(json.containsKey('valueProperties'), isFalse); 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);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment