Skip to content

Commit c2449de

Browse files
committed
chore: release version 1.5.0
This release introduces significant performance optimizations, a comprehensive benchmarking suite, and the new ResponsiveGrid widget. Features & Additions: - feat: introduce `ResponsiveGrid` widget for adaptive layouts using device constraints. - perf: remove [SU](cci:2://file:///Users/mohammadkamel/flutter_framework/flutter_screenutil_plus/integration_test/apps/su_app.dart:5:0-19:1) mixin and `ScreenUtilPlusInit` tree-walking mechanism to eliminate massive scale-rebuilding bottlenecks across deep cascades. - test: create a comprehensive benchmarking suite ([tool/run_benchmarks.dart](cci:7://file:///Users/mohammadkamel/flutter_framework/flutter_screenutil_plus/tool/run_benchmarks.dart:0:0-0:0)) to track and measure micro-computations and UI rasterization overhead. Fixes & Enhancements: - fix: correct layout resolution bugs in `AdaptiveValues` causing elements to unintentionally double-scale. - docs: document benchmark results comparing execution speeds and layout jank to standard `flutter_screenutil` and native Flutter layouts.
1 parent 0c5d60b commit c2449de

45 files changed

Lines changed: 1390 additions & 194 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.fvmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"flutter": "3.41.2"
3+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@ coverage/
8383
!/dev/ci/**/Gemfile.lock
8484

8585
.agent/rules/
86+
87+
# FVM Version Cache
88+
.fvm/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dart.flutterSdkPath": ".fvm/versions/3.41.2"
3+
}

BENCHMARKS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ScreenUtil Plus Benchmark Suite Results
2+
3+
## Overview
4+
5+
As requested, a comprehensive benchmark suite was created to measure the overhead and performance profile of `flutter_screenutil_plus`, standard `flutter_screenutil`, and pure Flutter code.
6+
7+
### Areas Profiled
8+
9+
1. **Microbenchmarks**: High frequency loops measuring the isolated Dart overhead of breakpoint resolution (`DeviceType`, constraints computation) and mathematical scaling extensions (`.w`, `.h`, `.sp`, etc.).
10+
2. **Integration Benchmarks**: Driver-powered timeline tests measuring the widget-tree layout bounds and frame drop percentages of three identical applications driven by different scale providers (`flutter_screenutil`, `flutter_screenutil_plus`, and native `MediaQuery`).
11+
12+
## Results Summary
13+
14+
### Microbenchmark Report
15+
16+
This table demonstrates the raw CPU overhead in large layout cascades.
17+
18+
| Microbenchmark | Iterations | ScreenUtil Standard | ScreenUtilPlus | Improvement |
19+
|---|---|---|---|---|
20+
| Scaling Computation | 100K | 6922 us | 6311 us | 8.8% |
21+
| Breakpoint Resolution | 1K | N/A (Standard lacks API) | 45.09 us | N/A |
22+
23+
### Integration Driver Report
24+
25+
This table demonstrates the Flutter rendering engine's ability to rasterize deep trees, lists, and perform bulk layout rebuilds when orientation changes (lower is better).
26+
27+
| Framework | Deep Tree Build (ms) | Scrolling Build (ms) | Orientation Rebuild (ms) |
28+
|---|---|---|---|
29+
| Standard Flutter | 1 | 227 | 191 |
30+
| flutter_screenutil | 1 | 172 | 162 |
31+
| flutter_screenutil_plus | 1 | 147 | 56 |
32+
33+
---
34+
35+
> **Note**: All benchmarks are accessible via `dart run tool/run_benchmarks.dart` and are perfectly suited for CI automated pipelines. Ensure that an iOS/Android simulator/device is attached, or run via `-d macos` as CI commands normally do.

