-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Create a
MaxColumnWidthorMinColumnWidthwitha: FlexColumnWidth(1.0)andb: FixedColumnWidth(100) - See the return of
.flex([])
The flex() function of both MaxColumnWidth and MinColumnWidth will ignore aFlex when bFlex is null, which will cause unexpected results. For example, MaxColumnWidth(a, b) and MaxColumnWidth(b, a) have different outputs.
flutter/packages/flutter/lib/src/rendering/table.dart
Lines 263 to 274 in 0ff68b8
| @override | |
| double? flex(Iterable<RenderBox> cells) { | |
| final double? aFlex = a.flex(cells); | |
| if (aFlex == null) { | |
| return b.flex(cells); | |
| } | |
| final double? bFlex = b.flex(cells); | |
| if (bFlex == null) { | |
| return null; | |
| } | |
| return math.max(aFlex, bFlex); | |
| } |
flutter/packages/flutter/lib/src/rendering/table.dart
Lines 316 to 327 in 0ff68b8
| @override | |
| double? flex(Iterable<RenderBox> cells) { | |
| final double? aFlex = a.flex(cells); | |
| if (aFlex == null) { | |
| return b.flex(cells); | |
| } | |
| final double? bFlex = b.flex(cells); | |
| if (bFlex == null) { | |
| return null; | |
| } | |
| return math.min(aFlex, bFlex); | |
| } |
Expected results
1.0 as a is a FlexColumnWIdth
Actual results
null
Code sample
Code sample
import 'package:flutter/rendering.dart';
void main() {
const width = MaxColumnWidth(
FlexColumnWidth(1.0),
FixedColumnWidth(100),
);
print('${width.flex([])}');
}Flutter code sample
import 'package:flutter/material.dart';
/// Flutter code sample for [Table].
void main() => runApp(const TableExampleApp());
class TableExampleApp extends StatelessWidget {
const TableExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Table Sample')),
body: const Column(children: [
TableExample(
width: MaxColumnWidth(
FlexColumnWidth(),
FixedColumnWidth(100),
),
),
Divider(),
TableExample(
width: MaxColumnWidth(
FixedColumnWidth(100),
FlexColumnWidth(),
),
),
]),
),
);
}
}
class TableExample extends StatelessWidget {
const TableExample({
super.key,
required this.width,
});
final TableColumnWidth width;
@override
Widget build(BuildContext context) {
return Table(
columnWidths: {
0: width,
1: const FixedColumnWidth(120),
},
children: [
TableRow(children: [
Container(
height: 64,
color: Colors.green,
),
Container(
height: 64,
color: Colors.red,
)
]),
],
);
}
}
Screenshots or Video
No response
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.2.1 22D68 darwin-arm64, locale en-HK)
• Flutter version 3.10.6 on channel stable at /Users/xxx/Development/sdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f468f3366c (2 weeks ago), 2023-07-12 15:19:05 -0700
• Engine revision cdbeda788a
• Dart version 3.0.6
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/xxx/Library/Android/sdk
• Platform android-33, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• Android Studio at /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 11.0.15+0-b2043.56-8887301)
[✓] VS Code (version 1.80.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.68.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.2.1 22D68 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.126
[✓] Network resources
• All expected network resources are available.
• No issues found!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.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team