Skip to main content

prefer-action-button-tooltip

effort: 2m
has IDE fix
pro+

Warns when a FloatingActionButton does not pass the tooltip argument.

Adding tooltip is important if you want your users with screen readers to be able to understand what the action is supposed to do.

Example

❌ Bad:

class MyWidget extends StatelessWidget {
const MyWidget({super.key});


Widget build(BuildContext context) => Scaffold(
// LINT: Tooltip is not specified. Try adding it.
floatingActionButton: FloatingActionButton(
onPressed: () {},
),
);
}

class MyWidget extends StatelessWidget {
const MyWidget({super.key});


Widget build(BuildContext context) => Scaffold(
floatingActionButton: FloatingActionButton(
// LINT: Tooltip is not specified. Try adding it.
tooltip: '',
onPressed: () {},
),
);
}

✅ Good:

class MyWidget extends StatelessWidget {
const MyWidget({super.key});


Widget build(BuildContext context) => Scaffold(
floatingActionButton: FloatingActionButton(
tooltip: 'some tooltip',
onPressed: () {},
),
);
}

Additional Resources