S.D.
S.D.

Reputation: 5867

UI Testing if a button is enabled

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?

Upvotes: 15

Views: 6124

Answers (1)

Richard Heap
Richard Heap

Reputation: 51692

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);

Upvotes: 27

Related Questions