lundi 29 avril 2019

How to unit Test a Flutter TextFormField maxlines

Is it possible to write a unit test that verifies that the maxLines property of a TextFormField is set correctly. I can not find a way to access the property:

i create a TextFormField

final field = TextFormField(
    initialValue: "hello",
    key: Key('textformfield'),
    maxLines: 2,
  );

then in the test i get access to the form field with tester.widget

 final formfield =
    await tester.widget<TextFormField>(find.byKey(Key('textformfield')));

but since the maxLines property is passed to the Builder which returns a Textfield, how can i get access to the textfield.

Or is there an completely other ways to verify this?

Aucun commentaire:

Enregistrer un commentaire