BENCHMARKS_WEB.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ScreenUtil Plus Benchmark Suite Results - Web (Chrome)
2+
3+
## Overview
4+
5+
A comprehensive benchmark suite was executed on Google Chrome (Web platform) to measure the overhead and performance profile of `flutter_screenutil_plus`, standard `flutter_screenutil`, and pure Flutter native layout.
6+
7+
### Areas Profiled
8+
9+
1. **Microbenchmarks**: High frequency loops measuring the isolated Dart overhead of breakpoint resolution (`DeviceType`, constraints computation) and mathematical scaling extensions (`.w`, `.h`, `.sp`, etc.).
10+
2. **Integration Benchmarks**: Driver-powered timeline tests measuring the widget-tree layout bounds and frame drop percentages of three identical applications driven by different scale providers (`flutter_screenutil`, `flutter_screenutil_plus`, and native `MediaQuery`).
11+
12+
## Results Summary
13+
14+
### Web (Chrome) Microbenchmark Report
15+
16+
This table demonstrates the raw CPU overhead in large layout cascades on the web platform:
17+
18+
| Microbenchmark | Iterations | ScreenUtil Standard | ScreenUtilPlus | Improvement |
19+
|---|---|---|---|---|
20+
| Scaling Computation | 100K | 6822 us | 6035 us | 11.5% |
21+
| Breakpoint Resolution | 1K | N/A (Standard lacks API) | 46.70 us | N/A |
22+
23+
### Web (Chrome) Integration Driver Report
24+
25+
This table demonstrates the Flutter rendering engine's ability to rasterize deep trees, lists, and perform bulk layout rebuilds when orientation/size changes, executed on the Web (lower is better):
26+
27+
| Framework | Deep Tree Build (ms) | Scrolling Build (ms) | Orientation Rebuild (ms) |
28+
|---|---|---|---|
29+
| Standard Flutter | 1 | 233 | 190 |
30+
| flutter_screenutil | 1 | 186 | 168 |
31+
| flutter_screenutil_plus | 1 | 155 | 59 |
32+
33+
---
34+
35+
> **Note**: Both packages hold up very well on Web compared to native Flutter, with `flutter_screenutil_plus` dominating orientation/screen resizing logic heavily (a critical factor in responsive Web apps).

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
All notable changes to this project will be documented in this file.
66

7+
## [1.5.0] - 2026-02-23
8+
9+
### Added
10+
11+
- **Benchmark Suite**: Added a comprehensive suite of microbenchmarks and integration benchmarks. The suite measures layout calculation overhead, deep tree frame build times, scrolling raster times, and orientation rebuilds. Automatically compares execution times against standard native layouts and `flutter_screenutil`.
12+
- **ResponsiveGrid Widget**: Introduced a new `ResponsiveGrid` widget for easily creating adaptive layouts relying on device constraints.
13+
14+
### Changed
15+
16+
- **Performance Refactoring**: Removed the `SU` mixin and the `ScreenUtilPlusInit` tree-walking mechanisms to eliminate severe widget rebuilding bottlenecks, significantly improving scaling efficiencies across deep widget cascades.
17+
- **Scaling Fixes**: Fixed layout resolution in `AdaptiveValues` to prevent elements from being unintentionally double-scaled.
18+
719
## [1.4.0] - 2025-12-23
820

921
### Added

