-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Description
When the use_swt_fonts flag is enabled, the computed sizes (computeSize) of some widgets (e.g., Button and Link) are incorrect.
The use_swt_fonts flag determines whether the widget uses:
- The font and foreground color provided by Java (SWT), or
- The font rendered by Flutter
In the reported case (use_swt_fonts = true), the size calculation does not match the expected values.
Technical Context
Sizes are calculated in Sizes.java.
For Button and Link, the computeSize() method is auto-generated.
The generation flow is the following:
- Classes to be generated are added in
measure.dart. - The
GenerateAlltask is executed. This generates:WidgetSizeTest.javameasure_widget.dart- Other supporting files.
- The following command is executed:
flutter run -d windows -t tool/measure_widget.dart
NOTE: (Replace windows with the corresponding OS.)
This generates the constants used to approximate computeSize(). Although the measurement is performed using Flutter code, additional heuristics are applied to estimate the final size.
- Finally,
widgetSizes.javais generated.
Validation
WidgetSizeTest.java contains the tests that validate whether widgetSizes.java was generated correctly.
These tests:
- Measure the widget in Java
- Measure the widget in Flutter
- Compare both results across different scenarios
Covered scenarios include:
- Minimum size (widget occupies the smallest possible space)
- Respecting bounds
- Bold/italic font cases
flutter_should_equal_javacomparison cases
All these tests must pass, as they ensure widgetSizes.java is correctly aligned with both Java and Flutter measurements.
Expected Behavior
- When
use_swt_fonts = true,computeSize()should: - Correctly reflect Java (SWT) font metrics.
- Pass all
WidgetSizeTesttests. - Maintain consistency between Java and Flutter measurements in the flutter_should_equal_java scenarios.