extract getEffectiveCenterTitle

This commit is contained in:
Salvatore Giordano
2022-04-27 11:52:07 +02:00
parent 81c4207b04
commit 622efa7ba2
3 changed files with 33 additions and 36 deletions
@@ -17,6 +17,28 @@ Future<void> launchURL(BuildContext context, String url) async {
}
}
/// Get centerTitle considering a default and platform specific behaviour
bool getEffectiveCenterTitle(
ThemeData theme, {
bool? centerTitle,
List<Widget>? actions,
}) {
if (centerTitle != null) return centerTitle;
if (theme.appBarTheme.centerTitle != null) {
return theme.appBarTheme.centerTitle!;
}
switch (theme.platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return actions == null || actions.length < 2;
}
}
/// Shows confirmation dialog
Future<bool?> showConfirmationDialog(
BuildContext context, {