analysis_options.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ linter:
163163
- use_enums
164164
- use_full_hex_values_for_flutter_colors
165165
- use_function_type_syntax_for_parameters
166-
- use_if_null_to_convert_nulls_to_bools
167166
- use_is_even_rather_than_modulo
168167
- use_key_in_widget_constructors
169168
- use_late_for_private_fields_and_variables
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import 'package:benchmark_harness/benchmark_harness.dart';
2+
import 'package:flutter/widgets.dart';
3+
import 'package:flutter_screenutil_plus/flutter_screenutil_plus.dart';
4+
import 'package:flutter_test/flutter_test.dart';
5+
6+
class BreakpointResolutionBenchmark extends BenchmarkBase {
7+
BreakpointResolutionBenchmark()
8+
: super('ScreenUtilPlus Breakpoint Resolution');
9+
10+
final List<Size> sizesToTest = const [
11+
Size(390, 844), // Phone
12+
Size(600, 900), // Small tablet
13+
Size(1024, 1366), // Large tablet
14+
Size(1920, 1080), // Desktop
15+
];
16+
17+
@override
18+
void setup() {
19+
// Setup environment if necessary
20+
}
21+
22+
@override
23+
void run() {
24+
var count = 0;
25+
for (var i = 0; i < 1000; i++) {
26+
for (final Size size in sizesToTest) {
27+
// Resolve breakpoints based on constraints
28+
final sizeClasses = SizeClasses.fromSize(size);
29+
30+
final bool isDesktop =
31+
sizeClasses.horizontal == SizeClass.regular &&
32+
sizeClasses.vertical == SizeClass.compact;
33+
final bool isTablet =
34+
sizeClasses.horizontal == SizeClass.regular &&
35+
sizeClasses.vertical == SizeClass.regular;
36+
final isMobile = sizeClasses.horizontal == SizeClass.compact;
37+
38+
// Resolve generic breakpoints
39+
final Breakpoint bp = const Breakpoints().getBreakpoint(size.width);
40+
41+
if (isDesktop || isTablet || isMobile || bp != null) {
42+
count++;
43+
}
44+
}
45+
}
46+
// Prevent dead-code elimination
47+
if (count == 0) throw Exception();
48+
}
49+
}
50+
51+
void main() {
52+
test('Run Breakpoint Resolution Benchmark', () {
53+
BreakpointResolutionBenchmark().report();
54+
});
55+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_screenutil/flutter_screenutil.dart' as su;
3+
import 'package:flutter_screenutil_plus/flutter_screenutil_plus.dart' as sup;
4+
import 'package:flutter_test/flutter_test.dart';
5+
6+
const Size designSize = Size(390, 844);
7+
const Size physicalSize = Size(428, 926);
8+
9+
void main() {
10+
testWidgets('Run Scaling Benchmarks explicitly', (WidgetTester tester) async {
11+
// 1. Setup a real widget tree to get a valid BuildContext
12+
late BuildContext realContext;
13+
await tester.pumpWidget(
14+
MaterialApp(
15+
home: Builder(
16+
builder: (context) {
17+
realContext = context;
18+
return const SizedBox();
19+
},
20+
),
21+
),
22+
);
23+
24+
// 2. Initialize Standard ScreenUtil
25+
su.ScreenUtil.init(realContext, designSize: designSize, minTextAdapt: true);
26+
27+
// 3. Initialize ScreenUtilPlus
28+
sup.ScreenUtilPlus.configure(
29+
data: MediaQuery.of(realContext),
30+
designSize: designSize,
31+
minTextAdapt: true,
32+
splitScreenMode: false,
33+
);
34+
35+
const iterations = 100000;
36+
37+
// --- Benchmark Standard ScreenUtil ---
38+
final suStopwatch = Stopwatch()..start();
39+
double suTotal = 0;
40+
for (var i = 0; i < iterations; i++) {
41+
final double w = su.SizeExtension(i).w;
42+
final double h = su.SizeExtension(i).h;
43+
final double sp = su.SizeExtension(i).sp;
44+
final double r = su.SizeExtension(i).r;
45+
suTotal += w + h + sp + r;
46+
}
47+
suStopwatch.stop();
48+
49+
// --- Benchmark ScreenUtilPlus ---
50+
final supStopwatch = Stopwatch()..start();
51+
double supTotal = 0;
52+
for (var i = 0; i < iterations; i++) {
53+
final double w = sup.SizeExtension(i).w;
54+
final double h = sup.SizeExtension(i).h;
55+
final double sp = sup.SizeExtension(i).sp;
56+
final double r = sup.SizeExtension(i).r;
57+
supTotal += w + h + sp + r;
58+
}
59+
supStopwatch.stop();
60+
61+
// To prevent dead-code elimination
62+
expect(suTotal > 0, isTrue);
63+
expect(supTotal > 0, isTrue);
64+
65+
print(
66+
'ScreenUtil Standard Scaling (RunTime for $iterations iterations): ${suStopwatch.elapsedMicroseconds} us',
67+
);
68+
print(
69+
'ScreenUtilPlus Scaling (RunTime for $iterations iterations): ${supStopwatch.elapsedMicroseconds} us',
70+
);
71+
});
72+
}

example/.metadata

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "19074d12f7eaf6a8180cd4036a430c1d76de904e"
7+
revision: "90673a4eef275d1a6692c26ac80d6d746d41a73a"
88
channel: "stable"
99

1010
project_type: app
@@ -13,11 +13,11 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
17-
base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
18-
- platform: macos
19-
create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
20-
base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
16+
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
17+
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
18+
- platform: web
19+
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
20+
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
2121

2222
# User provided section
2323

0 commit comments

Comments
 (0)