-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed AppBar constraints break layouts #44550
Comments
This is indeed an unintended regression due to a breaking change in AppBar's layout; see #42936. The breaking change should have been announced along with a remedy that restored the original behavior. Sorry about that. Here's an app that demonstrates the problem:
The images/logo.png image is from pixabay. To restore the original AppBar layout behavior, wrap the AppBar's title in a SizedBox with appBar: AppBar(
title: SizedBox(
height: kToolbarHeight,
child: Image.asset(logoAsset),
),
),
| Will update the API docs and Stack Overflow. |
@HansMuller I understand the workaround. I have implemented as much at the moment. The problem is really the way the jumbo title solution is implemented surely? I see other layout problems coming in with FlexibleSpace and other related changes to AppBar size. That really needs the constraints to be passed down. |
@slightfoot Do you have a specific example of an AppBar layout failure related to FlexibleSpace or the AppBar's preferred size? |
This (the jumbo appbar PR) also broke my personal app's appbars. I had a column in the AppBar so that it would align things to the bottom, and that stopped working (now the Column just shrink-wraps). Testcase: import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:dummy_appbar/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
final UniqueKey key = UniqueKey();
await tester.pumpWidget(MaterialApp(
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 10.0,
height: 10.0,
child: DecoratedBox(
key: key,
decoration: BoxDecoration(
color: Colors.yellow,
),
),
),
],
),
),
),
));
expect(tester.getRect(find.byKey(key)), Rect.fromLTWH(395, 46, 10, 10));
});
} |
Bug was caused by flutter/flutter#42936 as reported by flutter/flutter#44550. Fixes jocosocial#291
Bug was caused by flutter/flutter#42936 as reported by flutter/flutter#44550. Fixes #291
Code Sample
flutter doctor -v
|
I'm going to close this as the current AppBar layout behavior has been documented #49583 and has been around for long enough to make adding another incompatible layout change worse than leaving things as they are. Sorry about the long delay in resolving this. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I recently compiled one of our application with the latest dev channel version
v1.10.15
and I noticed that the logo placed in the AppBar suddenly was broken. Confirmed this is not the case inv1.10.14
..I've tracked it down to a change made by @HansMuller in PR #42936: Support AppBars with jumbo titles. This change makes the AppBar's title area layout with an unconstrained height. This also seems to layout outside the parent bounds as pictured below.
flutter/packages/flutter/lib/src/material/app_bar.dart
Line 1285 in e7073f9
This wasn't reported as a breaking change. So perhaps there is thought into what conforms to a breaking change here? Also, since the AppBar is a preferredSize widget I think there is an expectation that a height should be provided to the title widget?
I've seen these types of layout issues before and I kinda feel minWidth/minHeight should resolve these. But the framework seems to fail on this to some degree. For example in this situation, we would expect their to be a minWidth/minHeight of the AppBar title area size and then have the maxHeight unconstrained. So that child widget need to be at least the size of the title area like a Tight constraint but can also get larger if required.
Example Code
Logs
The text was updated successfully, but these errors were encountered: