I have a button with a specific elevation, set as an argument:
child: ElevatedButton(
key: const Key('MyButton'),
onPressed: () {},
child: Text('My Button'),
style: ButtonStyle(
elevation: MaterialStateProperty.all<double>(2.0),
),
), ...
I would like to test the elevation value. The snippet I've wrote is below:
final button = tester
.widget<ElevatedButton>(find.byKey(Key('NewSessionsElevatedButton')));
expect(button.style.elevation, MaterialStateProperty.all<double>(2.0));
However, the exception below is raised in the test, telling both values are equal, but it breaks anyway:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
Expected: _MaterialStatePropertyAll<double>:<MaterialStateProperty.all(2.0)>
Actual: _MaterialStatePropertyAll<double>:<MaterialStateProperty.all(2.0)>
I've read the tests for this class in the repository, but they are not clear. How can I test MaterialStateProperty values?