According to the [docs][1]:
If the `onPressed` callback is null, then the button will be disabled and by default will resemble a flat button in the disabledColor.
Try below code snippet.
TextButton(
onPressed: calculateWhetherDisabledReturnsBool() ? null : () =>
whatToDoOnPressed,
child: Text('Button text')
);
[1]: https://docs.flutter.dev/release/breaking-changes/buttons
According to the [docs][1]:
> If the `onPressed` callback is null, then the button will be disabled
> and by default will resemble a flat button in the `disabledColor`.
So, you might do something like this:
```dart
RaisedButton(
onPressed: calculateWhetherDisabledReturnsBool() ? null : () => whatToDoOnPressed,
child: Text('Button text')
);
```
[1]: https://docs.flutter.dev/release/breaking-changes/buttons