SliverAppBar does not respect the appBarTheme's toolbarHeight
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
1. Set the `toolbarHeight` in the app theme's `appBarTheme` to anything except the default (e.g 70).
2. Use a `SliverAppBar ` anywhere in the app, without specifying its `toolbarHeight` directly.
### Expected results
The SliverAppBar should take its `toolbarHeight` from the theme — in our case, 70. (So, therefore, if the `toolbarHeight` attribute of 70 is then added to the SliverAppBar directly, its height should not change.)
### Actual results
The SliverAppBar ignores the toolbarHeight set in the app's theme.
### Code sample
Code sample
```dart
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(appBarTheme: AppBarTheme(toolbarHeight: 70.0)),
home: Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
backgroundColor: Colors.amber,
title: Text("TEST"),
)
],
),
),
);
}
}
```
### Screenshots or Video
_No response_
### Logs
_No response_
### Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel stable, 3.27.2, on macOS 15.2 24C101 darwin-arm64, locale en-CZ)
• Flutter version 3.27.2 on channel stable at /Users/me/Libraries/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 68415ad1d9 (3 weeks ago), 2025-01-13 10:22:03 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
• Android SDK at /Users/me/Library/Android/sdk
• Platform android-35, build-tools 35.0.1
• Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.13/libexec/openjdk.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.13+0)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
[✓] Android Studio (version 2024.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.2 24C101 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.2 24C101 darwin-arm64
• Chrome (web) • chrome • web-javascript • Brave Browser 132.1.74.51
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
Contributor guide
Assessment
This issue has not been assessed yet.