vendredi 29 novembre 2019

How to test not equal with matcher in flutter

I'm doing testing on render objects in Flutter. I'd like to check for inequality like this (simplified):

testWidgets('render object heights not equal', (WidgetTester tester) async {

  final renderObjectOneHeight = 10;
  final renderObjectTwoHeight = 11;

  expect(renderObjectOneHeight, notEqual(renderObjectTwoHeight));
});

I made up notEqual because it doesn't exist. This doesn't work either:

  • !equals

I found a solution that works so I am posting my answer below Q&A style. I welcome any better solutions, though.

Aucun commentaire:

Enregistrer un commentaire