Unverified Commit c51ee117 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Add a "troubleshooting" section to the AppBar API doc (#86188)

parent 46817f4a
......@@ -154,6 +154,50 @@ class _PreferredAppBarSize extends Size {
/// ```
/// {@end-tool}
///
/// ## Troubleshooting
///
/// ### Why don't my TextButton actions appear?
///
/// If the app bar's [actions] contains [TextButton]s, they will not
/// be visible if their foreground (text) color is the same as the
/// the app bar's background color.
///
/// The default app bar [backgroundColor] is the overall theme's
/// [ColorScheme.primary] if the overall theme's brightness is
/// [Brightness.light]. Unfortunately this is the same as the default
/// [ButtonStyle.foregroundColor] for [TextButton] for light themes.
/// In this case a preferable text button foreground color is
/// [ColorScheme.onPrimary], a color that contrasts nicely with
/// [ColorScheme.primary]. to remedy the problem, override
/// [TextButton.style]:
///
/// {@tool dartpad --template=stateless_widget_material}
///
/// ```dart
/// Widget build(BuildContext context) {
/// final ButtonStyle style = TextButton.styleFrom(
/// primary: Theme.of(context).colorScheme.onPrimary
/// );
/// return Scaffold(
/// appBar: AppBar(
/// actions: <Widget>[
/// TextButton(
/// style: style,
/// onPressed: () {},
/// child: const Text('Action 1'),
/// ),
/// TextButton(
/// style: style,
/// onPressed: () {},
/// child: const Text('Action 2'),
/// )
/// ],
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [Scaffold], which displays the [AppBar] in its [Scaffold.appBar] slot.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment