-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18Found to occur in 3.18frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.good first issueRelatively approachable for first-time contributorsRelatively approachable for first-time contributorshas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to reproduce
- Use the provided reproduction code
- Tap on the text to change the alignment from left to right
Expected results
The LayoutBuilder surrounding the Text widget should build again, because the layout of its descendantText changed.
Actual results
The LayoutBuilder doesn't run again because the descendant Text didn't report a layout change. It only reported dirty paint.
Code sample
Code sample
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: MyWidget(),
),
);
}
}
class MyWidget extends StatefulWidget {
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
print("Running LayoutBuilder");
return SizedBox(
width: double.infinity,
child: TextAlignChanger(),
);
}
);
}
}
class TextAlignChanger extends StatefulWidget {
@override
State<TextAlignChanger> createState() => _TextAlignChangerState();
}
class _TextAlignChangerState extends State<TextAlignChanger> {
TextAlign _textAlign = TextAlign.left;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => setState(() {
print("Changing text alignment to the right");
_textAlign = TextAlign.right;
}),
child: Text(
'Hello, World!',
textAlign: _textAlign,
style: Theme.of(context).textTheme.headlineMedium,
),
);
}
}Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Reproduced in Dart Pad: Based on Flutter 3.16.5 Dart SDK 3.2.3
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18Found to occur in 3.18frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.good first issueRelatively approachable for first-time contributorsRelatively approachable for first-time contributorshas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team