-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
I am not sure what is the minimal reproduction for this, as I got it in a very edgy case. The minimal case I managed to reproduced is presented in the sample code below, and can be reproduced both on master and stable. It can be reproduced on DartPad.
It does not have to be unmodified for the bug to happen. Actually, the first time I produced it I was trying to halve the constraints, so I though I messed something in the constraints, but the unmodified makes it clear that it is something with the widget.
I can make it work by either removing ConstraintsTransformBox or by passing a non-zero width to the widget.
Expected results
As the ConstraintsTransformBox does not changes the constraints, the rendered widget should be exactly the same as if there was no ConstraintsTransformBox.
Actual results
The child becomes invisible, while removing the ConstraintsTransformBox makes it visible again.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 24.0),
child: ConstraintsTransformBox( // Remove this widget to get it working
constraintsTransform: ConstraintsTransformBox.unmodified,
child: const VerticalLine(),
),
),
),
),
);
}
}
final class VerticalLine extends StatelessWidget {
const VerticalLine({super.key});
@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _VerticalLinePainter(),
size: Size.fromWidth(0.0),
);
}
}
final class _VerticalLinePainter extends CustomPainter {
const _VerticalLinePainter();
@override
void paint(Canvas canvas, Size size) {
final path = Path();
path.moveTo(size.width / 2.0, 0.0);
path.lineTo(size.width / 2.0, size.height);
final paint = Paint()
..color = const Color(0xFFFF0000)
..strokeWidth = 1.0
..style = PaintingStyle.stroke;
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(_VerticalLinePainter oldDelegate) => false;
}
Screenshots or Video
Logs
No response
Flutter Doctor output
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-x64, locale
en-BR)
• Flutter version 3.19.5 on channel stable at
/Users/pintome/.puro/envs/btg/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/pintome/Library/Android
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/pintome/Library/Android/
• Java binary at: /Users/pintome/Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
! CocoaPods 1.12.1 out of date (1.13.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin
code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade see
https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
for instructions.
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.2)
• Android Studio at /Users/pintome/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
17.0.9+0-17.0.9b1087.7-11185874)
[✓] Connected device (3 available)
• M2004J19C (mobile) • 8cf012db0406 • android-arm64 • Android 12 (API 31)
• macOS (desktop) • macos • darwin-x64 • macOS 14.4.1 23E224
darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome
123.0.6312.124
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.

