You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Actions in a scaffold are a different height than the menu/back icon #7185
I'm measuring the action item and menu item, and the action widget is squished up towards the top of the space it can occupy, and it takes up less vertical space. The switch and the menu appear to be top-aligned, which makes them look imbalanced.
An example:
action button: go/hsv/5051009483145216?node=95
menu button: go/hsv/5051009483145216?node=93
I had a similar problem last night when I tried to use an Icon widget instead of an IconButton widget in AppBar.actions. IconButton aligned properly, but Icon did not. Not sure if that's related to this or not.
Looks like our layout computation for AX information may be wrong: #7205 If you're going to use a lot of that tool, we might want to improve our AX information a bit. ;)
I've explicitly centered the switch so that it lines up with the center of the appbar's hamburger-title-actions row. As far as I can tell, the hamburger (the drawer icon on the left) is positioned correctly.
I agree that the app bar should vertically center its action widgets by default however this should easy to workaround for the moment.
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class AppBarAlignment extends StatefulWidget {
@override
_AppBarAlignmentState createState() => new _AppBarAlignmentState();
}
class _AppBarAlignmentState extends State<AppBarAlignment> {
static final List<String> _dropdownItems = <String>['One', 'Two', 'Free', 'Four'];
String _dropdownValue = 'One';
bool _switchValue = true;
@override
Widget build(BuildContext context) {
debugPaintSizeEnabled = true;
return new Scaffold(
appBar: new AppBar(
title: new Theme(
data: new ThemeData(brightness: Brightness.dark),
child: new SizedBox(
width: 200.0,
child: new DropdownButton<String>(
value: _dropdownValue,
onChanged: (String newValue) {
setState(() {
_dropdownValue = newValue;
});
},
items: _dropdownItems.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
),
),
),
actions: <Widget>[
new Theme(
data: new ThemeData(brightness: Brightness.dark),
child: new Center(
child: new Switch(
value: _switchValue,
onChanged: (bool value) {
setState(() {
_switchValue = value;
});
}
),
),
),
],
),
drawer: new Center(
child: new Text('Hello World'),
),
body: new Center(
child: new Text('Hello World'),
),
);
}
}
void main() {
runApp(new MaterialApp(home: new AppBarAlignment()));
}
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 flutter doctor -v and a minimal reproduction of the issue.
Activity
eseidelGoogle commentedon Dec 8, 2016
I had a similar problem last night when I tried to use an Icon widget instead of an IconButton widget in AppBar.actions. IconButton aligned properly, but Icon did not. Not sure if that's related to this or not.
Is this blocking you?
eseidelGoogle commentedon Dec 8, 2016
Looks like our layout computation for AX information may be wrong: #7205 If you're going to use a lot of that tool, we might want to improve our AX information a bit. ;)
DaveShuckerow commentedon Dec 9, 2016
Not a blocker, but it's a UI cleanup that we'd like to do before EOY (EO next week, essentially).
We only use it in the first page of the leafy app, as seen in the screenshot I sent you.
eseidelGoogle commentedon Dec 9, 2016
For clarity: Which alignment would you expect? Baseline? Center? @Hixie is probably the right person to ask about alignment questions. I don't see any the AppBar attempting any specific alignment:
https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/app_bar.dart#L59
DaveShuckerow commentedon Dec 9, 2016
We expect a center alignment here.
HansMuller commentedon Dec 14, 2016
Here's a test case.
I've explicitly centered the switch so that it lines up with the center of the appbar's hamburger-title-actions row. As far as I can tell, the hamburger (the drawer icon on the left) is positioned correctly.
I agree that the app bar should vertically center its action widgets by default however this should easy to workaround for the moment.
Hixie commentedon Dec 14, 2016
I think the solution is just to put a cross axis alignment of center here in the actions row in the appbar:
https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/app_bar.dart#L409
HansMuller commentedon Dec 14, 2016
I agree. Working on a test.
github-actions commentedon Sep 5, 2021
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
flutter doctor -vand a minimal reproduction of the issue.