Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Testing if a button is enabled

Tags:

flutter

dart

I want to check if a Button is disabled in my UI test.

In Android you would normally do something like this:

onView(withId(R.id.buttonId)).check(matches(not(isEnabled())));

What is the equivalent when writing a UI test for Flutter?

like image 589
S.D. Avatar asked Dec 11 '22 06:12

S.D.


1 Answers

Give your Button a UniqueKey and pump the Widget and perform other test clicks, etc. Then

expect(tester.widget<FlatButton>(find.byKey(buttonKey)).enabled, isFalse);
like image 67
Richard Heap Avatar answered Jan 23 '23 14:01

Richard Heap