Skip to content

Commit 6b73b9e

Browse files
committed
Convert extension type to regular class
1 parent 6c6cd19 commit 6b73b9e

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

packages/core/lib/src/widgets/html_flex.dart

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,17 @@ class HtmlFlex extends MultiChildRenderObjectWidget {
171171
}
172172
}
173173

174-
extension type const _AxisSize._(Size _size) {
174+
class _AxisSize {
175+
final Size _size;
176+
175177
_AxisSize({required double mainAxisExtent, required double crossAxisExtent})
176-
: this._(Size(mainAxisExtent, crossAxisExtent));
177-
_AxisSize.fromSize({required Size size, required Axis direction})
178-
: this._(_convert(size, direction));
178+
: _size = Size(mainAxisExtent, crossAxisExtent);
179+
180+
const _AxisSize._(this._size);
181+
182+
factory _AxisSize.fromSize({required Size size, required Axis direction}) {
183+
return _AxisSize._(_convert(size, direction));
184+
}
179185

180186
static const _AxisSize empty = _AxisSize._(Size.zero);
181187

@@ -207,8 +213,11 @@ extension type const _AxisSize._(Size _size) {
207213
);
208214
}
209215

210-
extension type const _AscentDescent._(
211-
(double ascent, double descent)? ascentDescent) {
216+
typedef _AscentDescentValue = (double ascent, double descent);
217+
218+
class _AscentDescent {
219+
final _AscentDescentValue? _value;
220+
212221
factory _AscentDescent({
213222
required double? baselineOffset,
214223
required double crossSize,
@@ -217,12 +226,17 @@ extension type const _AscentDescent._(
217226
? none
218227
: _AscentDescent._((baselineOffset, crossSize - baselineOffset));
219228
}
229+
230+
const _AscentDescent._(this._value);
231+
220232
static const _AscentDescent none = _AscentDescent._(null);
221233

222-
double? get baselineOffset => ascentDescent?.$1;
234+
double? get baselineOffset => _value?.$1;
223235

224-
_AscentDescent operator +(_AscentDescent other) => switch ((this, other)) {
225-
(null, final _AscentDescent v) || (final _AscentDescent v, null) => v,
236+
_AscentDescent operator +(_AscentDescent other) =>
237+
switch ((_value, other._value)) {
238+
(final _AscentDescentValue? _, null) => this,
239+
(null, final _AscentDescentValue? _) => other,
226240
(
227241
(final double xAscent, final double xDescent),
228242
(final double yAscent, final double yDescent),
@@ -1006,7 +1020,7 @@ class RenderHtmlFlex extends RenderBox
10061020
}
10071021
assert(totalFlex == 0);
10081022

1009-
accumulatedSize += switch (accumulatedAscentDescent) {
1023+
accumulatedSize += switch (accumulatedAscentDescent._value) {
10101024
null => _AxisSize.empty,
10111025
(final double ascent, final double descent) => _AxisSize(
10121026
mainAxisExtent: 0,

packages/core/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ description: Flutter package to render html as widgets that focuses on correctne
44
homepage: https://github.com/daohoangson/flutter_widget_from_html/tree/master/packages/core
55

66
environment:
7-
flutter: ">=3.19.0"
8-
sdk: ">=3.3.0 <4.0.0"
7+
flutter: ">=3.10.0"
8+
sdk: ">=3.0.0 <4.0.0"
99

1010
dependencies:
1111
csslib: ">=0.17.0 <2.0.0"

0 commit comments

Comments
 (0)