-
Notifications
You must be signed in to change notification settings - Fork 29.7k
IgnoreBaseline widget #131220
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
IgnoreBaseline widget #131220
Conversation
|
cc @justinmc - you might want to use this around the labels in a text field to prevent buttons in the same row from aligning with the text field label rather than the text field contents |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits 👍
Is this what you mean about aligning with the content instead of the label? Looks like it works now but I'm probably misunderstanding, or maybe we're already disregarding labels etc. in baseline calculations.
Code
import 'package:flutter/material.dart';
// See https://github.com/flutter/flutter/pull/131220
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final TextEditingController _controller = TextEditingController(
//text: 'Hello text field.',
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
textDirection: TextDirection.ltr,
children: [
ConstrainedBox(
constraints: BoxConstraints.loose(const Size(150.0, double.infinity)),
child: TextField(
controller: _controller,
decoration: const InputDecoration(
labelText: 'label',
labelStyle: TextStyle(fontSize: 64.0),
)
),
),
const Text(
'a',
textDirection: TextDirection.ltr,
style: TextStyle(fontSize: 128.0, fontFamily: 'FlutterTest'), // places baseline at y=96
),
const Text(
'b',
textDirection: TextDirection.ltr,
style: TextStyle(fontSize: 32.0, fontFamily: 'FlutterTest'), // 24 above baseline, 8 below baseline
),
],
),
],
),
),
);
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be super.child?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately not, it's a positional argument in the superclass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I missed that it was positional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Too many newlines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a section separator (the next section starts with an all-caps heading), the rest of the file (with one exception i can fix) has the same double blank line before headings.
I don't feel strongly one way or the other if you would prefer I removed the double blank lines everywhere in this file before the headings, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say don't worry about it here, maybe if it comes up again we can make this file all 1 line.
It was what I meant. I wonder how we make it work today! It used to be broken (see comments in #7037). |
|
I'll post in the issue about the button-textfield alignment thing. |
flutter/flutter@61fd11d...dd9764e 2023-07-27 [email protected] Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog. (flutter/flutter#131306) 2023-07-27 [email protected] Fix ios_add2app Podfile (flutter/flutter#131263) 2023-07-27 [email protected] Add DeviceLab build+test separation doc (flutter/flutter#131365) 2023-07-27 [email protected] IgnoreBaseline widget (flutter/flutter#131220) 2023-07-27 [email protected] Add 'vm:keep-name' pragmas to platform channel classes (flutter/flutter#131271) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md


Fixes #7037