I have a button which has CircleBorder set as shape, it works correctly when the app runs, but the widget testing case I've implemented returns null.
This is the built widget inside my build method:
TextButton(
style: (style ?? TextButtonTheme.of(context).style ?? const ButtonStyle()).copyWith(
shape: MaterialStateProperty.all(const CircleBorder()),
),
onPressed: onPressed,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon),
Text(label),
],
),
);
You can see I have set the shape to MaterialStateProperty.all(const CircleBorder()).
Here is the test which fails:
final shape = foundButton.style?.shape;
/// Test the shape of the button is a [CircleBorder].
expect(shape?.resolve(<MaterialState>{}), const CircleBorder());
And here is the output of the test:
The following TestFailure was thrown running a test:
Expected: CircleBorder:<CircleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none))>
Actual: <null>
Anyone knows what's causing the test to fail?