浏览代码

Remove all (float) and replace Math with Mathf.

/main
Yuncong Zhang 6 年前
当前提交
d821002b
共有 140 个文件被更改,包括 1173 次插入1155 次删除
  1. 1
      Editor/editor/EditorUtils.cs
  2. 2
      Runtime/animation/animation.cs
  3. 6
      Runtime/animation/animation_controller.cs
  4. 51
      Runtime/animation/animations.cs
  5. 28
      Runtime/animation/curves.cs
  6. 6
      Runtime/animation/tween.cs
  7. 4
      Runtime/async/coroutine.cs
  8. 12
      Runtime/async/timer.cs
  9. 2
      Runtime/debugger/inpsector_panel.cs
  10. 8
      Runtime/editor/editor_window.cs
  11. 8
      Runtime/editor/scroll_input.cs
  12. 16
      Runtime/editor/surface.cs
  13. 17
      Runtime/engine/DisplayMetrics.cs
  14. 9
      Runtime/engine/WidgetCanvas.cs
  15. 4
      Runtime/flow/layer_tree.cs
  16. 4
      Runtime/flow/picture_layer.cs
  17. 10
      Runtime/flow/raster_cache.cs
  18. 6
      Runtime/foundation/debug.cs
  19. 20
      Runtime/foundation/diagnostics.cs
  20. 6
      Runtime/gestures/constants.cs
  21. 4
      Runtime/gestures/drag_details.cs
  22. 22
      Runtime/gestures/lsq_resolver.cs
  23. 29
      Runtime/gestures/monodrag.cs
  24. 50
      Runtime/gestures/multitap.cs
  25. 2
      Runtime/gestures/recognizer.cs
  26. 11
      Runtime/gestures/velocity_tracker.cs
  27. 42
      Runtime/material/arc.cs
  28. 14
      Runtime/material/button.cs
  29. 36
      Runtime/material/button_theme.cs
  30. 6
      Runtime/material/card.cs
  31. 2
      Runtime/material/color_scheme.cs
  32. 8
      Runtime/material/constants.cs
  33. 15
      Runtime/material/drawer.cs
  34. 7
      Runtime/material/expand_icon.cs
  35. 6
      Runtime/material/icon_button.cs
  36. 2
      Runtime/material/ink_ripple.cs
  37. 6
      Runtime/material/ink_splash.cs
  38. 26
      Runtime/material/ink_well.cs
  39. 62
      Runtime/material/list_tile.cs
  40. 22
      Runtime/material/material.cs
  41. 6
      Runtime/material/material_button.cs
  42. 2
      Runtime/material/mergeable_material.cs
  43. 6
      Runtime/material/raised_button.cs
  44. 2
      Runtime/material/scrollbar.cs
  45. 22
      Runtime/material/text_selection.cs
  46. 8
      Runtime/material/theme_data.cs
  47. 10
      Runtime/material/tooltip.cs
  48. 26
      Runtime/material/utils.cs
  49. 84
      Runtime/painting/alignment.cs
  50. 35
      Runtime/painting/beveled_rectangle_border.cs
  51. 24
      Runtime/painting/borders.cs
  52. 6
      Runtime/painting/box_border.cs
  53. 10
      Runtime/painting/box_decoration.cs
  54. 13
      Runtime/painting/box_fit.cs
  55. 10
      Runtime/painting/box_shadow.cs
  56. 7
      Runtime/painting/circle_border.cs
  57. 10
      Runtime/painting/decoration_image.cs
  58. 23
      Runtime/painting/geometry.cs
  59. 93
      Runtime/painting/gradient.cs
  60. 6
      Runtime/painting/image_provider.cs
  61. 2
      Runtime/painting/image_resolution.cs
  62. 12
      Runtime/painting/rounded_rectangle_border.cs
  63. 52
      Runtime/painting/stadium_border.cs
  64. 10
      Runtime/painting/text_painter.cs
  65. 2
      Runtime/painting/text_span.cs
  66. 8
      Runtime/painting/text_style.cs
  67. 11
      Runtime/physics/friction_simulation.cs
  68. 101
      Runtime/physics/spring_simulation.cs
  69. 6
      Runtime/physics/utils.cs
  70. 4
      Runtime/rendering/animated_size.cs
  71. 81
      Runtime/rendering/box.cs
  72. 3
      Runtime/rendering/box.mixin.gen.cs
  73. 3
      Runtime/rendering/box.mixin.njk
  74. 8
      Runtime/rendering/custom_layout.cs
  75. 2
      Runtime/rendering/custom_paint.cs
  76. 54
      Runtime/rendering/editable.cs
  77. 127
      Runtime/rendering/flex.cs
  78. 18
      Runtime/rendering/image.cs
  79. 12
      Runtime/rendering/layer.cs
  80. 27
      Runtime/rendering/list_body.cs
  81. 4
      Runtime/rendering/object.cs
  82. 6
      Runtime/rendering/paragraph.cs
  83. 92
      Runtime/rendering/proxy_box.cs
  84. 61
      Runtime/rendering/shifted_box.cs
  85. 157
      Runtime/rendering/sliver.cs
  86. 6
      Runtime/rendering/sliver_fill.cs
  87. 15
      Runtime/rendering/sliver_fixed_extent_list.cs
  88. 4
      Runtime/rendering/sliver_list.cs
  89. 2
      Runtime/rendering/sliver_multi_box_adaptor.cs
  90. 34
      Runtime/rendering/sliver_padding.cs
  91. 24
      Runtime/rendering/stack.cs
  92. 2
      Runtime/rendering/view.cs
  93. 96
      Runtime/rendering/viewport.cs
  94. 4
      Runtime/scheduler/binding.cs
  95. 14
      Runtime/service/text_input.cs
  96. 115
      Runtime/ui/geometry.cs
  97. 58
      Runtime/ui/matrix.cs
  98. 4
      Runtime/ui/painting/canvas.cs
  99. 12
      Runtime/ui/painting/canvas_clip.cs
  100. 80
      Runtime/ui/painting/canvas_impl.cs

1
Editor/editor/EditorUtils.cs


using UnityEditor;
namespace Unity.UIWidgets.Editor {
[InitializeOnLoad]
public class Startup {
static Startup() {

2
Runtime/animation/animation.cs


}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<double>);
D.assert(this is Animation<float>);
return child.animate(this as Animation<float>);
}
}

6
Runtime/animation/animation_controller.cs


}
static readonly SpringDescription _kFlingSpringDescription = SpringDescription.withDampingRatio(
mass: 1.0,
stiffness: 500.0,
ratio: 1.0
mass: 1.0f,
stiffness: 500.0f,
ratio: 1.0f
);
static readonly Tolerance _kFlingTolerance = new Tolerance(

51
Runtime/animation/animations.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.animation {
class _AlwaysCompleteAnimation : Animation<float> {

}
public class ReverseAnimation : AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<double> {
public ReverseAnimation(Animation<double> parent) {
public class ReverseAnimation : AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<float> {
public ReverseAnimation(Animation<float> parent) {
public Animation<double> parent {
public Animation<float> parent {
readonly Animation<double> _parent;
readonly Animation<float> _parent;
public override void addListener(VoidCallback listener) {
this.didRegisterListener();

get { return this._reverseStatus(this.parent.status); }
}
public override double value {
get { return 1.0 - this.parent.value; }
public override float value {
get { return 1.0f - this.parent.value; }
}
AnimationStatus _reverseStatus(AnimationStatus status) {

if (t == 0.0 || t == 1.0) {
D.assert(() => {
double transformedValue = activeCurve.transform(t);
double roundedTransformedValue = transformedValue.round();
float transformedValue = activeCurve.transform(t);
float roundedTransformedValue = transformedValue.round();
if (roundedTransformedValue != t) {
throw new UIWidgetsError(
string.Format(

get { return this._currentTrain.status; }
}
double? _lastValue;
float? _lastValue;
void _valueChangeHandler() {
D.assert(this._currentTrain != null);

}
}
double newValue = this.value;
float newValue = this.value;
if (newValue != this._lastValue) {
this.notifyListeners();
this._lastValue = newValue;

}
}
public class AnimationMean : CompoundAnimation<double> {
public class AnimationMean : CompoundAnimation<float> {
Animation<double> left = null,
Animation<double> right = null
Animation<float> left = null,
Animation<float> right = null
public override double value {
get { return (this.first.value + this.next.value) / 2.0; }
public override float value {
get { return (this.first.value + this.next.value) / 2.0f; }
public class AnimationMax : CompoundAnimation<double> {
public class AnimationMax : CompoundAnimation<float> {
Animation<double> left = null,
Animation<double> right = null
Animation<float> left = null,
Animation<float> right = null
public override double value {
get { return Math.Max(this.first.value, this.next.value); }
public override float value {
get { return Mathf.Max(this.first.value, this.next.value); }
public class AnimationMin : CompoundAnimation<double> {
public class AnimationMin : CompoundAnimation<float> {
Animation<double> left = null,
Animation<double> right = null
Animation<float> left = null,
Animation<float> right = null
public override double value {
get { return Math.Min(this.first.value, this.next.value); }
public override float value {
get { return Mathf.Min(this.first.value, this.next.value); }
}
}

28
Runtime/animation/curves.cs


using System;
using UnityEngine;
namespace Unity.UIWidgets.animation {
public abstract class Curve {

}
public class Threshold : Curve {
public Threshold(double threshold) {
public Threshold(float threshold) {
public readonly double threshold;
public readonly float threshold;
public override float transform(float t) {
D.assert(t >= 0.0 && t <= 1.0);

D.assert(t >= 0.0 && t <= 1.0);
float s = this.period / 4.0f;
t = t - 1.0f;
return (float) (-Math.Pow(2.0, 10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period));
return -Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period);
}
public override string ToString() {

public class ElasticOutCurve : Curve {
public ElasticOutCurve(double period = 0.4) {
public ElasticOutCurve(float period = 0.4f) {
public readonly double period;
public readonly float period;
double s = this.period / 4.0;
return (float) (Math.Pow(2.0, -10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period) + 1.0);
float s = this.period / 4.0f;
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period) + 1.0f;
}
public override string ToString() {

public class ElasticInOutCurve : Curve {
public ElasticInOutCurve(double period = 0.4) {
public ElasticInOutCurve(float period = 0.4f) {
public readonly double period;
public readonly float period;
double s = this.period / 4.0f;
float s = this.period / 4.0f;
return (float) (-0.5 * Math.Pow(2.0f, 10.0f * t) * Math.Sin((t - s) * (Math.PI * 2.0f) / this.period));
return -0.5f * Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period);
return (float) (Math.Pow(2.0f, -10.0f * t) * Math.Sin((t - s) * (Math.PI * 2.0f) / this.period) * 0.5f +
1.0f);
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period) * 0.5f +
1.0f;
}
}

6
Runtime/animation/tween.cs


}
}
public class DoubleTween : Tween<double> {
public DoubleTween(double begin, double end) : base(begin: begin, end: end) {
public class floatTween : Tween<float> {
public floatTween(float begin, float end) : base(begin: begin, end: end) {
public override double lerp(float t) {
public override float lerp(float t) {
return this.begin + (this.end - this.begin) * t;
}
}

4
Runtime/async/coroutine.cs


struct _WaitForSecondsProcessor {
UIWidgetsWaitForSeconds _current;
double _targetTime;
float _targetTime;
public void set(UIWidgetsWaitForSeconds yieldStatement) {
if (this._current != yieldStatement) {

}
public class UIWidgetsWaitForSeconds {
public double waitTime { get; }
public float waitTime { get; }
public UIWidgetsWaitForSeconds(float time) {
this.waitTime = time;

12
Runtime/async/timer.cs


this.cancel();
}
public static double timeSinceStartup {
public static float timeSinceStartup {
return EditorApplication.timeSinceStartup;
return (float) EditorApplication.timeSinceStartup;
#else
return Time.realtimeSinceStartup;
#endif

}
class TimerImpl : Timer, IComparable<TimerImpl> {
double _deadline;
float _deadline;
readonly Action _callback;
bool _done;

public TimerImpl(TimeSpan duration, Action callback, bool periodic = false) {
this._deadline = timeSinceStartup + duration.TotalSeconds;
this._deadline = timeSinceStartup + (float) duration.TotalSeconds;
this._callback = callback;
this._done = false;

this._done = false;
}
public double deadline {
public float deadline {
get { return this._deadline; }
}

}
if (this.periodic) {
this._deadline = now + this._interval.TotalSeconds;
this._deadline = now + (float) this._interval.TotalSeconds;
}
}

2
Runtime/debugger/inpsector_panel.cs


EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
// splitter
this.m_SplitOffset = Math.Max(0, this.m_SplitOffset);
this.m_SplitOffset = Mathf.Max(0, this.m_SplitOffset);
var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true),
GUILayout.Height(this.m_SplitOffset));
this.m_TreeView.OnGUI(rect);

8
Runtime/editor/editor_window.cs


);
}
else if (evt.type == EventType.ScrollWheel) {
this._scrollInput.onScroll((float) (-evt.delta.x * this._devicePixelRatio),
(float) (-evt.delta.y * this._devicePixelRatio),
(float) (evt.mousePosition.x * this._devicePixelRatio),
(float) (evt.mousePosition.y * this._devicePixelRatio),
this._scrollInput.onScroll(-evt.delta.x * this._devicePixelRatio,
-evt.delta.y * this._devicePixelRatio,
evt.mousePosition.x * this._devicePixelRatio,
evt.mousePosition.y * this._devicePixelRatio,
evt.button
);
}

8
Runtime/editor/scroll_input.cs


deltaScroll.x = this._curDeltaX;
deltaScroll.y = this._curDeltaY;
this._scrollDeltaX = this._curDeltaX > 0
? Math.Max(0, this._scrollDeltaX - this._curDeltaX)
: Math.Min(0, this._scrollDeltaX - this._curDeltaX);
? Mathf.Max(0, this._scrollDeltaX - this._curDeltaX)
: Mathf.Min(0, this._scrollDeltaX - this._curDeltaX);
? Math.Max(0, this._scrollDeltaY - this._curDeltaY)
: Math.Min(0, this._scrollDeltaY - this._curDeltaY);
? Mathf.Max(0, this._scrollDeltaY - this._curDeltaY)
: Mathf.Min(0, this._scrollDeltaY - this._curDeltaY);
this._bufferIndex--;
}

16
Runtime/editor/surface.cs


}
public interface Surface : IDisposable {
SurfaceFrame acquireFrame(Size size, double devicePixelRatio);
SurfaceFrame acquireFrame(Size size, float devicePixelRatio);
MeshPool getMeshPool();
}

this._drawToTargetFunc = drawToTargetFunc;
}
public SurfaceFrame acquireFrame(Size size, double devicePixelRatio) {
public SurfaceFrame acquireFrame(Size size, float devicePixelRatio) {
this._createOrUpdateRenderTexture(size, devicePixelRatio);
return new SurfaceFrame(this._surface,

this._surface.getCanvas().reset();
var screenRect = new Rect(0, 0,
(float) (this._surface.size.width / this._surface.devicePixelRatio),
(float) (this._surface.size.height / this._surface.devicePixelRatio));
this._surface.size.width / this._surface.devicePixelRatio,
this._surface.size.height / this._surface.devicePixelRatio);
if (this._drawToTargetFunc == null) {
Graphics.DrawTexture(screenRect, this._surface.getRenderTexture(),

return true;
}
void _createOrUpdateRenderTexture(Size size, double devicePixelRatio) {
void _createOrUpdateRenderTexture(Size size, float devicePixelRatio) {
if (this._surface != null
&& this._surface.size == size
&& this._surface.devicePixelRatio == devicePixelRatio

public class GrSurface : IDisposable {
public readonly Size size;
public readonly double devicePixelRatio;
public readonly float devicePixelRatio;
readonly MeshPool _meshPool;

public Canvas getCanvas() {
if (this._canvas == null) {
this._canvas = new CommandBufferCanvas(
this._renderTexture, (float) this.devicePixelRatio, this._meshPool);
this._renderTexture, this.devicePixelRatio, this._meshPool);
public GrSurface(Size size, double devicePixelRatio, MeshPool meshPool) {
public GrSurface(Size size, float devicePixelRatio, MeshPool meshPool) {
this.size = size;
this.devicePixelRatio = devicePixelRatio;

17
Runtime/engine/DisplayMetrics.cs


using System;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Unity.UIWidgets.engine {
public class DisplayMetrics {

return _devicePixelRatio;
}
#if UNITY_ANDROID
#if UNITY_ANDROID
#if UNITY_WEBGL
#if UNITY_WEBGL
#if UNITY_IOS
#if UNITY_IOS
_devicePixelRatio = IOSDeviceSaleFactor();
#endif

return _devicePixelRatio;
}
#if UNITY_ANDROID
#if UNITY_ANDROID
static float AndroidDevicePixelRatio() {
using (
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")

[DllImport("__Internal")]
static extern int IOSDeviceSaleFactor();
#endif
}

9
Runtime/engine/WidgetCanvas.cs


protected override Vector2 queryWindowSize() {
var size = this._widgetCanvas.rectTransform.rect.size;
size = size * this._widgetCanvas.canvas.scaleFactor / (float) this._widgetCanvas.devicePixelRatio;
size = size * this._widgetCanvas.canvas.scaleFactor / this._widgetCanvas.devicePixelRatio;
return new Vector2(Mathf.Round(size.x), Mathf.Round(size.y));
}
}

IPointerEnterHandler, IPointerExitHandler {
static Event _repaintEvent;
[SerializeField]
protected float devicePixelRatioOverride;
[SerializeField] protected float devicePixelRatioOverride;
WindowAdapter _windowAdapter;
Texture _texture;

if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0) {
var scaleFactor = this.canvas.scaleFactor;
var pos = this.getPointPosition(Input.mousePosition);
this._scrollInput.onScroll((float) (Input.mouseScrollDelta.x * scaleFactor),
(float) (Input.mouseScrollDelta.y * scaleFactor),
this._scrollInput.onScroll(Input.mouseScrollDelta.x * scaleFactor,
Input.mouseScrollDelta.y * scaleFactor,
pos.x,
pos.y,
this.getScrollButton());

4
Runtime/flow/layer_tree.cs


set { this._frameSize = value; }
}
double _devicePixelRatio;
float _devicePixelRatio;
public double devicePixelRatio {
public float devicePixelRatio {
get { return this._devicePixelRatio; }
set { this._devicePixelRatio = value; }
}

4
Runtime/flow/picture_layer.cs


public override void preroll(PrerollContext context, Matrix3 matrix) {
if (context.rasterCache != null) {
Matrix3 ctm = new Matrix3(matrix);
ctm.postTranslate((float) this._offset.dx, (float) this._offset.dy);
ctm.postTranslate(this._offset.dx, this._offset.dy);
ctm[2] = ctm[2].alignToPixel(context.devicePixelRatio);
ctm[5] = ctm[5].alignToPixel(context.devicePixelRatio);

var canvas = context.canvas;
canvas.save();
canvas.translate((float) this._offset.dx, (float) this._offset.dy);
canvas.translate(this._offset.dx, this._offset.dy);
// align to pixel
var matrix = canvas.getTotalMatrix();

10
Runtime/flow/raster_cache.cs


var bounds = canvas.getTotalMatrix().mapRect(this.logicalRect);
D.assert(() => {
var textureWidth = Mathf.CeilToInt((float) bounds.width * this.devicePixelRatio);
var textureHeight = Mathf.CeilToInt((float) bounds.height * this.devicePixelRatio);
var textureWidth = Mathf.CeilToInt(bounds.width * this.devicePixelRatio);
var textureHeight = Mathf.CeilToInt(bounds.height * this.devicePixelRatio);
D.assert(this.image.width == textureWidth);
D.assert(this.image.height == textureHeight);

var bounds = transform.mapRect(picture.paintBounds);
var desc = new RenderTextureDescriptor(
Mathf.CeilToInt((float) (bounds.width * devicePixelRatio)),
Mathf.CeilToInt((float) (bounds.height * devicePixelRatio)),
Mathf.CeilToInt((bounds.width * devicePixelRatio)),
Mathf.CeilToInt((bounds.height * devicePixelRatio)),
RenderTextureFormat.Default, 24) {
useMipMap = false,
autoGenerateMips = false,

renderTexture.hideFlags = HideFlags.HideAndDontSave;
var canvas = new CommandBufferCanvas(renderTexture, devicePixelRatio, meshPool);
canvas.translate((float) -bounds.left, (float) -bounds.top);
canvas.translate(-bounds.left, -bounds.top);
canvas.concat(transform);
canvas.drawPicture(picture);
canvas.flush();

6
Runtime/foundation/debug.cs


// public static Color debugCurrentRepaintColor = Color.fromfromAHSV(0.4, 60.0, 1.0, 1.0);;
public static void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {
public static void _debugDrawfloatRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {
// final Path path = new Path()
// ..fillType = PathFillType.evenOdd
// ..addRect(outerRect)

public static void debugPaintPadding(Canvas canvas, Rect outerRect, Rect innerRect, float outlineWidth = 2.0f) {
assert(() => {
if (innerRect != null && !innerRect.isEmpty) {
_debugDrawDoubleRect(canvas, outerRect, innerRect, new Color(0x900090FF));
_debugDrawfloatRect(canvas, outerRect, innerRect, new Color(0x900090FF));
_debugDrawDoubleRect(canvas, innerRect.inflate(outlineWidth).intersect(outerRect), innerRect,
_debugDrawfloatRect(canvas, innerRect.inflate(outlineWidth).intersect(outerRect), innerRect,
new Color(0xFF0090FF));
Paint paint = new Paint();
paint.color = new Color(0x90909090);

20
Runtime/foundation/diagnostics.cs


}
}
public class DoubleProperty : _NumProperty<double?> {
public DoubleProperty(string name, double? value,
public class floatProperty : _NumProperty<float?> {
public floatProperty(string name, float? value,
string ifNull = null,
string unit = null,
string tooltip = null,

) {
}
DoubleProperty(
floatProperty(
ComputePropertyValueCallback<double?> computeValue,
ComputePropertyValueCallback<float?> computeValue,
string ifNull = null,
bool showName = true,
string unit = null,

) {
}
public static DoubleProperty lazy(
public static floatProperty lazy(
ComputePropertyValueCallback<double?> computeValue,
ComputePropertyValueCallback<float?> computeValue,
string ifNull = null,
bool showName = true,
string unit = null,

) {
return new DoubleProperty(
return new floatProperty(
name,
computeValue,
showName: showName,

}
}
public class PercentProperty : DoubleProperty {
public PercentProperty(string name, double fraction,
public class PercentProperty : floatProperty {
public PercentProperty(string name, float fraction,
string ifNull = null,
bool showName = true,
string tooltip = null,

return "null";
}
return (this.value.Value.clamp(0.0, 1.0) * 100).ToString("F1") + "%";
return (this.value.Value.clamp(0.0f, 1.0f) * 100).ToString("F1") + "%";
}
}

6
Runtime/gestures/constants.cs


public static class Constants {
public const float kTouchSlop = 18.0f;
public const float kDoubleTapTouchSlop = kTouchSlop;
public const float kfloatTapTouchSlop = kTouchSlop;
public const float kDoubleTapSlop = 100.0f;
public const float kfloatTapSlop = 100.0f;
public static readonly TimeSpan kDoubleTapTimeout = new TimeSpan(0, 0, 0, 0, 300);
public static readonly TimeSpan kfloatTapTimeout = new TimeSpan(0, 0, 0, 0, 300);
public static readonly TimeSpan kLongPressTimeout = new TimeSpan(0, 0, 0, 0, 500);

4
Runtime/gestures/drag_details.cs


public class DragEndDetails {
public DragEndDetails(
Velocity velocity = null,
double? primaryVelocity = null
float? primaryVelocity = null
) {
this.velocity = velocity ?? Velocity.zero;
this.primaryVelocity = primaryVelocity;

public readonly Velocity velocity;
public readonly double? primaryVelocity;
public readonly float? primaryVelocity;
public override string ToString() {
return this.GetType() + "(" + this.velocity + ")";

22
Runtime/gestures/lsq_resolver.cs


using System;
using UnityEngine;
namespace Unity.UIWidgets.gestures {
class _Vector {

}
public float norm() {
return (float) Math.Sqrt(this * this);
return Mathf.Sqrt(this * this);
}
}

public readonly List<float> coefficients;
public double confidence;
public float confidence;
}
public class LeastSquaresSolver {

}
float norm = q.getRow(j).norm();
if (norm < 0.000001) {
if (norm < 0.000001f) {
// Vectors are linearly dependent or zero so no solution.
return null;
}

// ...where sumSquaredError is the residual sum of squares (variance of the
// error), and sumSquaredTotal is the total sum of squares (variance of the
// data) where each has been weighted.
double yMean = 0.0;
float yMean = 0.0f;
for (int h = 0; h < m; h += 1) {
yMean += this.y[h];
}

double sumSquaredError = 0.0;
double sumSquaredTotal = 0.0;
float sumSquaredError = 0.0f;
float sumSquaredTotal = 0.0f;
double term = 1.0;
double err = this.y[h] - result.coefficients[0];
float term = 1.0f;
float err = this.y[h] - result.coefficients[0];
for (int i = 1; i < n; i += 1) {
term *= this.x[h];
err -= term * result.coefficients[i];

double v = this.y[h] - yMean;
float v = this.y[h] - yMean;
result.confidence = sumSquaredTotal <= 0.000001 ? 1.0 : 1.0 - (sumSquaredError / sumSquaredTotal);
result.confidence = sumSquaredTotal <= 0.000001f ? 1.0f : 1.0f - (sumSquaredError / sumSquaredTotal);
return result;
}
}

29
Runtime/gestures/monodrag.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.gestures {
enum _DragState {

this.invokeCallback<object>("onEnd", () => {
this.onEnd(new DragEndDetails(
velocity: Velocity.zero,
primaryVelocity: 0.0
primaryVelocity: 0.0f
));
return null;
}, debugReport: () => { return "Pointer scroll end"; }

this.invokeCallback<object>("onEnd", () => {
this.onEnd(new DragEndDetails(
velocity: Velocity.zero,
primaryVelocity: 0.0
primaryVelocity: 0.0f
));
return null;
}, debugReport: () =>

}
protected override bool _isFlingGesture(VelocityEstimate estimate) {
double minVelocity = this.minFlingVelocity ?? Constants.kMinFlingVelocity;
double minDistance = this.minFlingDistance ?? Constants.kTouchSlop;
return Math.Abs(estimate.pixelsPerSecond.dy) > minVelocity && Math.Abs(estimate.offset.dy) > minDistance;
float minVelocity = this.minFlingVelocity ?? Constants.kMinFlingVelocity;
float minDistance = this.minFlingDistance ?? Constants.kTouchSlop;
return Mathf.Abs(estimate.pixelsPerSecond.dy) > minVelocity && Mathf.Abs(estimate.offset.dy) > minDistance;
get { return Math.Abs(this._pendingDragOffset.dy) > Constants.kTouchSlop; }
get { return Mathf.Abs(this._pendingDragOffset.dy) > Constants.kTouchSlop; }
}
protected override Offset _getDeltaForDetails(Offset delta) {

protected override float? _getPrimaryValueFromOffset(Offset value) {
return (float) value.dy;
return value.dy;
}
public override string debugDescription {

}
protected override bool _isFlingGesture(VelocityEstimate estimate) {
double minVelocity = this.minFlingVelocity ?? Constants.kMinFlingVelocity;
double minDistance = this.minFlingDistance ?? Constants.kTouchSlop;
return Math.Abs(estimate.pixelsPerSecond.dx) > minVelocity && Math.Abs(estimate.offset.dx) > minDistance;
float minVelocity = this.minFlingVelocity ?? Constants.kMinFlingVelocity;
float minDistance = this.minFlingDistance ?? Constants.kTouchSlop;
return Mathf.Abs(estimate.pixelsPerSecond.dx) > minVelocity && Mathf.Abs(estimate.offset.dx) > minDistance;
get { return Math.Abs(this._pendingDragOffset.dx) > Constants.kTouchSlop; }
get { return Mathf.Abs(this._pendingDragOffset.dx) > Constants.kTouchSlop; }
}
protected override Offset _getDeltaForDetails(Offset delta) {

protected override float? _getPrimaryValueFromOffset(Offset value) {
return (float) value.dx;
return value.dx;
}
public override string debugDescription {

}
protected override bool _isFlingGesture(VelocityEstimate estimate) {
double minVelocity = this.minFlingVelocity ?? Constants.kMinFlingVelocity;
double minDistance = this.minFlingDistance ?? Constants.kTouchSlop;
float minVelocity = this.minFlingVelocity ?? Constants.kMinFlingVelocity;
float minDistance = this.minFlingDistance ?? Constants.kTouchSlop;
return estimate.pixelsPerSecond.distanceSquared > minVelocity * minVelocity
&& estimate.offset.distanceSquared > minDistance * minDistance;
}

50
Runtime/gestures/multitap.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.gestures {
public delegate void GestureDoubleTapCallback(DoubleTapDetails details);
public delegate void GesturefloatTapCallback(floatTapDetails details);
public class DoubleTapDetails {
public DoubleTapDetails(Offset firstGlobalPosition = null) {
public class floatTapDetails {
public floatTapDetails(Offset firstGlobalPosition = null) {
this.firstGlobalPosition = firstGlobalPosition ?? Offset.zero;
}

}
}
public bool isWithinTolerance(PointerEvent evt, double tolerance) {
public bool isWithinTolerance(PointerEvent evt, float tolerance) {
Offset offset = evt.position - this._initialPosition;
return offset.distance <= tolerance;
}

public class DoubleTapGestureRecognizer : GestureRecognizer {
public DoubleTapGestureRecognizer(object debugOwner = null)
public class floatTapGestureRecognizer : GestureRecognizer {
public floatTapGestureRecognizer(object debugOwner = null)
public GestureDoubleTapCallback onDoubleTap;
public GesturefloatTapCallback onfloatTap;
Timer _doubleTapTimer;
Timer _floatTapTimer;
!this._firstTap.isWithinTolerance(evt, Constants.kDoubleTapSlop)) {
!this._firstTap.isWithinTolerance(evt, Constants.kfloatTapSlop)) {
this._stopDoubleTapTimer();
this._stopfloatTapTimer();
_TapTracker tracker = new _TapTracker(
evt: evt,
entry: GestureBinding.instance.gestureArena.add(evt.pointer, this)

}
}
else if (evt is PointerMoveEvent) {
if (!tracker.isWithinTolerance(evt, Constants.kDoubleTapTouchSlop)) {
if (!tracker.isWithinTolerance(evt, Constants.kfloatTapTouchSlop)) {
this._reject(tracker);
}
}

}
void _reset() {
this._stopDoubleTapTimer();
this._stopfloatTapTimer();
if (this._firstTap != null) {
_TapTracker tracker = this._firstTap;
this._firstTap = null;

}
void _registerFirstTap(_TapTracker tracker) {
this._startDoubleTapTimer();
this._startfloatTapTimer();
GestureBinding.instance.gestureArena.hold(tracker.pointer);
this._freezeTracker(tracker);
this._trackers.Remove(tracker.pointer);

tracker.entry.resolve(GestureDisposition.accepted);
this._freezeTracker(tracker);
this._trackers.Remove(tracker.pointer);
if (this.onDoubleTap != null) {
this.invokeCallback<object>("onDoubleTap", () => {
this.onDoubleTap(new DoubleTapDetails(initialPosition));
if (this.onfloatTap != null) {
this.invokeCallback<object>("onfloatTap", () => {
this.onfloatTap(new floatTapDetails(initialPosition));
return null;
});
}

tracker.stopTrackingPointer(this._handleEvent);
}
void _startDoubleTapTimer() {
this._doubleTapTimer =
this._doubleTapTimer
?? Window.instance.run(Constants.kDoubleTapTimeout, this._reset);
void _startfloatTapTimer() {
this._floatTapTimer =
this._floatTapTimer
?? Window.instance.run(Constants.kfloatTapTimeout, this._reset);
void _stopDoubleTapTimer() {
if (this._doubleTapTimer != null) {
this._doubleTapTimer.cancel();
this._doubleTapTimer = null;
void _stopfloatTapTimer() {
if (this._floatTapTimer != null) {
this._floatTapTimer.cancel();
this._floatTapTimer = null;
get { return "double tap"; }
get { return "float tap"; }
}
}
}

2
Runtime/gestures/recognizer.cs


}
}
double _getDistance(PointerEvent evt) {
float _getDistance(PointerEvent evt) {
Offset offset = evt.position - this.initialPosition;
return offset.distance;
}

11
Runtime/gestures/velocity_tracker.cs


using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.gestures {
public class Velocity : IEquatable<Velocity> {

public Velocity clampMagnitude(float minValue, float maxValue) {
D.assert(minValue >= 0.0);
D.assert(maxValue >= 0.0 && maxValue >= minValue);
double valueSquared = this.pixelsPerSecond.distanceSquared;
float valueSquared = this.pixelsPerSecond.distanceSquared;
if (valueSquared > maxValue * maxValue) {
return new Velocity(pixelsPerSecond: (this.pixelsPerSecond / this.pixelsPerSecond.distance) * maxValue);
}

public class VelocityEstimate {
public VelocityEstimate(
Offset pixelsPerSecond,
double confidence,
float confidence,
TimeSpan duration,
Offset offset
) {

public readonly Offset pixelsPerSecond;
public readonly double confidence;
public readonly float confidence;
public readonly TimeSpan duration;

}
float age = (float) (newestSample.time - sample.time).TotalMilliseconds;
float delta = (float) Math.Abs((sample.time - previousSample.time).TotalMilliseconds);
float delta = Mathf.Abs((float) (sample.time - previousSample.time).TotalMilliseconds);
previousSample = sample;
if (age > _horizonMilliseconds ||
delta > _assumePointerMoveStoppedMilliseconds) {

return new VelocityEstimate(
pixelsPerSecond: Offset.zero,
confidence: 1.0,
confidence: 1.0f,
duration: newestSample.time - oldestSample.time,
offset: newestSample.point - oldestSample.point
);

42
Runtime/material/arc.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.material {
public class MaterialPointArcTween : Tween<Offset> {

Offset c = new Offset(this.end.dx, this.begin.dy);
float sweepAngle() {
return 2.0f * (float) Math.Asin(distanceFromAtoB / (2.0f * this._radius));
return 2.0f * Mathf.Asin(distanceFromAtoB / (2.0f * this._radius));
}
if (deltaX > ArcUtils._kOnAxisDelta && deltaY > ArcUtils._kOnAxisDelta) {

this._endAngle = 0.0f;
}
else {
this._beginAngle = (float) (Math.PI + sweepAngle() * (this.end.dy - this.begin.dy).sign());
this._endAngle = (float) Math.PI;
this._beginAngle = (Mathf.PI + sweepAngle() * (this.end.dy - this.begin.dy).sign());
this._endAngle = Mathf.PI;
}
}
else {

if (this.begin.dy < this.end.dy) {
this._beginAngle = -(float) Math.PI / 2.0f;
this._beginAngle = -Mathf.PI / 2.0f;
this._beginAngle = (float) Math.PI / 2.0f;
this._beginAngle = Mathf.PI / 2.0f;
this._endAngle = this._beginAngle + sweepAngle() * (this.begin.dx - this.end.dx).sign();
}
}

Offset _center;
public double? radius {
public float? radius {
get {
if (this.begin == null || this.end == null) {
return null;

float _radius;
public double? beginAngle {
public float? beginAngle {
get {
if (this.begin == null || this.end == null) {
return null;

float? _beginAngle;
public double? endAngle {
public float? endAngle {
get {
if (this.begin == null || this.end == null) {
return null;

return Offset.lerp(this.begin, this.end, t);
}
double angle = MathUtils.lerpNullableDouble(this._beginAngle, this._endAngle, t) ?? 0.0;
double x = Math.Cos(angle) * this._radius;
double y = Math.Sin(angle) * this._radius;
return this._center + new Offset((float) x, (float) y);
float angle = MathUtils.lerpNullablefloat(this._beginAngle, this._endAngle, t) ?? 0.0f;
float x = Mathf.Cos(angle) * this._radius;
float y = Mathf.Sin(angle) * this._radius;
return this._center + new Offset(x, y);
}
public override string ToString() {

this._dirty = false;
}
double _diagonalSupport(Offset centersVector, _Diagonal diagonal) {
float _diagonalSupport(Offset centersVector, _Diagonal diagonal) {
double length = delta.distance;
float length = delta.distance;
return centersVector.dx * delta.dx / length + centersVector.dy * delta.dy / length;
}

}
Offset center = this._centerArc.lerp(t);
double width = MathUtils.lerpDouble(this.begin.width, this.end.width, t);
double height = MathUtils.lerpDouble(this.begin.height, this.end.height, t);
float width = MathUtils.lerpfloat(this.begin.width, this.end.width, t);
float height = MathUtils.lerpfloat(this.begin.height, this.end.height, t);
(float) (center.dx - width / 2.0),
(float) (center.dy - height / 2.0),
(float) width,
(float) height);
(center.dx - width / 2.0f),
(center.dy - height / 2.0f),
width,
height);
}
public override string ToString() {

14
Runtime/material/button.cs


Color fillColor = null,
Color highlightColor = null,
Color splashColor = null,
double elevation = 2.0,
double highlightElevation = 8.0,
double disabledElevation = 0.0,
float elevation = 2.0f,
float highlightElevation = 8.0f,
float disabledElevation = 0.0f,
EdgeInsets padding = null,
BoxConstraints constraints = null,
ShapeBorder shape = null,

public readonly Color splashColor;
public readonly double elevation;
public readonly float elevation;
public readonly double highlightElevation;
public readonly float highlightElevation;
public readonly double disabledElevation;
public readonly float disabledElevation;
public readonly EdgeInsets padding;

}
public override Widget build(BuildContext context) {
double elevation = this.widget.enabled
float elevation = this.widget.enabled
? (this._highlight ? this.widget.highlightElevation : this.widget.elevation)
: this.widget.disabledElevation;

36
Runtime/material/button_theme.cs


Color _getDisabledColor(MaterialButton button) {
return this.getBrightness(button) == Brightness.dark
? this.colorScheme.onSurface.withOpacity(0.30)
: this.colorScheme.onSurface.withOpacity(0.38);
? this.colorScheme.onSurface.withOpacity(0.30f)
: this.colorScheme.onSurface.withOpacity(0.38f);
}

case ButtonTextTheme.primary:
return button.enabled
? this._buttonColor ?? this.colorScheme.primary
: this.colorScheme.onSurface.withOpacity(0.12);
: this.colorScheme.onSurface.withOpacity(0.12f);
}
D.assert(false);

}
}
return this.getTextColor(button).withOpacity(0.12);
return this.getTextColor(button).withOpacity(0.12f);
}
public Color getHighlightColor(MaterialButton button) {

switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return this._highlightColor ?? this.getTextColor(button).withOpacity(0.16);
return this._highlightColor ?? this.getTextColor(button).withOpacity(0.16f);
case ButtonTextTheme.primary:
return Colors.transparent;
}

}
public double getElevation(MaterialButton button) {
public float getElevation(MaterialButton button) {
return button.elevation ?? 0.0;
return button.elevation ?? 0.0f;
return 0.0;
return 0.0f;
return 2.0;
return 2.0f;
public double getHighlightElevation(MaterialButton button) {
public float getHighlightElevation(MaterialButton button) {
return button.highlightElevation ?? 0.0;
return button.highlightElevation ?? 0.0f;
return 0.0;
return 0.0f;
return 8.0;
return 8.0f;
public double getDisabledElevation(MaterialButton button) {
public float getDisabledElevation(MaterialButton button) {
return button.disabledElevation ?? 0.0;
return button.disabledElevation ?? 0.0f;
return 0.0;
return 0.0f;
}

ButtonThemeData defaultTheme = new ButtonThemeData();
properties.add(new EnumProperty<ButtonTextTheme>("textTheme", this.textTheme,
defaultValue: defaultTheme.textTheme));
properties.add(new DoubleProperty("minWidth", this.minWidth, defaultValue: defaultTheme.minWidth));
properties.add(new DoubleProperty("height", this.height, defaultValue: defaultTheme.height));
properties.add(new floatProperty("minWidth", this.minWidth, defaultValue: defaultTheme.minWidth));
properties.add(new floatProperty("height", this.height, defaultValue: defaultTheme.height));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding,
defaultValue: defaultTheme.padding));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: defaultTheme.shape));

6
Runtime/material/card.cs


public Card(
Key key = null,
Color color = null,
double? elevation = null,
float? elevation = null,
ShapeBorder shape = null,
EdgeInsets margin = null,
Clip clipBehavior = Clip.none,

public readonly Color color;
public readonly double? elevation;
public readonly float? elevation;
public readonly ShapeBorder shape;

child: new Material(
type: MaterialType.card,
color: this.color ?? Theme.of(context).cardColor,
elevation: this.elevation ?? 1.0,
elevation: this.elevation ?? 1.0f,
shape: this.shape ?? new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0f))
),

2
Runtime/material/color_scheme.cs


);
}
public static ColorScheme lerp(ColorScheme a, ColorScheme b, double t) {
public static ColorScheme lerp(ColorScheme a, ColorScheme b, float t) {
return new ColorScheme(
primary: Color.lerp(a.primary, b.primary, t),
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t),

8
Runtime/material/constants.cs


namespace Unity.UIWidgets.material {
public static class Constants {
public static readonly double kToolbarHeight = 56.0;
public static readonly float kToolbarHeight = 56.0f;
public static readonly double kBottomNavigationBarHeight = 56.0;
public static readonly float kBottomNavigationBarHeight = 56.0f;
public static readonly double kTextTabBarHeight = 48.0;
public static readonly float kTextTabBarHeight = 48.0f;
public static readonly double kRadialReactionRadius = 20.0;
public static readonly float kRadialReactionRadius = 20.0f;
public static readonly TimeSpan kRadialReactionDuration = new TimeSpan(0, 0, 0, 0, 100);

15
Runtime/material/drawer.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace Unity.UIWidgets.material {
public enum DrawerAlignment {

public class Drawer : StatelessWidget {
public Drawer(
Key key = null,
double elevation = 16.0,
float elevation = 16.0f,
public readonly double elevation;
public readonly float elevation;
public readonly Widget child;

get {
RenderBox box = (RenderBox) this._drawerKey.currentContext?.findRenderObject();
if (box != null) {
return (float) box.size.width;
return box.size.width;
}
return DrawerUtils._kWidth;

}
if (details.velocity.pixelsPerSecond.dx.abs() >= DrawerUtils._kMinFlingVelocity) {
float visualVelocity = (float) details.velocity.pixelsPerSecond.dx / DrawerUtils._kWidth;
float visualVelocity = details.velocity.pixelsPerSecond.dx / DrawerUtils._kWidth;
switch (this.widget.alignment) {
case DrawerAlignment.start:
break;

Widget _buildDrawer(BuildContext context) {
bool drawerIsStart = this.widget.alignment == DrawerAlignment.start;
EdgeInsets padding = MediaQuery.of(context).padding;
double dragAreaWidth = drawerIsStart ? padding.left : padding.right;
float dragAreaWidth = drawerIsStart ? padding.left : padding.right;
dragAreaWidth = Math.Max(dragAreaWidth, DrawerUtils._kEdgeDragWidth);
dragAreaWidth = Mathf.Max(dragAreaWidth, DrawerUtils._kEdgeDragWidth);
if (this._controller.status == AnimationStatus.dismissed) {
return new Align(
alignment: this._drawerOuterAlignment,

onHorizontalDragEnd: this._settle,
behavior: HitTestBehavior.translucent,
child: new Container(width: (float) dragAreaWidth)
child: new Container(width: dragAreaWidth)
)
);
}

7
Runtime/material/expand_icon.cs


using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace Unity.UIWidgets.material {
public class ExpandIcon : StatefulWidget {

double size = 24.0,
float size = 24.0f,
ValueChanged<bool> onPressed = null,
EdgeInsets padding = null) : base(key: key) {
this.isExpanded = isExpanded;

public readonly bool isExpanded;
public readonly double size;
public readonly float size;
public readonly ValueChanged<bool> onPressed;

this._controller = new AnimationController(duration: ThemeUtils.kThemeAnimationDuration, vsync: this);
this._iconTurns = this._controller.drive(_iconTurnTween);
if (this.widget.isExpanded) {
this._controller.setValue((float) Math.PI);
this._controller.setValue(Mathf.PI);
}
}

6
Runtime/material/icon_button.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
public class IconButton : StatelessWidget {

child: result,
highlightColor: this.highlightColor ?? Theme.of(context).highlightColor,
splashColor: this.splashColor ?? Theme.of(context).splashColor,
radius: (float) Math.Max(
radius: Mathf.Max(
(this.iconSize + Math.Min(this.padding.horizontal, this.padding.vertical)) * 0.7f)
(this.iconSize + Mathf.Min(this.padding.horizontal, this.padding.vertical)) * 0.7f)
);
}

2
Runtime/material/ink_ripple.cs


canvas.concat(transform);
}
else {
canvas.translate((float) originOffset.dx, (float) originOffset.dy);
canvas.translate(originOffset.dx, originOffset.dy);
}
if (this._clipCallback != null) {

6
Runtime/material/ink_splash.cs


vsync: controller.vsync);
this._radiusController.addListener(controller.markNeedsPaint);
this._radiusController.forward();
this._radius = this._radiusController.drive(new DoubleTween(
this._radius = this._radiusController.drive(new floatTween(
begin: InkSplashUtils._kSplashInitialSize,
end: this._targetRadius));

readonly bool _repositionToReferenceBox;
Animation<double> _radius;
Animation<float> _radius;
AnimationController _radiusController;
Animation<int> _alpha;

canvas.concat(transform);
}
else {
canvas.translate((float) originOffset.dx, (float) originOffset.dy);
canvas.translate(originOffset.dx, originOffset.dy);
}
if (this._clipCallback != null) {

26
Runtime/material/ink_well.cs


GestureTapCallback onTap = null,
GestureTapDownCallback onTapDown = null,
GestureTapCallback onTapCancel = null,
GestureTapCallback onDoubleTap = null,
GestureTapCallback onfloatTap = null,
GestureLongPressCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null,
bool containedInkWell = false,

this.onTap = onTap;
this.onTapDown = onTapDown;
this.onTapCancel = onTapCancel;
this.onDoubleTap = onDoubleTap;
this.onfloatTap = onfloatTap;
this.onLongPress = onLongPress;
this.onHighlightChanged = onHighlightChanged;
this.containedInkWell = containedInkWell;

public readonly GestureTapCallback onTapCancel;
public readonly GestureTapCallback onDoubleTap;
public readonly GestureTapCallback onfloatTap;
public readonly GestureLongPressCallback onLongPress;

gestures.Add("tap");
}
if (this.onDoubleTap != null) {
gestures.Add("double tap");
if (this.onfloatTap != null) {
gestures.Add("float tap");
}
if (this.onLongPress != null) {

this.updateHighlight(false);
}
void _handleDoubleTap() {
void _handlefloatTap() {
if (this.widget.onDoubleTap != null) {
this.widget.onDoubleTap();
if (this.widget.onfloatTap != null) {
this.widget.onfloatTap();
}
}

this._currentSplash.color = this.widget.splashColor ?? themeData.splashColor;
}
bool enabled = this.widget.onTap != null || this.widget.onDoubleTap != null ||
bool enabled = this.widget.onTap != null || this.widget.onfloatTap != null ||
this.widget.onLongPress != null;
return new GestureDetector(

onDoubleTap: this.widget.onDoubleTap != null
? (GestureDoubleTapCallback) (details => this._handleDoubleTap())
onfloatTap: this.widget.onfloatTap != null
? (GesturefloatTapCallback) (details => this._handlefloatTap())
: null,
onLongPress: this.widget.onLongPress != null
? (GestureLongPressCallback) (() => this._handleLongPress(context))

Key key = null,
Widget child = null,
GestureTapCallback onTap = null,
GestureTapCallback onDoubleTap = null,
GestureTapCallback onfloatTap = null,
GestureLongPressCallback onLongPress = null,
GestureTapDownCallback onTapDown = null,
GestureTapCancelCallback onTapCancel = null,

key: key,
child: child,
onTap: onTap,
onDoubleTap: onDoubleTap,
onfloatTap: onfloatTap,
onLongPress: onLongPress,
onTapDown: onTapDown,
onTapCancel: () => {

62
Runtime/material/list_tile.cs


using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {

protected override float computeMinIntrinsicWidth(float height) {
float leadingWidth = this.leading != null
? (float) Math.Max(this.leading.getMinIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
? Mathf.Max(this.leading.getMinIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
return leadingWidth + (float) Math.Max(_minWidth(this.title, height), _minWidth(this.subtitle, height)) +
return leadingWidth + Mathf.Max(_minWidth(this.title, height), _minWidth(this.subtitle, height)) +
? (float) Math.Max(this.leading.getMaxIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
? Mathf.Max(this.leading.getMaxIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
return leadingWidth + (float) Math.Max(_maxWidth(this.title, height), _maxWidth(this.subtitle, height)) +
return leadingWidth + Mathf.Max(_maxWidth(this.title, height), _maxWidth(this.subtitle, height)) +
_maxWidth(this.trailing, height);
}

}
protected override float computeMinIntrinsicHeight(float width) {
return (float) Math.Max(
return Mathf.Max(
this.title.getMinIntrinsicHeight(width) + this.subtitle?.getMinIntrinsicHeight(width) ?? 0.0);
this.title.getMinIntrinsicHeight(width) + this.subtitle?.getMinIntrinsicHeight(width) ?? 0.0f);
}
protected override float computeMaxIntrinsicHeight(float width) {

return parentData.offset.dy + this.title.getDistanceToActualBaseline(baseline);
}
static double _boxBaseline(RenderBox box, TextBaseline baseline) {
return box.getDistanceToBaseline(baseline) ?? 0.0;
static float _boxBaseline(RenderBox box, TextBaseline baseline) {
return box.getDistanceToBaseline(baseline) ?? 0.0f;
}
static Size _layoutBox(RenderBox box, BoxConstraints constraints) {

Size trailingSize = _layoutBox(this.trailing, looseConstraints);
float titleStart = hasLeading
? (float) Math.Max(_minLeadingWidth, leadingSize.width) + _horizontalTitleGap
? Mathf.Max(_minLeadingWidth, leadingSize.width) + _horizontalTitleGap
: 0.0f;
BoxConstraints textConstraints = looseConstraints.tighten(
width: tileWidth - titleStart - (hasTrailing ? trailingSize.width + _horizontalTitleGap : 0.0f));

double titleBaseline = 0.0;
double subtitleBaseline = 0.0;
float titleBaseline = 0.0f;
float subtitleBaseline = 0.0f;
titleBaseline = this.isDense ? 28.0 : 32.0;
subtitleBaseline = this.isDense ? 48.0 : 52.0;
titleBaseline = this.isDense ? 28.0f : 32.0f;
subtitleBaseline = this.isDense ? 48.0f : 52.0f;
titleBaseline = this.isDense ? 22.0 : 28.0;
subtitleBaseline = this.isDense ? 42.0 : 48.0;
titleBaseline = this.isDense ? 22.0f : 28.0f;
subtitleBaseline = this.isDense ? 42.0f : 48.0f;
}
else {
D.assert(isOneLine);

double titleY = 0.0;
double subtitleY = 0.0;
float titleY = 0.0f;
float subtitleY = 0.0f;
tileHeight = (float) Math.Max(this._defaultTileHeight, titleSize.height + 2.0 * _minVerticalPadding);
titleY = (tileHeight - titleSize.height) / 2.0;
tileHeight = Mathf.Max(this._defaultTileHeight, titleSize.height + 2.0f * _minVerticalPadding);
titleY = (tileHeight - titleSize.height) / 2.0f;
}
else {
D.assert(this.subtitleBaselineType != null);

tileHeight = this._defaultTileHeight;
double titleOverlap = titleY + titleSize.height - subtitleY;
if (titleOverlap > 0.0) {
titleY -= titleOverlap / 2.0;
subtitleY += titleOverlap / 2.0;
float titleOverlap = titleY + titleSize.height - subtitleY;
if (titleOverlap > 0.0f) {
titleY -= titleOverlap / 2.0f;
subtitleY += titleOverlap / 2.0f;
}
if (titleY < _minVerticalPadding ||

}
}
double leadingY = (tileHeight - leadingSize.height) / 2.0;
double trailingY = (tileHeight - trailingSize.height) / 2.0;
float leadingY = (tileHeight - leadingSize.height) / 2.0f;
float trailingY = (tileHeight - trailingSize.height) / 2.0f;
_positionBox(this.leading, new Offset(0.0f, (float) leadingY));
_positionBox(this.leading, new Offset(0.0f, leadingY));
_positionBox(this.title, new Offset((float) titleStart, (float) titleY));
_positionBox(this.title, new Offset(titleStart, titleY));
_positionBox(this.subtitle, new Offset((float) titleStart, (float) subtitleY));
_positionBox(this.subtitle, new Offset(titleStart, subtitleY));
_positionBox(this.trailing, new Offset((float) tileWidth - trailingSize.width, (float) trailingY));
_positionBox(this.trailing, new Offset(tileWidth - trailingSize.width, trailingY));
this.size = this.constraints.constrain(new Size((float) tileWidth, (float) tileHeight));
this.size = this.constraints.constrain(new Size(tileWidth, tileHeight));
D.assert(this.size.width == this.constraints.constrainWidth(tileWidth));
D.assert(this.size.height == this.constraints.constrainHeight(tileHeight));
}

22
Runtime/material/material.cs


public Material(
Key key = null,
MaterialType type = MaterialType.canvas,
double elevation = 0.0,
float elevation = 0.0f,
Color color = null,
Color shadowColor = null,
TextStyle textStyle = null,

public readonly MaterialType type;
public readonly double elevation;
public readonly float elevation;
public readonly Color color;

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<MaterialType>("type", this.type));
properties.add(new DoubleProperty("elevation", this.elevation, defaultValue: 0.0));
properties.add(new floatProperty("elevation", this.elevation, defaultValue: 0.0));
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor,
defaultValue: new Color(0xFF000000)));

if (this._inkFeatures != null && this._inkFeatures.isNotEmpty()) {
Canvas canvas = context.canvas;
canvas.save();
canvas.translate((float) offset.dx, (float) offset.dy);
canvas.translate(offset.dx, offset.dy);
canvas.clipRect(Offset.zero & this.size);
foreach (InkFeature inkFeature in this._inkFeatures) {
inkFeature._paint(canvas);

Widget child = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
double? elevation = null,
float? elevation = null,
Color color = null,
Color shadowColor = null,
Curve curve = null,

this.child = child;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.elevation = elevation ?? 0.0;
this.elevation = elevation ?? 0.0f;
this.color = color;
this.shadowColor = shadowColor;
}

public readonly Clip clipBehavior;
public readonly double elevation;
public readonly float elevation;
public readonly Color color;

public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape));
description.add(new DoubleProperty("elevation", this.elevation));
description.add(new floatProperty("elevation", this.elevation));
description.add(new DiagnosticsProperty<Color>("color", this.color));
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}

DoubleTween _elevation;
floatTween _elevation;
this._elevation = (DoubleTween) visitor.visit(this, this._elevation, this.widget.elevation,
(double value) => new DoubleTween(begin: value, end: value));
this._elevation = (floatTween) visitor.visit(this, this._elevation, this.widget.elevation,
(float value) => new floatTween(begin: value, end: value));
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor,
(Color value) => new ColorTween(begin: value));
this._border = (ShapeBorderTween) visitor.visit(this, this._border, this.widget.shape,

6
Runtime/material/material_button.cs


public readonly Color highlightColor;
public readonly double? elevation;
public readonly float? elevation;
public readonly double? highlightElevation;
public readonly float? highlightElevation;
public readonly double? disabledElevation;
public readonly float? disabledElevation;
public readonly Brightness? colorBrightness;

2
Runtime/material/mergeable_material.cs


public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<Axis>("mainAxis", this.mainAxis));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new floatProperty("elevation", this.elevation));
}
public override State createState() {

6
Runtime/material/raised_button.cs


properties.add(new DiagnosticsProperty<Color>("splashColor", this.splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Brightness?>("colorBrightness", this.colorBrightness,
defaultValue: null));
properties.add(new DiagnosticsProperty<double?>("elevation", this.elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<double?>("highlightElevation", this.highlightElevation,
properties.add(new DiagnosticsProperty<float?>("elevation", this.elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("highlightElevation", this.highlightElevation,
properties.add(new DiagnosticsProperty<double?>("disabledElevation", this.disabledElevation,
properties.add(new DiagnosticsProperty<float?>("disabledElevation", this.disabledElevation,
defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: null));

2
Runtime/material/scrollbar.cs


ThemeData theme = Theme.of(this.context);
this._themeColor = theme.highlightColor.withOpacity(1.0);
this._themeColor = theme.highlightColor.withOpacity(1.0f);
this._textDirection = Directionality.of(this.context);
this._materialPainter = this._BuildMaterialScrollbarPainter();
}

22
Runtime/material/text_selection.cs


}
static class _TextSelectionUtils {
internal const double _kHandleSize = 22.0;
internal const double _kToolbarScreenPadding = 8.0;
internal const float _kHandleSize = 22.0f;
internal const float _kToolbarScreenPadding = 8.0f;
}
class _TextSelectionToolbar : StatelessWidget {

public override Offset getPositionForChild(Size size, Size childSize) {
Offset globalPosition = this.globalEditableRegion.topLeft + this.position;
double x = globalPosition.dx - childSize.width / 2.0;
double y = globalPosition.dy - childSize.height;
float x = globalPosition.dx - childSize.width / 2.0f;
float y = globalPosition.dy - childSize.height;
if (x < _TextSelectionUtils._kToolbarScreenPadding) {
x = _TextSelectionUtils._kToolbarScreenPadding;

y = this.screenSize.height - childSize.height - _TextSelectionUtils._kToolbarScreenPadding;
}
return new Offset((float) x, (float) y);
return new Offset(x, y);
}
public override bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) {

public override void paint(Canvas canvas, Size size) {
Paint paint = new Paint();
paint.color = this.color;
double radius = size.width / 2.0;
canvas.drawCircle(new Offset((float) radius, (float) radius), radius, paint);
canvas.drawRect(Rect.fromLTWH(0.0f, 0.0f, (float) radius, (float) radius), paint);
float radius = size.width / 2.0f;
canvas.drawCircle(new Offset(radius, radius), radius, paint);
canvas.drawRect(Rect.fromLTWH(0.0f, 0.0f, radius, radius), paint);
}

class _MaterialTextSelectionControls : TextSelectionControls {
public override Size handleSize {
get {
return new Size((float) _TextSelectionUtils._kHandleSize,
(float) _TextSelectionUtils._kHandleSize);
return new Size(_TextSelectionUtils._kHandleSize,
_TextSelectionUtils._kHandleSize);
}
}

);
}
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textLineHeight) {
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) {
Widget handle = new Padding(
padding: EdgeInsets.only(right: 26.0f, bottom: 26.0f),
child: new SizedBox(

8
Runtime/material/theme_data.cs


unselectedWidgetColor = unselectedWidgetColor ?? (isDark ? Colors.white70 : Colors.black54);
secondaryHeaderColor = secondaryHeaderColor ?? (isDark ? Colors.grey[700] : primarySwatch[50]);
textSelectionColor = textSelectionColor ?? (isDark ? accentColor : primarySwatch[200]);
cursorColor = cursorColor ?? Color.fromRGBO(66, 133, 244, 1.0);
cursorColor = cursorColor ?? Color.fromRGBO(66, 133, 244, 1.0f);
textSelectionHandleColor =
textSelectionHandleColor ?? (isDark ? Colors.tealAccent[400] : primarySwatch[300]);

public static Brightness estimateBrightnessForColor(Color color) {
double relativeLuminance = color.computeLuminance();
double kThreshold = 0.15;
if ((relativeLuminance + 0.05) * (relativeLuminance + 0.05) > kThreshold) {
float relativeLuminance = color.computeLuminance();
float kThreshold = 0.15f;
if ((relativeLuminance + 0.05f) * (relativeLuminance + 0.05f) > kThreshold) {
return Brightness.light;
}

10
Runtime/material/tooltip.cs


public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new StringProperty("message", this.message, showName: false));
properties.add(new DoubleProperty("vertical offset", this.verticalOffset));
properties.add(new floatProperty("vertical offset", this.verticalOffset));
properties.add(new FlagProperty("position", value: this.preferBelow, ifTrue: "below", ifFalse: "above",
showName: true));
}

public class _TooltipPositionDelegate : SingleChildLayoutDelegate {
public _TooltipPositionDelegate(
Offset target = null,
double? verticalOffset = null,
float? verticalOffset = null,
this.verticalOffset = verticalOffset ?? 0.0;
this.verticalOffset = verticalOffset ?? 0.0f;
public readonly double verticalOffset;
public readonly float verticalOffset;
public readonly bool preferBelow;

child: new FadeTransition(
opacity: this.animation,
child: new Opacity(
opacity: 0.9,
opacity: 0.9f,
child: new ConstrainedBox(
constraints: new BoxConstraints(minHeight: this.height ?? 0.0f),
child: new Container(

26
Runtime/material/utils.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
public static class ThemeDataUtils {

}
static float _getSplashRadiusForPositionInSize(Size bounds, Offset position) {
double d1 = (position - bounds.topLeft(Offset.zero)).distance;
double d2 = (position - bounds.topRight(Offset.zero)).distance;
double d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
double d4 = (position - bounds.bottomRight(Offset.zero)).distance;
return Math.Max(Math.Max(d1, d2), Math.Max(d3, d4)).ceil();
float d1 = (position - bounds.topLeft(Offset.zero)).distance;
float d2 = (position - bounds.topRight(Offset.zero)).distance;
float d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
float d4 = (position - bounds.bottomRight(Offset.zero)).distance;
return Mathf.Max(Mathf.Max(d1, d2), Mathf.Max(d3, d4)).ceil();
}
}

public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
Offset position) {
Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
double d1 = size.bottomRight(Offset.zero).distance;
double d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).distance;
return (float) (Math.Max(d1, d2) / 2.0);
float d1 = size.bottomRight(Offset.zero).distance;
float d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).distance;
return (Mathf.Max(d1, d2) / 2.0f);
}
}

public static class ArcUtils {
public const double _kOnAxisDelta = 2.0;
public const float _kOnAxisDelta = 2.0f;
public static readonly List<_Diagonal> _allDiagonals = new List<_Diagonal> {
new _Diagonal(_CornerId.topLeft, _CornerId.bottomRight),

};
public delegate double _KeyFunc<T>(T input);
public delegate float _KeyFunc<T>(T input);
double? maxKey = null;
float? maxKey = null;
double key = keyFunc(value);
float key = keyFunc(value);
if (maxKey == null || key > maxKey) {
maxValue = value;
maxKey = key;

84
Runtime/painting/alignment.cs


namespace Unity.UIWidgets.painting {
public class Alignment : IEquatable<Alignment> {
public Alignment(double x, double y) {
public Alignment(float x, float y) {
public readonly double x;
public readonly float x;
public readonly double y;
public readonly float y;
public static readonly Alignment topLeft = new Alignment(-1.0, -1.0);
public static readonly Alignment topCenter = new Alignment(0, -1.0);
public static readonly Alignment topRight = new Alignment(1.0, -1.0);
public static readonly Alignment centerLeft = new Alignment(-1.0, 0.0);
public static readonly Alignment center = new Alignment(0.0, 0.0);
public static readonly Alignment centerRight = new Alignment(1.0, 0.0);
public static readonly Alignment bottomLeft = new Alignment(-1.0, 1.0);
public static readonly Alignment bottomCenter = new Alignment(0.0, 1.0);
public static readonly Alignment bottomRight = new Alignment(1.0, 1.0);
public static readonly Alignment topLeft = new Alignment(-1.0f, -1.0f);
public static readonly Alignment topCenter = new Alignment(0, -1.0f);
public static readonly Alignment topRight = new Alignment(1.0f, -1.0f);
public static readonly Alignment centerLeft = new Alignment(-1.0f, 0.0f);
public static readonly Alignment center = new Alignment(0.0f, 0.0f);
public static readonly Alignment centerRight = new Alignment(1.0f, 0.0f);
public static readonly Alignment bottomLeft = new Alignment(-1.0f, 1.0f);
public static readonly Alignment bottomCenter = new Alignment(0.0f, 1.0f);
public static readonly Alignment bottomRight = new Alignment(1.0f, 1.0f);
public static Alignment operator -(Alignment a, Alignment b) {
return new Alignment(a.x - b.x, a.y - b.y);

return new Alignment(-a.x, -a.y);
}
public static Alignment operator *(Alignment a, double b) {
public static Alignment operator *(Alignment a, float b) {
public static Alignment operator /(Alignment a, double b) {
public static Alignment operator /(Alignment a, float b) {
public static Alignment operator %(Alignment a, double b) {
public static Alignment operator %(Alignment a, float b) {
double centerX = other.dx / 2.0;
double centerY = other.dy / 2.0;
return new Offset((float) (centerX + this.x * centerX), (float) (centerY + this.y * centerY));
float centerX = other.dx / 2.0f;
float centerY = other.dy / 2.0f;
return new Offset((centerX + this.x * centerX), (centerY + this.y * centerY));
double centerX = other.width / 2.0;
double centerY = other.height / 2.0;
return new Offset((float) (centerX + this.x * centerX), (float) (centerY + this.y * centerY));
float centerX = other.width / 2.0f;
float centerY = other.height / 2.0f;
return new Offset((centerX + this.x * centerX), (centerY + this.y * centerY));
double halfWidth = rect.width / 2.0;
double halfHeight = rect.height / 2.0;
float halfWidth = rect.width / 2.0f;
float halfHeight = rect.height / 2.0f;
(float) (rect.left + halfWidth + this.x * halfWidth),
(float) (rect.top + halfHeight + this.y * halfHeight)
(rect.left + halfWidth + this.x * halfWidth),
(rect.top + halfHeight + this.y * halfHeight)
double halfWidthDelta = (rect.width - size.width) / 2.0;
double halfHeightDelta = (rect.height - size.height) / 2.0;
float halfWidthDelta = (rect.width - size.width) / 2.0f;
float halfHeightDelta = (rect.height - size.height) / 2.0f;
(float) (rect.left + halfWidthDelta + this.x * halfWidthDelta),
(float) (rect.top + halfHeightDelta + this.y * halfHeightDelta),
(rect.left + halfWidthDelta + this.x * halfWidthDelta),
(rect.top + halfHeightDelta + this.y * halfHeightDelta),
public static Alignment lerp(Alignment a, Alignment b, double t) {
public static Alignment lerp(Alignment a, Alignment b, float t) {
return new Alignment(MathUtils.lerpDouble(0.0, b.x, t), MathUtils.lerpDouble(0.0, b.y, t));
return new Alignment(MathUtils.lerpfloat(0.0f, b.x, t), MathUtils.lerpfloat(0.0f, b.y, t));
return new Alignment(MathUtils.lerpDouble(a.x, 0.0, t), MathUtils.lerpDouble(a.y, 0.0, t));
return new Alignment(MathUtils.lerpfloat(a.x, 0.0f, t), MathUtils.lerpfloat(a.y, 0.0f, t));
return new Alignment(MathUtils.lerpDouble(a.x, b.x, t), MathUtils.lerpDouble(a.y, b.y, t));
return new Alignment(MathUtils.lerpfloat(a.x, b.x, t), MathUtils.lerpfloat(a.y, b.y, t));
}
public bool Equals(Alignment other) {

}
public override string ToString() {
if (this.x == -1.0 && this.y == -1.0) {
if (this.x == -1.0f && this.y == -1.0f) {
if (this.x == 0.0 && this.y == -1.0) {
if (this.x == 0.0f && this.y == -1.0f) {
if (this.x == 1.0 && this.y == -1.0) {
if (this.x == 1.0f && this.y == -1.0f) {
if (this.x == -1.0 && this.y == 0.0) {
if (this.x == -1.0f && this.y == 0.0f) {
if (this.x == 0.0 && this.y == 0.0) {
if (this.x == 0.0f && this.y == 0.0f) {
if (this.x == 1.0 && this.y == 0.0) {
if (this.x == 1.0f && this.y == 0.0f) {
if (this.x == -1.0 && this.y == 1.0) {
if (this.x == -1.0f && this.y == 1.0f) {
if (this.x == 0.0 && this.y == 1.0) {
if (this.x == 0.0f && this.y == 1.0f) {
if (this.x == 1.0 && this.y == 1.0) {
if (this.x == 1.0f && this.y == 1.0f) {
return "bottomRight";
}

35
Runtime/painting/beveled_rectangle_border.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.painting {
public class BeveledRectangleBorder : ShapeBorder, IEquatable<BeveledRectangleBorder> {

Offset centerTop = new Offset(rrect.center.dx, rrect.top);
Offset centerBottom = new Offset(rrect.center.dx, rrect.bottom);
double tlRadiusX = Math.Max(0.0, rrect.tlRadiusX);
double tlRadiusY = Math.Max(0.0, rrect.tlRadiusY);
double trRadiusX = Math.Max(0.0, rrect.trRadiusX);
double trRadiusY = Math.Max(0.0, rrect.trRadiusY);
double blRadiusX = Math.Max(0.0, rrect.blRadiusX);
double blRadiusY = Math.Max(0.0, rrect.blRadiusY);
double brRadiusX = Math.Max(0.0, rrect.brRadiusX);
double brRadiusY = Math.Max(0.0, rrect.brRadiusY);
float tlRadiusX = Mathf.Max(0.0f, rrect.tlRadiusX);
float tlRadiusY = Mathf.Max(0.0f, rrect.tlRadiusY);
float trRadiusX = Mathf.Max(0.0f, rrect.trRadiusX);
float trRadiusY = Mathf.Max(0.0f, rrect.trRadiusY);
float blRadiusX = Mathf.Max(0.0f, rrect.blRadiusX);
float blRadiusY = Mathf.Max(0.0f, rrect.blRadiusY);
float brRadiusX = Mathf.Max(0.0f, rrect.brRadiusX);
float brRadiusY = Mathf.Max(0.0f, rrect.brRadiusY);
new Offset(rrect.left, (float) Math.Min(centerLeft.dy, rrect.top + tlRadiusY)),
new Offset((float) Math.Min(centerTop.dx, rrect.left + tlRadiusX), rrect.top),
new Offset((float) Math.Max(centerTop.dx, rrect.right - trRadiusX), rrect.top),
new Offset(rrect.right, (float) Math.Min(centerRight.dy, rrect.top + trRadiusY)),
new Offset(rrect.right, (float) Math.Max(centerRight.dy, rrect.bottom - brRadiusY)),
new Offset((float) Math.Max(centerBottom.dx, rrect.right - brRadiusX), rrect.bottom),
new Offset((float) Math.Min(centerBottom.dx, rrect.left + blRadiusX), rrect.bottom),
new Offset(rrect.left, (float) Math.Max(centerLeft.dy, rrect.bottom - blRadiusY)),
new Offset(rrect.left, Mathf.Min(centerLeft.dy, rrect.top + tlRadiusY)),
new Offset(Mathf.Min(centerTop.dx, rrect.left + tlRadiusX), rrect.top),
new Offset(Mathf.Max(centerTop.dx, rrect.right - trRadiusX), rrect.top),
new Offset(rrect.right, Mathf.Min(centerRight.dy, rrect.top + trRadiusY)),
new Offset(rrect.right, Mathf.Max(centerRight.dy, rrect.bottom - brRadiusY)),
new Offset(Mathf.Max(centerBottom.dx, rrect.right - brRadiusX), rrect.bottom),
new Offset(Mathf.Min(centerBottom.dx, rrect.left + blRadiusX), rrect.bottom),
new Offset(rrect.left, Mathf.Max(centerLeft.dy, rrect.bottom - blRadiusY)),
};
var path = new Path();

24
Runtime/painting/borders.cs


using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.painting {
public enum BorderStyle {

);
}
public BorderSide scale(double t) {
public BorderSide scale(float t) {
width: (float) Math.Max(0.0, this.width * t),
width: Mathf.Max(0.0f, this.width * t),
style: t <= 0.0 ? BorderStyle.none : this.style
);
}

case BorderStyle.none:
return new Paint {
color = Color.clear,
strokeWidth = 0.0,
strokeWidth = 0.0f,
style = PaintingStyle.stroke
};
}

List<ShapeBorder> aList = a is _CompoundBorder aBorder ? aBorder.borders : new List<ShapeBorder> {a};
List<ShapeBorder> bList = b is _CompoundBorder bBorder ? bBorder.borders : new List<ShapeBorder> {b};
List<ShapeBorder> results = new List<ShapeBorder>();
int length = Math.Max(aList.Count, bList.Count);
int length = Mathf.Max(aList.Count, bList.Count);
for (int index = 0; index < length; index += 1) {
ShapeBorder localA = index < aList.Count ? aList[index] : null;
ShapeBorder localB = index < bList.Count ? bList[index] : null;

switch (top.style) {
case BorderStyle.solid:
Paint paint = new Paint {
strokeWidth = 0.0,
strokeWidth = 0.0f,
color = top.color,
};

if (top.width == 0.0) {
if (top.width == 0.0f) {
paint.style = PaintingStyle.stroke;
}
else {

switch (right.style) {
case BorderStyle.solid:
Paint paint = new Paint {
strokeWidth = 0.0,
strokeWidth = 0.0f,
color = right.color,
};

switch (bottom.style) {
case BorderStyle.solid:
Paint paint = new Paint {
strokeWidth = 0.0,
strokeWidth = 0.0f,
color = bottom.color,
};

switch (left.style) {
case BorderStyle.solid:
Paint paint = new Paint {
strokeWidth = 0.0,
strokeWidth = 0.0f,
color = left.color,
};

if (left.width == 0.0) {
if (left.width == 0.0f) {
paint.style = PaintingStyle.stroke;
}
else {

6
Runtime/painting/box_border.cs


float width = side.width;
if (width == 0.0) {
paint.style = PaintingStyle.stroke;
paint.strokeWidth = 0.0;
paint.strokeWidth = 0.0f;
canvas.drawRRect(outer, paint);
}
else {

static void _paintUniformBorderWithCircle(Canvas canvas, Rect rect, BorderSide side) {
D.assert(side.style != BorderStyle.none);
double width = side.width;
float width = side.width;
double radius = (rect.shortestSide - width) / 2.0;
float radius = (rect.shortestSide - width) / 2.0f;
canvas.drawCircle(rect.center, radius, paint);
}

10
Runtime/painting/box_decoration.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.painting {
public class BoxDecoration : Decoration, IEquatable<BoxDecoration> {

return true;
case BoxShape.circle:
Offset center = size.center(Offset.zero);
double distance = (position - center).distance;
return distance <= Math.Min(size.width, size.height) / 2.0;
float distance = (position - center).distance;
return distance <= Mathf.Min(size.width, size.height) / 2.0;
}
return false;

case BoxShape.circle:
D.assert(this._decoration.borderRadius == null);
Offset center = rect.center;
double radius = rect.shortestSide / 2.0;
float radius = rect.shortestSide / 2.0f;
canvas.drawCircle(center, radius, paint);
break;
case BoxShape.rectangle:

13
Runtime/painting/box_fit.cs


using System;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.painting {
public enum BoxFit {

outputSize.height);
break;
case BoxFit.none:
sourceSize = new Size(Math.Min(inputSize.width, outputSize.width),
Math.Min(inputSize.height, outputSize.height));
sourceSize = new Size(Mathf.Min(inputSize.width, outputSize.width),
Mathf.Min(inputSize.height, outputSize.height));
double aspectRatio = inputSize.width / inputSize.height;
float aspectRatio = inputSize.width / inputSize.height;
destinationSize = new Size((float) (outputSize.height * aspectRatio),
(float) outputSize.height);
destinationSize = new Size((outputSize.height * aspectRatio),
outputSize.height);
destinationSize = new Size(outputSize.width, (float) (outputSize.width / aspectRatio));
destinationSize = new Size(outputSize.width, (outputSize.width / aspectRatio));
}
break;

10
Runtime/painting/box_shadow.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.painting {
public class BoxShadow : IEquatable<BoxShadow> {

public readonly float blurRadius;
public readonly float spreadRadius;
public static double convertRadiusToSigma(double radius) {
return radius * 0.57735 + 0.5;
public static float convertRadiusToSigma(float radius) {
return radius * 0.57735f + 0.5f;
public double blurSigma {
public float blurSigma {
get { return convertRadiusToSigma(this.blurRadius); }
}

a = a ?? new List<BoxShadow>();
b = b ?? new List<BoxShadow>();
List<BoxShadow> result = new List<BoxShadow>();
int commonLength = Math.Min(a.Count, b.Count);
int commonLength = Mathf.Min(a.Count, b.Count);
for (int i = 0; i < commonLength; i += 1) {
result.Add(lerp(a[i], b[i], t));
}

7
Runtime/painting/circle_border.cs


using System;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.painting {
public class CircleBorder : ShapeBorder, IEquatable<CircleBorder> {

var path = new Path();
path.addOval(Rect.fromCircle(
center: rect.center,
radius: (float) Math.Max(0.0, rect.shortestSide / 2.0 - this.side.width)
radius: Mathf.Max(0.0f, rect.shortestSide / 2.0f - this.side.width)
));
return path;
}

case BorderStyle.none:
break;
case BorderStyle.solid:
canvas.drawCircle(rect.center, (rect.shortestSide - this.side.width) / 2.0, this.side.toPaint());
canvas.drawCircle(rect.center, (rect.shortestSide - this.side.width) / 2.0f, this.side.toPaint());
break;
}
}

10
Runtime/painting/decoration_image.cs


paint.invertColors = invertColors;
double halfWidthDelta = (outputSize.width - destinationSize.width) / 2.0;
double halfHeightDelta = (outputSize.height - destinationSize.height) / 2.0;
double dx = halfWidthDelta + alignment.x * halfWidthDelta;
double dy = halfHeightDelta + alignment.y * halfHeightDelta;
Offset destinationPosition = rect.topLeft.translate((float) dx, (float) dy);
float halfWidthDelta = (outputSize.width - destinationSize.width) / 2.0f;
float halfHeightDelta = (outputSize.height - destinationSize.height) / 2.0f;
float dx = halfWidthDelta + alignment.x * halfWidthDelta;
float dy = halfHeightDelta + alignment.y * halfHeightDelta;
Offset destinationPosition = rect.topLeft.translate(dx, dy);
Rect destinationRect = destinationPosition & destinationSize;
bool needSave = repeat != ImageRepeat.noRepeat;
if (needSave) {

23
Runtime/painting/geometry.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.painting {
public static class Geometry {

Offset target = null,
bool? preferBelow = null,
double verticalOffset = 0.0,
double margin = 10.0) {
float verticalOffset = 0.0f,
float margin = 10.0f) {
D.assert(size != null);
D.assert(childSize != null);
D.assert(target != null);

bool fitsAbove = target.dy - verticalOffset - childSize.height >= margin;
bool tooltipBelow = (preferBelow ?? true) ? (fitsBelow || !fitsAbove) : !(fitsAbove || !fitsBelow);
double y;
float y;
y = Math.Min(target.dy + verticalOffset, size.height - margin);
y = Mathf.Min(target.dy + verticalOffset, size.height - margin);
y = Math.Max(target.dy - verticalOffset - childSize.height, margin);
y = Mathf.Max(target.dy - verticalOffset - childSize.height, margin);
double x;
float x;
x = (size.width - childSize.width) / 2.0;
x = (size.width - childSize.width) / 2.0f;
double normalizedTargetX = target.dx.clamp((float) margin, (float) (size.width - margin));
double edge = margin + childSize.width / 2.0;
float normalizedTargetX = target.dx.clamp(margin, size.width - margin);
float edge = margin + childSize.width / 2.0f;
if (normalizedTargetX < edge) {
x = margin;
}

else {
x = normalizedTargetX - childSize.width / 2.0;
x = normalizedTargetX - childSize.width / 2.0f;
return new Offset((float) x, (float) y);
return new Offset(x, y);
}
}
}

93
Runtime/painting/gradient.cs


using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
public _ColorsAndStops(List<Color> colors, List<double> stops) {
public _ColorsAndStops(List<Color> colors, List<float> stops) {
public readonly List<double> stops;
public readonly List<float> stops;
List<Color> aColors, List<double> aStops, List<Color> bColors, List<double> bStops, double t) {
List<Color> aColors, List<float> aStops, List<Color> bColors, List<float> bStops, float t) {
D.assert(aColors.Count == bColors.Count,
"Cannot interpolate between two gradients with a different number of colors.");
D.assert((aStops == null && aColors.Count == 2) || (aStops != null && aStops.Count == aColors.Count));

interpolatedColors.Add(Color.lerp(aColors[i], bColors[i], t));
}
List<double> interpolatedStops = null;
List<float> interpolatedStops = null;
aStops = aStops ?? new List<double> {0.0, 1.0};
bStops = bStops ?? new List<double> {0.0, 1.0};
aStops = aStops ?? new List<float> {0.0f, 1.0f};
bStops = bStops ?? new List<float> {0.0f, 1.0f};
interpolatedStops = new List<double>();
interpolatedStops = new List<float>();
interpolatedStops.Add(MathUtils.lerpDouble(aStops[i], bStops[i], t).clamp(0.0, 1.0));
interpolatedStops.Add(MathUtils.lerpfloat(aStops[i], bStops[i], t).clamp(0.0f, 1.0f));
}
}

public abstract class Gradient {
public Gradient(
List<Color> colors = null,
List<double> stops = null
List<float> stops = null
) {
D.assert(colors != null);
this.colors = colors;

public readonly List<Color> colors;
public readonly List<double> stops;
public readonly List<float> stops;
protected List<double> _impliedStops() {
protected List<float> _impliedStops() {
if (this.stops != null) {
return this.stops;
}

}
D.assert(this.colors.Count >= 2, "colors list must have at least two colors");
double separation = 1.0 / (this.colors.Count - 1);
float separation = 1.0f / (this.colors.Count - 1);
return Enumerable.Range(0, this.colors.Count).Select(i => i * separation).ToList();
}

public abstract Gradient scale(double factor);
public abstract Gradient scale(float factor);
protected virtual Gradient lerpFrom(Gradient a, double t) {
protected virtual Gradient lerpFrom(Gradient a, float t) {
if (a == null) {
return this.scale(t);
}

protected virtual Gradient lerpTo(Gradient b, double t) {
protected virtual Gradient lerpTo(Gradient b, float t) {
return this.scale(1.0 - t);
return this.scale(1.0f - t);
}
return null;

public static Gradient lerp(Gradient a, Gradient b, double t) {
public static Gradient lerp(Gradient a, Gradient b, float t) {
Gradient result = null;
if (b != null) {
result = b.lerpFrom(a, t); // if a is null, this must return non-null

}
D.assert(a != null && b != null);
return t < 0.5 ? a.scale(1.0 - (t * 2.0)) : b.scale((t - 0.5) * 2.0);
return t < 0.5 ? a.scale(1.0f - (t * 2.0f)) : b.scale((t - 0.5f) * 2.0f);
}
}

Alignment begin = null,
Alignment end = null,
List<Color> colors = null,
List<double> stops = null,
List<float> stops = null,
TileMode tileMode = TileMode.clamp
) : base(colors: colors, stops: stops) {
this.begin = begin ?? Alignment.centerLeft;

);
}
public override Gradient scale(double factor) {
public override Gradient scale(float factor) {
return new LinearGradient(
begin: this.begin,
end: this.end,

);
}
protected override Gradient lerpFrom(Gradient a, double t) {
protected override Gradient lerpFrom(Gradient a, float t) {
if (a == null || (a is LinearGradient && a.colors.Count == this.colors.Count)) {
return lerp((LinearGradient) a, this, t);
}

protected override Gradient lerpTo(Gradient b, double t) {
protected override Gradient lerpTo(Gradient b, float t) {
if (b == null || (b is LinearGradient && b.colors.Count == this.colors.Count)) {
return lerp(this, (LinearGradient) b, t);
}

public static LinearGradient lerp(LinearGradient a, LinearGradient b, double t) {
public static LinearGradient lerp(LinearGradient a, LinearGradient b, float t) {
if (a == null && b == null) {
return null;
}

}
if (b == null) {
return (LinearGradient) a.scale(1.0 - t);
return (LinearGradient) a.scale(1.0f - t);
}
_ColorsAndStops interpolated =

public class RadialGradient : Gradient, IEquatable<RadialGradient> {
public RadialGradient(
Alignment center = null,
double radius = 0.5,
float radius = 0.5f,
List<double> stops = null,
List<float> stops = null,
TileMode tileMode = TileMode.clamp
) : base(colors: colors, stops: stops) {
this.center = center ?? Alignment.center;

public readonly Alignment center;
public readonly double radius;
public readonly float radius;
public readonly TileMode tileMode;

);
}
public override Gradient scale(double factor) {
public override Gradient scale(float factor) {
return new RadialGradient(
center: this.center,
radius: this.radius,

);
}
protected override Gradient lerpFrom(Gradient a, double t) {
protected override Gradient lerpFrom(Gradient a, float t) {
if (a == null || (a is RadialGradient && a.colors.Count == this.colors.Count)) {
return lerp((RadialGradient) a, this, t);
}

protected override Gradient lerpTo(Gradient b, double t) {
protected override Gradient lerpTo(Gradient b, float t) {
if (b == null || (b is RadialGradient && b.colors.Count == this.colors.Count)) {
return lerp(this, (RadialGradient) b, t);
}

public static RadialGradient lerp(RadialGradient a, RadialGradient b, double t) {
public static RadialGradient lerp(RadialGradient a, RadialGradient b, float t) {
if (a == null && b == null) {
return null;
}

}
if (b == null) {
return (RadialGradient) a.scale(1.0 - t);
return (RadialGradient) a.scale(1.0f - t);
}
_ColorsAndStops interpolated =

radius: Math.Max(0.0, MathUtils.lerpDouble(a.radius, b.radius, t)),
radius: Mathf.Max(0.0f, MathUtils.lerpfloat(a.radius, b.radius, t)),
colors: interpolated.colors,
stops: interpolated.stops,
tileMode: t < 0.5 ? a.tileMode : b.tileMode

public class SweepGradient : Gradient, IEquatable<SweepGradient> {
public SweepGradient(
Alignment center = null,
double startAngle = 0.0,
double endAngle = Math.PI * 2,
float startAngle = 0.0f,
float endAngle = Mathf.PI * 2,
List<double> stops = null,
List<float> stops = null,
TileMode tileMode = TileMode.clamp
) : base(colors: colors, stops: stops) {
this.center = center ?? Alignment.center;

public readonly Alignment center;
public readonly double startAngle;
public readonly float startAngle;
public readonly double endAngle;
public readonly float endAngle;
public readonly TileMode tileMode;

);
}
public override Gradient scale(double factor) {
public override Gradient scale(float factor) {
return new SweepGradient(
center: this.center,
startAngle: this.startAngle,

);
}
protected override Gradient lerpFrom(Gradient a, double t) {
protected override Gradient lerpFrom(Gradient a, float t) {
if (a == null || (a is SweepGradient && a.colors.Count == this.colors.Count)) {
return lerp((SweepGradient) a, this, t);
}

protected override Gradient lerpTo(Gradient b, double t) {
protected override Gradient lerpTo(Gradient b, float t) {
if (b == null || (b is SweepGradient && b.colors.Count == this.colors.Count)) {
return lerp(this, (SweepGradient) b, t);
}

public static SweepGradient lerp(SweepGradient a, SweepGradient b, double t) {
public static SweepGradient lerp(SweepGradient a, SweepGradient b, float t) {
if (a == null && b == null) {
return null;
}

}
if (b == null) {
return (SweepGradient) a.scale(1.0 - t);
return (SweepGradient) a.scale(1.0f - t);
}
_ColorsAndStops interpolated =

startAngle: Math.Max(0.0, MathUtils.lerpDouble(a.startAngle, b.startAngle, t)),
endAngle: Math.Max(0.0, MathUtils.lerpDouble(a.endAngle, b.endAngle, t)),
startAngle: Mathf.Max(0.0f, MathUtils.lerpfloat(a.startAngle, b.startAngle, t)),
endAngle: Mathf.Max(0.0f, MathUtils.lerpfloat(a.endAngle, b.endAngle, t)),
colors: interpolated.colors,
stops: interpolated.stops,
tileMode: t < 0.5 ? a.tileMode : b.tileMode

6
Runtime/painting/image_provider.cs


public class ImageConfiguration : IEquatable<ImageConfiguration> {
public ImageConfiguration(
AssetBundle bundle = null,
double? devicePixelRatio = null,
float? devicePixelRatio = null,
Locale locale = null,
Size size = null,
RuntimePlatform? platform = null

public ImageConfiguration copyWith(
AssetBundle bundle = null,
double? devicePixelRatio = null,
float? devicePixelRatio = null,
Locale locale = null,
Size size = null,
RuntimePlatform? platform = null

public readonly AssetBundle bundle;
public readonly double? devicePixelRatio;
public readonly float? devicePixelRatio;
public readonly Locale locale;

2
Runtime/painting/image_resolution.cs


});
}
IEnumerator _loadAssetAsync(AssetBundle bundle, double devicePixelRatio) {
IEnumerator _loadAssetAsync(AssetBundle bundle, float devicePixelRatio) {
var extension = Path.GetExtension(this.assetName);
var name = Path.GetFileNameWithoutExtension(this.assetName);

12
Runtime/painting/rounded_rectangle_border.cs


}
if (rect.width < rect.height) {
double delta = this.circleness * (rect.height - rect.width) / 2.0;
float delta = this.circleness * (rect.height - rect.width) / 2.0f;
(float) (rect.top + delta),
(rect.top + delta),
(float) (rect.bottom - delta)
(rect.bottom - delta)
double delta = this.circleness * (rect.width - rect.height) / 2.0;
float delta = this.circleness * (rect.width - rect.height) / 2.0f;
(float) (rect.left + delta),
(rect.left + delta),
(float) (rect.right - delta),
(rect.right - delta),
rect.bottom
);
}

52
Runtime/painting/stadium_border.cs


if (a is CircleBorder circleBorder) {
return new _StadiumToCircleBorder(
side: BorderSide.lerp(circleBorder.side, this.side, t),
circleness: 1.0 - t
circleness: 1.0f - t
);
}

borderRadius: rectBorder.borderRadius,
rectness: 1.0 - t
rectness: 1.0f - t
);
}

class _StadiumToCircleBorder : ShapeBorder, IEquatable<_StadiumToCircleBorder> {
public _StadiumToCircleBorder(
BorderSide side = null,
double circleness = 0.0
float circleness = 0.0f
) {
this.side = BorderSide.none;
this.circleness = circleness;

public readonly double circleness;
public readonly float circleness;
public override EdgeInsets dimensions {
get { return EdgeInsets.all(this.side.width); }

if (a is CircleBorder circleBorder) {
return new _StadiumToCircleBorder(
side: BorderSide.lerp(circleBorder.side, this.side, t),
circleness: this.circleness + (1.0 - this.circleness) * (1.0 - t)
circleness: this.circleness + (1.0f - this.circleness) * (1.0f - t)
);
}

circleness: MathUtils.lerpDouble(border.circleness, this.circleness, t)
circleness: MathUtils.lerpfloat(border.circleness, this.circleness, t)
);
}

if (b is StadiumBorder stadiumBorder) {
return new _StadiumToCircleBorder(
side: BorderSide.lerp(this.side, stadiumBorder.side, t),
circleness: this.circleness * (1.0 - t)
circleness: this.circleness * (1.0f - t)
);
}

circleness: this.circleness + (1.0 - this.circleness) * t
circleness: this.circleness + (1.0f - this.circleness) * t
);
}

circleness: MathUtils.lerpDouble(this.circleness, border.circleness, t)
circleness: MathUtils.lerpfloat(this.circleness, border.circleness, t)
);
}

Rect _adjustRect(Rect rect) {
if (this.circleness == 0.0 || rect.width == rect.height) {
if (this.circleness == 0.0f || rect.width == rect.height) {
double delta = this.circleness * (rect.height - rect.width) / 2.0;
float delta = this.circleness * (rect.height - rect.width) / 2.0f;
(float) (rect.top + delta),
rect.top + delta,
(float) (rect.bottom - delta)
rect.bottom - delta
double delta = this.circleness * (rect.width - rect.height) / 2.0;
float delta = this.circleness * (rect.width - rect.height) / 2.0f;
(float) (rect.left + delta),
(rect.left + delta),
(float) (rect.right - delta),
(rect.right - delta),
rect.bottom
);
}

break;
case BorderStyle.solid:
float width = this.side.width;
if (width == 0.0) {
if (width == 0.0f) {
canvas.drawRRect(this._adjustBorderRadius(rect).toRRect(this._adjustRect(rect)),
this.side.toPaint());
}

public _StadiumToRoundedRectangleBorder(
BorderSide side = null,
BorderRadius borderRadius = null,
double rectness = 0.0
float rectness = 0.0f
) {
this.side = side ?? BorderSide.none;
this.borderRadius = borderRadius ?? BorderRadius.zero;

public readonly BorderRadius borderRadius;
public readonly double rectness;
public readonly float rectness;
public override EdgeInsets dimensions {
get { return EdgeInsets.all(this.side.width); }

return new _StadiumToRoundedRectangleBorder(
side: BorderSide.lerp(rectBorder.side, this.side, t),
borderRadius: this.borderRadius,
rectness: this.rectness + (1.0 - this.rectness) * (1.0 - t)
rectness: this.rectness + (1.0f - this.rectness) * (1.0f - t)
);
}

borderRadius: BorderRadius.lerp(border.borderRadius, this.borderRadius, t),
rectness: MathUtils.lerpDouble(border.rectness, this.rectness, t)
rectness: MathUtils.lerpfloat(border.rectness, this.rectness, t)
);
}

return new _StadiumToRoundedRectangleBorder(
side: BorderSide.lerp(this.side, stadiumBorder.side, t),
borderRadius: this.borderRadius,
rectness: this.rectness * (1.0 - t)
rectness: this.rectness * (1.0f - t)
);
}

borderRadius: this.borderRadius,
rectness: this.rectness + (1.0 - this.rectness) * t
rectness: this.rectness + (1.0f - this.rectness) * t
);
}

borderRadius: BorderRadius.lerp(this.borderRadius, border.borderRadius, t),
rectness: MathUtils.lerpDouble(this.rectness, border.rectness, t)
rectness: MathUtils.lerpfloat(this.rectness, border.rectness, t)
);
}

return BorderRadius.lerp(
this.borderRadius,
BorderRadius.all(Radius.circular(rect.shortestSide / 2.0f)),
(float) (1.0 - this.rectness)
(1.0f - this.rectness)
);
}

break;
case BorderStyle.solid:
float width = this.side.width;
if (width == 0.0) {
if (width == 0.0f) {
canvas.drawRRect(this._adjustBorderRadius(rect).toRRect(rect), this.side.toPaint());
}
else {

10
Runtime/painting/text_painter.cs


public TextPosition getPositionVerticalMove(TextPosition position, int move) {
D.assert(!this._needsLayout);
var offset = this.getOffsetForCaret(position, Rect.zero);
var lineIndex = Math.Min(Math.Max(this._paragraph.getLine(position) + move, 0),
var lineIndex = Mathf.Min(Mathf.Max(this._paragraph.getLine(position) + move, 0),
this._paragraph.getLineCount() - 1);
var targetLineStart = this._paragraph.getLineRange(lineIndex).start;
var newLineOffset = this.getOffsetForCaret(new TextPosition(targetLineStart), Rect.zero);

public TextPosition getWordLeft(TextPosition position) {
D.assert(!this._needsLayout);
var offset = Math.Max(position.offset - 1, 0);
var offset = Mathf.Max(position.offset - 1, 0);
while (true) {
var range = this._paragraph.getWordBoundary(offset);
if (!char.IsWhiteSpace((char) (this.text.codeUnitAt(range.start) ?? 0))) {

offset = Math.Max(range.start - 1, 0);
offset = Mathf.Max(range.start - 1, 0);
if (offset == 0) {
break;
}

}
}
float _applyFloatingPointHack(double layoutValue) {
return (float) Math.Ceiling(layoutValue);
float _applyFloatingPointHack(float layoutValue) {
return Mathf.Ceil(layoutValue);
}

2
Runtime/painting/text_span.cs


this.children = children;
}
public void build(ParagraphBuilder builder, double textScaleFactor = 1.0) {
public void build(ParagraphBuilder builder, float textScaleFactor = 1.0f) {
var hasTyle = this.style != null;
if (hasTyle) {
builder.pushStyle(this.style);

8
Runtime/painting/text_style.cs


defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new StringProperty("family", this.fontFamily, defaultValue: Diagnostics.kNullDefaultValue,
quoted: false));
styles.Add(new DiagnosticsProperty<double?>("size", this.fontSize,
styles.Add(new DiagnosticsProperty<float?>("size", this.fontSize,
defaultValue: Diagnostics.kNullDefaultValue));
string weightDescription = "";
if (this.fontWeight != null) {

));
styles.Add(new EnumProperty<FontStyle?>("style", this.fontStyle,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("letterSpacing", this.letterSpacing,
styles.Add(new DiagnosticsProperty<float?>("letterSpacing", this.letterSpacing,
styles.Add(new DiagnosticsProperty<double?>("wordSpacing", this.wordSpacing,
styles.Add(new DiagnosticsProperty<float?>("wordSpacing", this.wordSpacing,
styles.Add(new DiagnosticsProperty<double?>("height", this.height,
styles.Add(new DiagnosticsProperty<float?>("height", this.height,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new StringProperty("background", this.background == null ? null : this.background.ToString(),
defaultValue: Diagnostics.kNullDefaultValue, quoted: false));

11
Runtime/physics/friction_simulation.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.physics {
public class FrictionSimulation : Simulation {

) : base(tolerance: tolerance) {
this._drag = drag;
this._dragLog = (float) Math.Log(drag);
this._dragLog = Mathf.Log(drag);
this._x = position;
this._v = velocity;
}

readonly float _v;
static float _dragFor(float startPosition, float endPosition, float startVelocity, float endVelocity) {
return (float) Math.Pow(Math.E, (startVelocity - endVelocity) / (startPosition - endPosition));
return Mathf.Pow((float) Math.E, (startVelocity - endVelocity) / (startPosition - endPosition));
return this._x + this._v * (float) Math.Pow(this._drag, time) / this._dragLog - this._v / this._dragLog;
return this._x + this._v * Mathf.Pow(this._drag, time) / this._dragLog - this._v / this._dragLog;
return this._v * (float) Math.Pow(this._drag, time);
return this._v * Mathf.Pow(this._drag, time);
}
public float finalX {

return float.PositiveInfinity;
}
return (float) Math.Log(this._dragLog * (x - this._x) / this._v + 1.0) / this._dragLog;
return Mathf.Log(this._dragLog * (x - this._x) / this._v + 1.0f) / this._dragLog;
}
public override bool isDone(float time) {

101
Runtime/physics/spring_simulation.cs


using System;
using Unity.UIWidgets.foundation;
using UnityEngine;
double mass,
double stiffness,
double damping
float mass,
float stiffness,
float damping
) {
this.mass = mass;
this.stiffness = stiffness;

public static SpringDescription withDampingRatio(
double mass,
double stiffness,
double ratio = 1.0
float mass,
float stiffness,
float ratio = 1.0f
var damping = ratio * 2.0 * Math.Sqrt(mass * stiffness);
var damping = ratio * 2.0f * Mathf.Sqrt(mass * stiffness);
public readonly double mass;
public readonly float mass;
public readonly double stiffness;
public readonly float stiffness;
public readonly double damping;
public readonly float damping;
public override string ToString() {
return $"{this.GetType()}(mass {this.mass:F1}, stiffness: {this.stiffness:F1}, damping: {this.damping:F1})";

abstract class _SpringSolution {
internal static _SpringSolution create(
SpringDescription spring,
double initialPosition,
double initialVelocity
float initialPosition,
float initialVelocity
double cmk = spring.damping * spring.damping - 4 * spring.mass * spring.stiffness;
float cmk = spring.damping * spring.damping - 4 * spring.mass * spring.stiffness;
if (cmk == 0.0) {
return _CriticalSolution.create(spring, initialPosition, initialVelocity);

class _CriticalSolution : _SpringSolution {
internal new static _CriticalSolution create(
SpringDescription spring,
double distance,
double velocity
float distance,
float velocity
double r = -spring.damping / (2.0 * spring.mass);
double c1 = distance;
double c2 = velocity / (r * distance);
float r = -spring.damping / (2.0f * spring.mass);
float c1 = distance;
float c2 = velocity / (r * distance);
double r, double c1, double c2
float r, float c1, float c2
) {
this._r = r;
this._c1 = c1;

readonly double _r, _c1, _c2;
readonly float _r, _c1, _c2;
return (float) ((this._c1 + this._c2 * time) * Math.Pow(Math.E, this._r * time));
return ((this._c1 + this._c2 * time) * Mathf.Pow((float) Math.E, this._r * time));
double power = Math.Pow(Math.E, this._r * time);
return (float) (this._r * (this._c1 + this._c2 * time) * power + this._c2 * power);
float power = Mathf.Pow((float) Math.E, this._r * time);
return (this._r * (this._c1 + this._c2 * time) * power + this._c2 * power);
}
public override SpringType type {

float distance,
float velocity
) {
double cmk = spring.damping * spring.damping - 4 * spring.mass * spring.stiffness;
double r1 = (-spring.damping - Math.Sqrt(cmk)) / (2.0 * spring.mass);
double r2 = (-spring.damping + Math.Sqrt(cmk)) / (2.0 * spring.mass);
double c2 = (velocity - r1 * distance) / (r2 - r1);
double c1 = distance - c2;
float cmk = spring.damping * spring.damping - 4 * spring.mass * spring.stiffness;
float r1 = (-spring.damping - Mathf.Sqrt(cmk)) / (2.0f * spring.mass);
float r2 = (-spring.damping + Mathf.Sqrt(cmk)) / (2.0f * spring.mass);
float c2 = (velocity - r1 * distance) / (r2 - r1);
float c1 = distance - c2;
double r1, double r2, double c1, double c2
float r1, float r2, float c1, float c2
) {
this._r1 = r1;
this._r2 = r2;

readonly double _r1, _r2, _c1, _c2;
readonly float _r1, _r2, _c1, _c2;
return (float) (this._c1 * Math.Pow(Math.E, this._r1 * time) +
this._c2 * Math.Pow(Math.E, this._r2 * time));
return (this._c1 * Mathf.Pow((float) Math.E, this._r1 * time) +
this._c2 * Mathf.Pow((float) Math.E, this._r2 * time));
return (float) (this._c1 * this._r1 * Math.Pow(Math.E, this._r1 * time) +
this._c2 * this._r2 * Math.Pow(Math.E, this._r2 * time));
return (this._c1 * this._r1 * Mathf.Pow((float) Math.E, this._r1 * time) +
this._c2 * this._r2 * Mathf.Pow((float) Math.E, this._r2 * time));
}
public override SpringType type {

class _UnderdampedSolution : _SpringSolution {
internal new static _UnderdampedSolution create(
SpringDescription spring,
double distance,
double velocity
float distance,
float velocity
double w = Math.Sqrt(4.0 * spring.mass * spring.stiffness -
spring.damping * spring.damping) / (2.0 * spring.mass);
double r = -(spring.damping / 2.0 * spring.mass);
double c1 = distance;
double c2 = (velocity - r * distance) / w;
float w = Mathf.Sqrt(4.0f * spring.mass * spring.stiffness -
spring.damping * spring.damping) / (2.0f * spring.mass);
float r = -(spring.damping / 2.0f * spring.mass);
float c1 = distance;
float c2 = (velocity - r * distance) / w;
double w, double r, double c1, double c2
float w, float r, float c1, float c2
) {
this._w = w;
this._r = r;

readonly double _w, _r, _c1, _c2;
readonly float _w, _r, _c1, _c2;
return (float) (Math.Pow(Math.E, this._r * time) *
(this._c1 * Math.Cos(this._w * time) + this._c2 * Math.Sin(this._w * time)));
return (Mathf.Pow((float) Math.E, this._r * time) *
(this._c1 * Mathf.Cos(this._w * time) + this._c2 * Mathf.Sin(this._w * time)));
double power = Math.Pow(Math.E, this._r * time);
double cosine = Math.Cos(this._w * time);
double sine = Math.Sin(this._w * time);
return (float) (power * (this._c2 * this._w * cosine - this._c1 * this._w * sine) +
this._r * power * (this._c2 * sine + this._c1 * cosine));
float power = Mathf.Pow((float) Math.E, this._r * time);
float cosine = Mathf.Cos(this._w * time);
float sine = Mathf.Sin(this._w * time);
return (power * (this._c2 * this._w * cosine - this._c1 * this._w * sine) +
this._r * power * (this._c2 * sine + this._c1 * cosine));
}
public override SpringType type {

6
Runtime/physics/utils.cs


namespace Unity.UIWidgets.physics {
public class PhysicsUtils {
public static bool nearEqual(double? a, double? b, double epsilon) {
public static bool nearEqual(float? a, float? b, float epsilon) {
D.assert(epsilon >= 0.0);
if (a == null || b == null) {
return a == b;

}
public static bool nearZero(double? a, double epsilon) {
return nearEqual(a, 0.0, epsilon);
public static bool nearZero(float? a, float epsilon) {
return nearEqual(a, 0.0f, epsilon);
}
}
}

4
Runtime/rendering/animated_size.cs


CurvedAnimation _animation;
readonly SizeTween _sizeTween = new SizeTween();
bool _hasVisualOverflow;
double _lastValue;
float _lastValue;
public RenderAnimatedSizeState state {
get { return this._state; }

}
void _restartAnimation() {
this._lastValue = 0.0;
this._lastValue = 0.0f;
this._controller.forward(from: 0.0f);
}

81
Runtime/rendering/box.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
class _DebugSize : Size {

float height = float.PositiveInfinity
) {
return new BoxConstraints(
!double.IsPositiveInfinity(width) ? width : 0.0f,
!double.IsPositiveInfinity(width) ? width : float.PositiveInfinity,
!double.IsPositiveInfinity(height) ? height : 0.0f,
!double.IsPositiveInfinity(height) ? height : float.PositiveInfinity
!float.IsPositiveInfinity(width) ? width : 0.0f,
!float.IsPositiveInfinity(width) ? width : float.PositiveInfinity,
!float.IsPositiveInfinity(height) ? height : 0.0f,
!float.IsPositiveInfinity(height) ? height : float.PositiveInfinity
);
}

D.assert(this.debugAssertIsValid());
float horizontal = edges.horizontal;
float vertical = edges.vertical;
float deflatedMinWidth = (float) Math.Max(0.0, this.minWidth - horizontal);
float deflatedMinHeight = (float) Math.Max(0.0, this.minHeight - vertical);
float deflatedMinWidth = Mathf.Max(0.0f, this.minWidth - horizontal);
float deflatedMinHeight = Mathf.Max(0.0f, this.minHeight - vertical);
maxWidth: Math.Max(deflatedMinWidth, this.maxWidth - horizontal),
maxWidth: Mathf.Max(deflatedMinWidth, this.maxWidth - horizontal),
maxHeight: Math.Max(deflatedMinHeight, this.maxHeight - vertical)
maxHeight: Mathf.Max(deflatedMinHeight, this.maxHeight - vertical)
);
}

}
public bool hasBoundedWidth {
get { return this.maxWidth < double.PositiveInfinity; }
get { return this.maxWidth < float.PositiveInfinity; }
get { return this.maxHeight < double.PositiveInfinity; }
get { return this.maxHeight < float.PositiveInfinity; }
get { return this.minWidth >= double.PositiveInfinity; }
get { return this.minWidth >= float.PositiveInfinity; }
get { return this.minHeight >= double.PositiveInfinity; }
get { return this.minHeight >= float.PositiveInfinity; }
}
public bool isSatisfiedBy(Size size) {

D.assert(b.debugAssertIsValid());
D.assert(
(a.minWidth.isFinite() && b.minWidth.isFinite()) ||
(a.minWidth == double.PositiveInfinity && b.minWidth == double.PositiveInfinity),
(a.minWidth == float.PositiveInfinity && b.minWidth == float.PositiveInfinity),
(a.maxWidth == double.PositiveInfinity && b.maxWidth == double.PositiveInfinity),
(a.maxWidth == float.PositiveInfinity && b.maxWidth == float.PositiveInfinity),
(a.minHeight == double.PositiveInfinity && b.minHeight == double.PositiveInfinity),
(a.minHeight == float.PositiveInfinity && b.minHeight == float.PositiveInfinity),
(a.maxHeight == double.PositiveInfinity && b.maxHeight == double.PositiveInfinity),
(a.maxHeight == float.PositiveInfinity && b.maxHeight == float.PositiveInfinity),
"Cannot interpolate between finite constraints and unbounded constraints.");
return new BoxConstraints(
minWidth: a.minWidth.isFinite()

public override string ToString() {
string annotation = this.isNormalized ? "" : "; NOT NORMALIZED";
if (this.minWidth == double.PositiveInfinity &&
this.minHeight == double.PositiveInfinity) {
if (this.minWidth == float.PositiveInfinity &&
this.minHeight == float.PositiveInfinity) {
if (this.minWidth == 0 && this.maxWidth == double.PositiveInfinity &&
this.minHeight == 0 && this.maxHeight == double.PositiveInfinity) {
if (this.minWidth == 0 && this.maxWidth == float.PositiveInfinity &&
this.minHeight == 0 && this.maxHeight == float.PositiveInfinity) {
var describe = new Func<double, double, string, string>((min, max, dim) => {
var describe = new Func<float, float, string, string>((min, max, dim) => {
if (min == max) {
return dim + "=" + min.ToString("F1");
}

}
class _IntrinsicDimensionsCacheEntry : IEquatable<_IntrinsicDimensionsCacheEntry> {
internal _IntrinsicDimensionsCacheEntry(_IntrinsicDimension dimension, double argument) {
internal _IntrinsicDimensionsCacheEntry(_IntrinsicDimension dimension, float argument) {
public readonly double argument;
public readonly float argument;
public bool Equals(_IntrinsicDimensionsCacheEntry other) {
if (ReferenceEquals(null, other)) {

"The height argument to getMinIntrinsicWidth was negative.\n" +
"The argument to getMinIntrinsicWidth must not be negative. " +
"If you perform computations on another height before passing it to " +
"getMinIntrinsicWidth, consider using math.max() or double.clamp() " +
"getMinIntrinsicWidth, consider using mathf.max() or float.clamp() " +
"to force the value into the valid range."
);
}

"The height argument to getMaxIntrinsicWidth was negative.\n" +
"The argument to getMaxIntrinsicWidth must not be negative. " +
"If you perform computations on another height before passing it to " +
"getMaxIntrinsicWidth, consider using math.max() or double.clamp() " +
"getMaxIntrinsicWidth, consider using mathf.max() or float.clamp() " +
"to force the value into the valid range."
);
}

"The width argument to getMinIntrinsicHeight was negative.\n" +
"The argument to getMinIntrinsicHeight must not be negative. " +
"If you perform computations on another width before passing it to " +
"getMinIntrinsicHeight, consider using math.max() or double.clamp() " +
"getMinIntrinsicHeight, consider using mathf.max() or float.clamp() " +
"to force the value into the valid range."
);
}

"The width argument to getMaxIntrinsicHeight was negative.\n" +
"The argument to getMaxIntrinsicHeight must not be negative. " +
"If you perform computations on another width before passing it to " +
"getMaxIntrinsicHeight, consider using math.max() or double.clamp() " +
"getMaxIntrinsicHeight, consider using mathf.max() or float.clamp() " +
"to force the value into the valid range."
);
}

failureCount += 1;
}
return (float) result;
return result;
});
var testIntrinsicsForValues =

if (this.constraints.hasBoundedWidth) {
testIntrinsicsForValues(this.getMinIntrinsicWidth, this.getMaxIntrinsicWidth, "Width",
(float) this.constraints.maxWidth);
this.constraints.maxWidth);
(float) this.constraints.maxHeight);
this.constraints.maxHeight);
}
debugCheckingIntrinsics = false;

var childParentData = (BoxParentData) child.parentData;
var offset = childParentData.offset;
transform.preTranslate((float) offset.dx, (float) offset.dy);
transform.preTranslate(offset.dx, offset.dy);
}
public Offset globalToLocal(Offset point, RenderObject ancestor = null) {

// ..strokeWidth = 0.25;
// Path path;
// // ideographic baseline
// final double baselineI = getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true);
// final float baselineI = getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true);
// if (baselineI != null) {
// paint.color = const Color (0xFFFFD000);
// path = Path();

// }
//
// // alphabetic baseline
// final double baselineA = getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true);
// final float baselineA = getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true);
// if (baselineA != null) {
// paint.color = const Color (0xFF00FF00);
// path = Path();

: ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType>
where ChildType : RenderBox
where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public double? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
public float? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
double? result = child.getDistanceToActualBaseline(baseline);
float? result = child.getDistanceToActualBaseline(baseline);
if (result != null) {
return result.Value + childParentData.offset.dy;
}

return null;
}
public double? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
double? result = null;
float? result = null;
double? candidate = child.getDistanceToActualBaseline(baseline);
float? candidate = child.getDistanceToActualBaseline(baseline);
result = Math.Min(result.Value, candidate.Value);
result = Mathf.Min(result.Value, candidate.Value);
}
else {
result = candidate;

3
Runtime/rendering/box.mixin.gen.cs


using System.Collections.Generic;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.rendering {
public abstract class

if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = (float) Math.Min(result.Value, candidate.Value);
result = Mathf.Min(result.Value, candidate.Value);
}
else {
result = candidate;

3
Runtime/rendering/box.mixin.njk


using System;
using System.Collections.Generic;
using UnityEngine;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;

if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = Math.Min(result.Value, candidate.Value);
result = Mathf.Min(result.Value, candidate.Value);
} else {
result = candidate;
}

8
Runtime/rendering/custom_layout.cs


}
protected override float computeMinIntrinsicWidth(float height) {
float width = (float) this._getSize(BoxConstraints.tightForFinite(height: height)).width;
float width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
if (!float.IsInfinity(width)) {
return width;
}

protected override float computeMaxIntrinsicWidth(float height) {
float width = (float) this._getSize(BoxConstraints.tightForFinite(height: height)).width;
float width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
if (!float.IsInfinity(width)) {
return width;
}

protected override float computeMinIntrinsicHeight(float width) {
float height = (float) this._getSize(BoxConstraints.tightForFinite(width: width)).height;
float height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
if (!float.IsInfinity(height)) {
return height;
}

protected override float computeMaxIntrinsicHeight(float width) {
float height = (float) this._getSize(BoxConstraints.tightForFinite(width: width)).height;
float height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
if (!float.IsInfinity(height)) {
return height;
}

2
Runtime/rendering/custom_paint.cs


return true;
});
if (offset != Offset.zero) {
canvas.translate((float) offset.dx, (float) offset.dy);
canvas.translate(offset.dx, offset.dy);
}
painter.paint(canvas, this.size);

54
Runtime/rendering/editable.cs


public enum SelectionChangedCause {
tap,
doubleTap,
floatTap,
longPress,
keyboard,
}

}
}
/*
this._doubleTapGesture = new DoubleTapGestureRecognizer(this.rendererBindings.rendererBinding);
this._doubleTapGesture.onDoubleTap = () => { Debug.Log("onDoubleTap"); };*/
this._floatTapGesture = new floatTapGestureRecognizer(this.rendererBindings.rendererBinding);
this._floatTapGesture.onfloatTap = () => { Debug.Log("onfloatTap"); };*/
public class RenderEditable : RenderBox {
public static readonly char obscuringCharacter = '•';

bool _obscureText;
TapGestureRecognizer _tap;
LongPressGestureRecognizer _longPress;
DoubleTapGestureRecognizer _doubleTap;
floatTapGestureRecognizer _floatTap;
public bool ignorePointer;
public SelectionChangedHandler onSelectionChanged;
public CaretChangedHandler onCaretChanged;

D.assert(!this._showCursor.value || cursorColor != null);
this._tap = new TapGestureRecognizer(this);
this._doubleTap = new DoubleTapGestureRecognizer(this);
this._floatTap = new floatTapGestureRecognizer(this);
this._doubleTap.onDoubleTap = this._handleDoubleTap;
this._floatTap.onfloatTap = this._handlefloatTap;
this._longPress = new LongPressGestureRecognizer(debugOwner: this);
this._longPress.onLongPress = this._handleLongPress;
}

///
public List<TextSelectionPoint> getEndpointsForSelection(TextSelection selection) {
D.assert(this.constraints != null);
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
var paintOffset = this._paintOffset;
if (selection.isCollapsed) {
var caretOffset = this._textPainter.getOffsetForCaret(selection.extendPos, this._caretPrototype);

}
public TextPosition getPositionForPoint(Offset globalPosition) {
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
var caretOffset = this._textPainter.getOffsetForCaret(caretPosition, this._caretPrototype);
return Rect.fromLTWH(0.0f, 0.0f, _kCaretWidth, this.preferredLineHeight)
.shift(caretOffset + this._paintOffset);

}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
return this._textPainter.computeDistanceToActualBaseline(baseline);
}

D.assert(this.debugHandleEvent(evt, entry));
if (evt is PointerDownEvent && this.onSelectionChanged != null) {
this._tap.addPointer((PointerDownEvent) evt);
this._doubleTap.addPointer((PointerDownEvent) evt);
this._floatTap.addPointer((PointerDownEvent) evt);
this._longPress.addPointer((PointerDownEvent) evt);
}
}

}
public void handleTap() {
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
D.assert(this._lastTapDownPosition != null);
if (this.onSelectionChanged != null) {
var position = this._textPainter.getPositionForOffset(this.globalToLocal(this._lastTapDownPosition));

public void handleDoubleTap(DoubleTapDetails details) {
public void handlefloatTap(floatTapDetails details) {
this.selectWord(cause: SelectionChangedCause.doubleTap);
this.selectWord(cause: SelectionChangedCause.floatTap);
}
public void handleLongPress() {

void selectWord(SelectionChangedCause? cause = null) {
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
D.assert(this._lastTapDownPosition != null);
if (this.onSelectionChanged != null) {
TextPosition position =

}
protected override void performLayout() {
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
this._caretPrototype = Rect.fromLTWH(0.0f, _kCaretHeightOffset, _kCaretWidth,
this.preferredLineHeight - 2.0f * _kCaretHeightOffset);
this._selectionRects = null;

this.constraints.constrainHeight(this._preferredHeight((float) this.constraints.maxWidth)));
this.constraints.constrainHeight(this._preferredHeight(this.constraints.maxWidth)));
var contentSize = new Size(textPainterSize.width + _kCaretGap + _kCaretWidth,
textPainterSize.height);
var _maxScrollExtent = this._getMaxScrollExtend(contentSize);

}
public override void paint(PaintingContext context, Offset offset) {
this._layoutText((float) this.constraints.maxWidth);
this._layoutText(this.constraints.maxWidth);
if (this._hasVisualOverflow) {
context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, this._paintContents);
}

var caretOffset = this._textPainter.getOffsetForCaret(this._selection.extendPos,
Rect.fromLTWH(0, 0, 1, this.preferredLineHeight));
var caretRec = this._caretPrototype.shift(caretOffset + effectiveOffset);
Input.compositionCursorPos = new Vector2((float) caretRec.left, (float) caretRec.bottom);
Input.compositionCursorPos = new Vector2(caretRec.left, caretRec.bottom);
}
this._textPainter.paint(context.canvas, effectiveOffset);

this.handleTap();
}
void _handleDoubleTap(DoubleTapDetails details) {
void _handlefloatTap(floatTapDetails details) {
this.handleDoubleTap(details);
this.handlefloatTap(details);
}
void _handleLongPress() {

return this.preferredLineHeight * this.maxLines.Value;
}
if (double.IsInfinity(width)) {
if (float.IsInfinity(width)) {
var text = this._textPainter.text.text;
int lines = 1;
for (int index = 0; index < text.Length; ++index) {

}
this._layoutText(width);
return (float) Math.Max(this.preferredLineHeight, this._textPainter.height);
return Mathf.Max(this.preferredLineHeight, this._textPainter.height);
}
void _layoutText(float constraintWidth) {

var caretMargin = _kCaretGap + _kCaretWidth;
var avialableWidth = (float) Math.Max(0.0, constraintWidth - caretMargin);
var avialableWidth = Mathf.Max(0.0f, constraintWidth - caretMargin);
var maxWidth = this._isMultiline ? avialableWidth : float.PositiveInfinity;
this._textPainter.layout(minWidth: avialableWidth, maxWidth: maxWidth);
this._textLayoutLastWidth = constraintWidth;

D.assert(this.hasSize);
switch (this._viewportAxis) {
case Axis.horizontal:
return (float) Math.Max(0.0, contentSize.width - this.size.width);
return Mathf.Max(0.0f, contentSize.width - this.size.width);
return (float) Math.Max(0.0, contentSize.height - this.size.height);
return Mathf.Max(0.0f, contentSize.height - this.size.height);
}
return 0.0f;

properties.add(new DiagnosticsProperty<ValueNotifier<bool>>("showCursor", this.showCursor));
properties.add(new DiagnosticsProperty<int?>("maxLines", this.maxLines));
properties.add(new DiagnosticsProperty<Color>("selectionColor", this.selectionColor));
properties.add(new DiagnosticsProperty<double>("textScaleFactor", this.textScaleFactor));
properties.add(new DiagnosticsProperty<float>("textScaleFactor", this.textScaleFactor));
properties.add(new DiagnosticsProperty<TextSelection>("selection", this.selection));
properties.add(new DiagnosticsProperty<ViewportOffset>("offset", this.offset));
}

127
Runtime/rendering/flex.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.rendering {
public enum FlexFit {

public TextBaseline _textBaseline;
public double _overflow;
public float _overflow;
public override void setupParentData(RenderObject child) {
if (!(child.parentData is FlexParentData)) {

int flex = this._getFlex(child);
totalFlex += flex;
if (flex > 0) {
double flexFraction = childSize(child, extent) / this._getFlex(child);
maxFlexFractionSoFar = (float) Math.Max(maxFlexFractionSoFar, flexFraction);
float flexFraction = childSize(child, extent) / this._getFlex(child);
maxFlexFractionSoFar = Mathf.Max(maxFlexFractionSoFar, flexFraction);
}
else {
inflexibleSpace += childSize(child, extent);

return maxFlexFractionSoFar * totalFlex + inflexibleSpace;
}
else {
double availableMainSpace = extent;
float availableMainSpace = extent;
int totalFlex = 0;
float inflexibleSpace = 0.0f;
float maxCrossSize = 0.0f;

}
inflexibleSpace += mainSize;
maxCrossSize = Math.Max(maxCrossSize, crossSize);
maxCrossSize = Mathf.Max(maxCrossSize, crossSize);
}
var childParentData = (FlexParentData) child.parentData;

float spacePerFlex = (float) Math.Max(0.0, (availableMainSpace - inflexibleSpace) / totalFlex);
float spacePerFlex = Mathf.Max(0.0f, (availableMainSpace - inflexibleSpace) / totalFlex);
maxCrossSize = Math.Max(maxCrossSize, childSize(child, spacePerFlex * flex));
maxCrossSize = Mathf.Max(maxCrossSize, childSize(child, spacePerFlex * flex));
}
var childParentData = (FlexParentData) child.parentData;

return childParentData.fit;
}
public double _getCrossSize(RenderBox child) {
public float _getCrossSize(RenderBox child) {
switch (this._direction) {
case Axis.horizontal:
return child.size.height;

return 0;
}
public double _getMainSize(RenderBox child) {
public float _getMainSize(RenderBox child) {
switch (this._direction) {
case Axis.horizontal:
return child.size.width;

protected override void performLayout() {
int totalFlex = 0;
int totalChildren = 0;
double maxMainSize = this._direction == Axis.horizontal
float maxMainSize = this._direction == Axis.horizontal
bool canFlex = maxMainSize < double.PositiveInfinity;
bool canFlex = maxMainSize < float.PositiveInfinity;
double crossSize = 0.0;
double allocatedSize = 0.0;
float crossSize = 0.0f;
float allocatedSize = 0.0f;
RenderBox child = this.firstChild;
RenderBox lastFlexChild = null;
while (child != null) {

child.layout(innerConstraints, parentUsesSize: true);
allocatedSize += this._getMainSize(child);
crossSize = Math.Max(crossSize, this._getCrossSize(child));
crossSize = Mathf.Max(crossSize, this._getCrossSize(child));
double freeSpace = Math.Max(0.0, (canFlex ? maxMainSize : 0.0) - allocatedSize);
double allocatedFlexSpace = 0.0;
double maxBaselineDistance = 0.0;
float freeSpace = Mathf.Max(0.0f, (canFlex ? maxMainSize : 0.0f) - allocatedSize);
float allocatedFlexSpace = 0.0f;
float maxBaselineDistance = 0.0f;
double spacePerFlex = canFlex && totalFlex > 0 ? (freeSpace / totalFlex) : double.NaN;
float spacePerFlex = canFlex && totalFlex > 0 ? (freeSpace / totalFlex) : float.NaN;
double maxChildExtent = canFlex
float maxChildExtent = canFlex
: double.PositiveInfinity;
double minChildExtent = 0.0;
: float.PositiveInfinity;
float minChildExtent = 0.0f;
minChildExtent = 0.0;
minChildExtent = 0.0f;
break;
}

case Axis.horizontal:
innerConstraints = new BoxConstraints(
minWidth: (float) minChildExtent,
maxWidth: (float) maxChildExtent,
minWidth: minChildExtent,
maxWidth: maxChildExtent,
minHeight: this.constraints.maxHeight,
maxHeight: this.constraints.maxHeight);
break;

maxWidth: this.constraints.maxWidth,
minHeight: (float) minChildExtent,
maxHeight: (float) maxChildExtent);
minHeight: minChildExtent,
maxHeight: maxChildExtent);
break;
}
}

innerConstraints = new BoxConstraints(
minWidth: (float) minChildExtent,
maxWidth: (float) maxChildExtent,
minWidth: minChildExtent,
maxWidth: maxChildExtent,
minHeight: (float) minChildExtent,
maxHeight: (float) maxChildExtent);
minHeight: minChildExtent,
maxHeight: maxChildExtent);
double childSize = this._getMainSize(child);
float childSize = this._getMainSize(child);
crossSize = Math.Max(crossSize, this._getCrossSize(child));
crossSize = Mathf.Max(crossSize, this._getCrossSize(child));
double? distance = child.getDistanceToBaseline(this.textBaseline, onlyReal: true);
float? distance = child.getDistanceToBaseline(this.textBaseline, onlyReal: true);
maxBaselineDistance = Math.Max(maxBaselineDistance, distance.Value);
maxBaselineDistance = Mathf.Max(maxBaselineDistance, distance.Value);
}
}

}
double idealSize = canFlex && this.mainAxisSize == MainAxisSize.max ? maxMainSize : allocatedSize;
double actualSize = 0.0;
double actualSizeDelta = 0.0;
float idealSize = canFlex && this.mainAxisSize == MainAxisSize.max ? maxMainSize : allocatedSize;
float actualSize = 0.0f;
float actualSizeDelta = 0.0f;
this.size = this.constraints.constrain(new Size((float) idealSize, (float) crossSize));
this.size = this.constraints.constrain(new Size(idealSize, crossSize));
this.size = this.constraints.constrain(new Size((float) crossSize, (float) idealSize));
this.size = this.constraints.constrain(new Size(crossSize, idealSize));
actualSize = this.size.height;
crossSize = this.size.width;
break;

this._overflow = Math.Max(0.0, -actualSizeDelta);
this._overflow = Mathf.Max(0.0f, -actualSizeDelta);
double remainingSpace = Math.Max(0.0, actualSizeDelta);
double leadingSpace = 0.0;
double betweenSpace = 0.0;
float remainingSpace = Mathf.Max(0.0f, actualSizeDelta);
float leadingSpace = 0.0f;
float betweenSpace = 0.0f;
leadingSpace = 0.0;
betweenSpace = 0.0;
leadingSpace = 0.0f;
betweenSpace = 0.0f;
betweenSpace = 0.0;
betweenSpace = 0.0f;
leadingSpace = remainingSpace / 2.0;
betweenSpace = 0.0;
leadingSpace = remainingSpace / 2.0f;
betweenSpace = 0.0f;
leadingSpace = 0.0;
betweenSpace = totalChildren > 1 ? remainingSpace / (totalChildren - 1) : 0.0;
leadingSpace = 0.0f;
betweenSpace = totalChildren > 1 ? remainingSpace / (totalChildren - 1) : 0.0f;
betweenSpace = totalChildren > 0 ? remainingSpace / totalChildren : 0.0;
leadingSpace = betweenSpace / 2.0;
betweenSpace = totalChildren > 0 ? remainingSpace / totalChildren : 0.0f;
leadingSpace = betweenSpace / 2.0f;
betweenSpace = totalChildren > 0 ? remainingSpace / (totalChildren + 1) : 0.0;
betweenSpace = totalChildren > 0 ? remainingSpace / (totalChildren + 1) : 0.0f;
double childMainPosition = flipMainAxis ? actualSize - leadingSpace : leadingSpace;
float childMainPosition = flipMainAxis ? actualSize - leadingSpace : leadingSpace;
double childCrossPosition = 0.0;
float childCrossPosition = 0.0f;
switch (this._crossAxisAlignment) {
case CrossAxisAlignment.start:
case CrossAxisAlignment.end:

== (this._crossAxisAlignment == CrossAxisAlignment.start)
? 0.0
? 0.0f
childCrossPosition = crossSize / 2.0 - this._getCrossSize(child) / 2.0;
childCrossPosition = crossSize / 2.0f - this._getCrossSize(child) / 2.0f;
childCrossPosition = 0.0;
childCrossPosition = 0.0f;
childCrossPosition = 0.0;
childCrossPosition = 0.0f;
double? distance = child.getDistanceToBaseline(this.textBaseline, onlyReal: true);
float? distance = child.getDistanceToBaseline(this.textBaseline, onlyReal: true);
if (distance != null) {
childCrossPosition = maxBaselineDistance - distance.Value;
}

switch (this._direction) {
case Axis.horizontal:
childParentData.offset = new Offset((float) childMainPosition, (float) childCrossPosition);
childParentData.offset = new Offset(childMainPosition, childCrossPosition);
childParentData.offset = new Offset((float) childCrossPosition, (float) childMainPosition);
childParentData.offset = new Offset(childCrossPosition, childMainPosition);
break;
}

}
public override void paint(PaintingContext context, Offset offset) {
if (this._overflow <= 0.0) {
if (this._overflow <= 0.0f) {
this.defaultPaint(context, offset);
return;
}

18
Runtime/rendering/image.cs


}
return constraints.constrainSizeAndAttemptToPreserveAspectRatio(new Size(
(float) (this._image.width / this._scale),
(float) (this._image.height / this._scale)
(this._image.width / this._scale),
(this._image.height / this._scale)
));
}

return 0.0f;
}
return (float) this._sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width;
return this._sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width;
return (float) this._sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width;
return this._sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width;
}
protected override float computeMinIntrinsicHeight(float width) {

}
return (float) this._sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height;
return this._sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height;
return (float) this._sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height;
return this._sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height;
}
protected override bool hitTestSelf(Offset position) {

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Image>("image", this.image));
properties.add(new DoubleProperty("width", this.width, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new DoubleProperty("height", this.height, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new DoubleProperty("scale", this.scale, defaultValue: 1.0));
properties.add(new floatProperty("width", this.width, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new floatProperty("height", this.height, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new floatProperty("scale", this.scale, defaultValue: 1.0));
properties.add(new DiagnosticsProperty<Color>("color", this.color,
defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new EnumProperty<BlendMode>("colorBlendMode", this.colorBlendMode,

12
Runtime/rendering/layer.cs


var totalOffset = this.offset + layerOffset;
if (totalOffset != Offset.zero) {
this._lastEffectiveTransform = Matrix3.makeTrans((float) totalOffset.dx, (float) totalOffset.dy);
this._lastEffectiveTransform = Matrix3.makeTrans(totalOffset.dx, totalOffset.dy);
this._lastEffectiveTransform.preConcat(this._transform);
}

public override void applyTransform(Layer child, Matrix3 transform) {
D.assert(this._lastOffset != null);
if (this._lastOffset != Offset.zero) {
transform.preTranslate((float) this._lastOffset.dx, (float) this._lastOffset.dy);
transform.preTranslate(this._lastOffset.dx, this._lastOffset.dy);
}
}

return null;
}
Matrix3 result = Matrix3.makeTrans((float) -this._lastOffset.dx, (float) -this._lastOffset.dy);
Matrix3 result = Matrix3.makeTrans(-this._lastOffset.dx, -this._lastOffset.dy);
result.preConcat(this._lastTransform);
return result;
}

inverseTransform = inverse;
inverseTransform.preConcat(forwardTransform);
inverseTransform.preTranslate((float) this.linkedOffset.dx, (float) this.linkedOffset.dy);
inverseTransform.preTranslate(this.linkedOffset.dx, this.linkedOffset.dy);
this._lastTransform = inverseTransform;
}

}
else {
this._lastOffset = null;
var matrix = Matrix3.makeTrans((float) this.unlinkedOffset.dx, (float) this.unlinkedOffset.dy);
var matrix = Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy);
builder.pushTransform(matrix);
this.addChildrenToScene(builder, Offset.zero);
builder.pop();

transform.preConcat(this._lastTransform);
}
else {
transform.preConcat(Matrix3.makeTrans((float) this.unlinkedOffset.dx, (float) this.unlinkedOffset.dy));
transform.preConcat(Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy));
}
}

27
Runtime/rendering/list_body.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.rendering {
public class ListBodyParentData : ContainerParentDataMixinBoxParentData<RenderBox> {

);
});
double mainAxisExtent = 0.0;
float mainAxisExtent = 0.0f;
double position;
float position;
switch (this.axisDirection) {
case AxisDirection.right:

ListBodyParentData childParentData = (ListBodyParentData) child.parentData;
childParentData.offset = new Offset((float) mainAxisExtent, 0.0f);
childParentData.offset = new Offset(mainAxisExtent, 0.0f);
this.size = this.constraints.constrain(new Size((float) mainAxisExtent,
this.size = this.constraints.constrain(new Size(mainAxisExtent,
this.constraints.maxHeight));
break;
case AxisDirection.left:

child = childParentData.nextSibling;
}
position = 0.0;
position = 0.0f;
childParentData.offset = new Offset((float) (mainAxisExtent - position), 0.0f);
childParentData.offset = new Offset((mainAxisExtent - position), 0.0f);
this.size = this.constraints.constrain(new Size((float) mainAxisExtent,
this.size = this.constraints.constrain(new Size(mainAxisExtent,
this.constraints.maxHeight));
break;
case AxisDirection.down:

ListBodyParentData childParentData = (ListBodyParentData) child.parentData;
childParentData.offset = new Offset(0.0f, (float) mainAxisExtent);
childParentData.offset = new Offset(0.0f, mainAxisExtent);
this.size = this.constraints.constrain(new Size(this.constraints.maxWidth, (float) mainAxisExtent));
this.size = this.constraints.constrain(new Size(this.constraints.maxWidth, mainAxisExtent));
break;
case AxisDirection.up:
innerConstraints = BoxConstraints.tightFor(width: this.constraints.maxWidth);

child = childParentData.nextSibling;
}
position = 0.0;
position = 0.0f;
childParentData.offset = new Offset(0.0f, (float) (mainAxisExtent - position));
childParentData.offset = new Offset(0.0f, (mainAxisExtent - position));
this.size = this.constraints.constrain(new Size(this.constraints.maxWidth, (float) mainAxisExtent));
this.size = this.constraints.constrain(new Size(this.constraints.maxWidth, mainAxisExtent));
break;
}

float extent = 0.0f;
RenderBox child = this.firstChild;
while (child != null) {
extent = Math.Max(extent, childSize(child));
extent = Mathf.Max(extent, childSize(child));
ListBodyParentData childParentData = (ListBodyParentData) child.parentData;
child = childParentData.nextSibling;
}

4
Runtime/rendering/object.cs


public void pushTransform(bool needsCompositing, Offset offset, Matrix3 transform,
PaintingContextCallback painter) {
var effectiveTransform = Matrix3.makeTrans((float) offset.dx, (float) offset.dy);
var effectiveTransform = Matrix3.makeTrans(offset.dx, offset.dy);
effectiveTransform.preTranslate((float) -offset.dx, (float) -offset.dy);
effectiveTransform.preTranslate(-offset.dx, -offset.dy);
if (needsCompositing) {
var inverse = Matrix3.I();

6
Runtime/rendering/paragraph.cs


public float textScaleFactor {
get { return this._textPainter.textScaleFactor; }
set {
if (Math.Abs(this._textPainter.textScaleFactor - value) < 0.00000001) {
if (Mathf.Abs(this._textPainter.textScaleFactor - value) < 0.00000001) {
return;
}

}
void _layoutTextWithConstraints(BoxConstraints constraints) {
this._layoutText(minWidth: (float) constraints.minWidth, maxWidth: (float) constraints.maxWidth);
this._layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
}
public override List<DiagnosticsNode> debugDescribeChildren() {

properties.add(new FlagProperty("softWrap", value: this.softWrap, ifTrue: "wrapping at box width",
ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextOverflow>("overflow", this.overflow));
properties.add(new DoubleProperty("textScaleFactor", this.textScaleFactor, defaultValue: 1.0));
properties.add(new floatProperty("textScaleFactor", this.textScaleFactor, defaultValue: 1.0));
properties.add(new IntProperty("maxLines", this.maxLines, ifNull: "unlimited"));
}
}

92
Runtime/rendering/proxy_box.cs


protected override float computeMinIntrinsicWidth(float height) {
if (this._additionalConstraints.hasBoundedWidth && this._additionalConstraints.hasTightWidth) {
return (float) this._additionalConstraints.minWidth;
return this._additionalConstraints.minWidth;
}
float width = base.computeMinIntrinsicWidth(height);

return (float) this._additionalConstraints.constrainWidth(width);
return this._additionalConstraints.constrainWidth(width);
}
return width;

if (this._additionalConstraints.hasBoundedWidth && this._additionalConstraints.hasTightWidth) {
return (float) this._additionalConstraints.minWidth;
return this._additionalConstraints.minWidth;
}
float width = base.computeMaxIntrinsicWidth(height);

return (float) this._additionalConstraints.constrainWidth(width);
return this._additionalConstraints.constrainWidth(width);
}
return width;

if (this._additionalConstraints.hasBoundedHeight && this._additionalConstraints.hasTightHeight) {
return (float) this._additionalConstraints.minHeight;
return this._additionalConstraints.minHeight;
}
float height = base.computeMinIntrinsicHeight(width);

return (float) this._additionalConstraints.constrainHeight(height);
return this._additionalConstraints.constrainHeight(height);
}
return height;

if (this._additionalConstraints.hasBoundedHeight && this._additionalConstraints.hasTightHeight) {
return (float) this._additionalConstraints.minHeight;
return this._additionalConstraints.minHeight;
}
float height = base.computeMaxIntrinsicHeight(width);

return (float) this._additionalConstraints.constrainHeight(height);
return this._additionalConstraints.constrainHeight(height);
}
return height;

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DoubleProperty("maxWidth", this.maxWidth, defaultValue: double.PositiveInfinity));
properties.add(new DoubleProperty("maxHeight", this.maxHeight, defaultValue: double.PositiveInfinity));
properties.add(new floatProperty("maxWidth", this.maxWidth, defaultValue: float.PositiveInfinity));
properties.add(new floatProperty("maxHeight", this.maxHeight, defaultValue: float.PositiveInfinity));
}
}

protected override float computeMinIntrinsicWidth(float height) {
if (!double.IsInfinity(height)) {
if (!float.IsInfinity(height)) {
return height * this._aspectRatio;
}

}
protected override float computeMaxIntrinsicWidth(float height) {
if (!double.IsInfinity(height)) {
if (!float.IsInfinity(height)) {
return height * this._aspectRatio;
}

}
protected override float computeMinIntrinsicHeight(float width) {
if (!double.IsInfinity(width)) {
if (!float.IsInfinity(width)) {
return width / this._aspectRatio;
}

}
protected override float computeMaxIntrinsicHeight(float width) {
if (!double.IsInfinity(width)) {
if (!float.IsInfinity(width)) {
return width / this._aspectRatio;
}

return constraints.smallest;
}
double width = constraints.maxWidth;
double height = width / this._aspectRatio;
float width = constraints.maxWidth;
float height = width / this._aspectRatio;
if (width > constraints.maxWidth) {
width = constraints.maxWidth;

width = height * this._aspectRatio;
}
return constraints.constrain(new Size((float) width, (float) height));
return constraints.constrain(new Size(width, height));
}
protected override void performLayout() {

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DoubleProperty("aspectRatio", this.aspectRatio));
properties.add(new floatProperty("aspectRatio", this.aspectRatio));
public RenderOpacity(double opacity = 1.0, RenderBox child = null) : base(child) {
public RenderOpacity(float opacity = 1.0f, RenderBox child = null) : base(child) {
D.assert(opacity >= 0.0 && opacity <= 1.0);
this._opacity = opacity;
this._alpha = _getAlphaFromOpacity(opacity);

int _alpha;
internal static int _getAlphaFromOpacity(double opacity) {
internal static int _getAlphaFromOpacity(float opacity) {
double _opacity;
float _opacity;
public double opacity {
public float opacity {
get { return this._opacity; }
set {
D.assert(value >= 0.0 && value <= 1.0);

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DoubleProperty("opacity", this.opacity));
properties.add(new floatProperty("opacity", this.opacity));
}
}

public abstract class _RenderPhysicalModelBase<T> : _RenderCustomClip<T> where T : class {
public _RenderPhysicalModelBase(
RenderBox child = null,
double? elevation = null,
float? elevation = null,
Color color = null,
Color shadowColor = null,
Clip clipBehavior = Clip.none,

D.assert(color != null);
D.assert(shadowColor != null);
this._elevation = elevation ?? 0.0;
this._elevation = elevation ?? 0.0f;
public double elevation {
public float elevation {
get { return this._elevation; }
set {
if (this.elevation == value) {

}
}
double _elevation;
float _elevation;
public Color shadowColor {
get { return this._shadowColor; }

public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DoubleProperty("elevation", this.elevation));
description.add(new floatProperty("elevation", this.elevation));
description.add(new DiagnosticsProperty<Color>("color", this.color));
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}

BoxShape shape = BoxShape.rectangle,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double elevation = 0.0,
float elevation = 0.0f,
Color color = null,
Color shadowColor = null
) : base(clipBehavior: clipBehavior, child: child, elevation: elevation, color: color,

RenderBox child = null,
CustomClipper<Path> clipper = null,
Clip clipBehavior = Clip.none,
double elevation = 0.0,
float elevation = 0.0f,
Color color = null,
Color shadowColor = null
) : base(child: child,

this.markNeedsPaint();
}
public void rotateX(double degrees) {
public void rotateX(float degrees) {
public void rotateY(double degrees) {
public void rotateY(float degrees) {
public void rotateZ(double degrees) {
this._transform.preRotate((float) degrees);
public void rotateZ(float degrees) {
this._transform.preRotate(degrees);
public void translate(double x, double y = 0.0, double z = 0.0) {
this._transform.preTranslate((float) x, (float) y);
public void translate(float x, float y = 0.0f, float z = 0.0f) {
this._transform.preTranslate(x, y);
public void scale(double x, double y, double z) {
this._transform.preScale((float) x, (float) y);
public void scale(float x, float y, float z) {
this._transform.preScale(x, y);
this.markNeedsPaint();
}

var result = Matrix3.I();
if (this._origin != null) {
result.preTranslate((float) this._origin.dx, (float) this._origin.dy);
result.preTranslate(this._origin.dx, this._origin.dy);
result.preTranslate((float) translation.dx, (float) translation.dy);
result.preTranslate(translation.dx, translation.dy);
result.preTranslate((float) -translation.dx, (float) -translation.dy);
result.preTranslate(-translation.dx, -translation.dy);
result.preTranslate((float) -this._origin.dx, (float) -this._origin.dy);
result.preTranslate(-this._origin.dx, -this._origin.dy);
}
return result;

}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preTranslate((float) (this.translation.dx * this.size.width),
(float) (this.translation.dy * this.size.height));
transform.preTranslate((this.translation.dx * this.size.width),
(this.translation.dy * this.size.height));
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

properties.add(new MessageProperty("usefulness ratio", "no metrics collected yet (never painted)"));
}
else {
double fraction = (double) this.debugAsymmetricPaintCount /
(this.debugSymmetricPaintCount + this.debugAsymmetricPaintCount);
float fraction = this.debugAsymmetricPaintCount /
(this.debugSymmetricPaintCount + this.debugAsymmetricPaintCount);
string diagnosis;
if (this.debugSymmetricPaintCount + this.debugAsymmetricPaintCount < 5) {

61
Runtime/rendering/shifted_box.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.foundation;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public abstract class RenderShiftedBox : RenderObjectWithChildMixinRenderBox<RenderBox> {

protected override float computeMinIntrinsicWidth(float height) {
if (this.child != null) {
return this.child.getMinIntrinsicWidth((float) Math.Max(0.0, height - this._padding.vertical)) +
return this.child.getMinIntrinsicWidth(Mathf.Max(0.0f, height - this._padding.vertical)) +
this._padding.horizontal;
}

protected override float computeMaxIntrinsicWidth(float height) {
if (this.child != null) {
return this.child.getMaxIntrinsicWidth((float) Math.Max(0.0, height - this._padding.vertical)) +
return this.child.getMaxIntrinsicWidth(Mathf.Max(0.0f, height - this._padding.vertical)) +
this._padding.horizontal;
}

protected override float computeMinIntrinsicHeight(float width) {
if (this.child != null) {
return this.child.getMinIntrinsicHeight((float) Math.Max(0.0, width - this._padding.horizontal)) +
return this.child.getMinIntrinsicHeight(Mathf.Max(0.0f, width - this._padding.horizontal)) +
this._padding.vertical;
}

protected override float computeMaxIntrinsicHeight(float width) {
if (this.child != null) {
return this.child.getMaxIntrinsicHeight((float) Math.Max(0.0, width - this._padding.horizontal)) +
return this.child.getMaxIntrinsicHeight(Mathf.Max(0.0f, width - this._padding.horizontal)) +
this._padding.vertical;
}

float? _heightFactor;
protected override void performLayout() {
bool shrinkWrapWidth = this._widthFactor != null || double.IsPositiveInfinity(this.constraints.maxWidth);
bool shrinkWrapHeight = this._heightFactor != null || double.IsPositiveInfinity(this.constraints.maxHeight);
bool shrinkWrapWidth = this._widthFactor != null || float.IsPositiveInfinity(this.constraints.maxWidth);
bool shrinkWrapHeight = this._heightFactor != null || float.IsPositiveInfinity(this.constraints.maxHeight);
if (this.child != null) {
this.child.layout(this.constraints.loosen(), parentUsesSize: true);

// final BoxParentData childParentData = child.parentData;
// if (childParentData.offset.dy > 0.0) {
// // vertical alignment arrows
// final double headSize = math.min(childParentData.offset.dy * 0.2, 10.0);
// final float headSize = math.min(childParentData.offset.dy * 0.2, 10.0);
// path
// ..moveTo(offset.dx + size.width / 2.0, offset.dy)
// ..relativeLineTo(0.0, childParentData.offset.dy - headSize)

// }
// if (childParentData.offset.dx > 0.0) {
// // horizontal alignment arrows
// final double headSize = math.min(childParentData.offset.dx * 0.2, 10.0);
// final float headSize = math.min(childParentData.offset.dx * 0.2, 10.0);
// path
// ..moveTo(offset.dx, offset.dy + size.height / 2.0)
// ..relativeLineTo(childParentData.offset.dx - headSize, 0.0)

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DoubleProperty("widthFactor", this._widthFactor, ifNull: "expand"));
properties.add(new DoubleProperty("heightFactor", this._heightFactor, ifNull: "expand"));
properties.add(new floatProperty("widthFactor", this._widthFactor, ifNull: "expand"));
properties.add(new floatProperty("heightFactor", this._heightFactor, ifNull: "expand"));
}
}

public Size _requestedSize;
protected override float computeMinIntrinsicWidth(float height) {
return (float) this._requestedSize.width;
return this._requestedSize.width;
return (float) this._requestedSize.width;
return this._requestedSize.width;
return (float) this._requestedSize.height;
return this._requestedSize.height;
return (float) this._requestedSize.height;
return this._requestedSize.height;
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {

public float? _heightFactor;
public BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
double minWidth = constraints.minWidth;
double maxWidth = constraints.maxWidth;
float minWidth = constraints.minWidth;
float maxWidth = constraints.maxWidth;
double width = maxWidth * this._widthFactor.Value;
float width = maxWidth * this._widthFactor.Value;
double minHeight = constraints.minHeight;
double maxHeight = constraints.maxHeight;
float minHeight = constraints.minHeight;
float maxHeight = constraints.maxHeight;
double height = maxHeight * this._heightFactor.Value;
float height = maxHeight * this._heightFactor.Value;
minWidth: (float) minWidth,
maxWidth: (float) maxWidth,
minHeight: (float) minHeight,
maxHeight: (float) maxHeight
minWidth: minWidth,
maxWidth: maxWidth,
minHeight: minHeight,
maxHeight: maxHeight
);
}

protected override float computeMinIntrinsicWidth(float height) {
float width = (float) this._getSize(BoxConstraints.tightForFinite(height: height)).width;
float width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
if (width.isFinite()) {
return width;
}

protected override float computeMaxIntrinsicWidth(float height) {
float width = (float) this._getSize(BoxConstraints.tightForFinite(height: height)).width;
float width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
if (width.isFinite()) {
return width;
}

protected override float computeMinIntrinsicHeight(float width) {
float height = (float) this._getSize(BoxConstraints.tightForFinite(width: width)).height;
float height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
if (height.isFinite()) {
return height;
}

protected override float computeMaxIntrinsicHeight(float width) {
float height = (float) this._getSize(BoxConstraints.tightForFinite(width: width)).height;
float height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
if (height.isFinite()) {
return height;
}

157
Runtime/rendering/sliver.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public enum GrowthDirection {

public override bool isNormalized {
get {
return this.scrollOffset >= 0.0
&& this.crossAxisExtent >= 0.0
return this.scrollOffset >= 0.0f
&& this.crossAxisExtent >= 0.0f
&& this.viewportMainAxisExtent >= 0.0
&& this.remainingPaintExtent >= 0.0;
&& this.viewportMainAxisExtent >= 0.0f
&& this.remainingPaintExtent >= 0.0f;
}
}

$"{this.GetType()} is not valid: {message}\n{information}The offending constraints were: \n {this}");
});
verify(this.scrollOffset >= 0.0, "The \"scrollOffset\" is negative.");
verify(this.crossAxisExtent >= 0.0, "The \"crossAxisExtent\" is negative.");
verify(this.scrollOffset >= 0.0f, "The \"scrollOffset\" is negative.");
verify(this.crossAxisExtent >= 0.0f, "The \"crossAxisExtent\" is negative.");
verify(this.viewportMainAxisExtent >= 0.0, "The \"viewportMainAxisExtent\" is negative.");
verify(this.remainingPaintExtent >= 0.0, "The \"remainingPaintExtent\" is negative.");
verify(this.remainingCacheExtent >= 0.0, "The \"remainingCacheExtent\" is negative.");
verify(this.cacheOrigin <= 0.0, "The \"cacheOrigin\" is positive.");
verify(this.viewportMainAxisExtent >= 0.0f, "The \"viewportMainAxisExtent\" is negative.");
verify(this.remainingPaintExtent >= 0.0f, "The \"remainingPaintExtent\" is negative.");
verify(this.remainingCacheExtent >= 0.0f, "The \"remainingCacheExtent\" is negative.");
verify(this.cacheOrigin <= 0.0f, "The \"cacheOrigin\" is positive.");
verify(this.isNormalized, "The constraints are not normalized.");
return true;
});

public override string ToString() {
return
$"SliverConstraints({this.axisDirection}, {this.growthDirection}, {this.userScrollDirection}, scrollOffset: {this.scrollOffset:F1}, remainingPaintExtent: {this.remainingCacheExtent:F1}, " +
$"{(this.overlap != 0.0 ? "overlap: " + this.overlap.ToString("F1") + ", " : "")}crossAxisExtent: {this.crossAxisExtent:F1}, crossAxisDirection: {this.crossAxisDirection}, " +
$"{(this.overlap != 0.0f ? "overlap: " + this.overlap.ToString("F1") + ", " : "")}crossAxisExtent: {this.crossAxisExtent:F1}, crossAxisDirection: {this.crossAxisDirection}, " +
$"viewportMainAxisExtent: {this.viewportMainAxisExtent:F1}, remainingCacheExtent: {this.remainingCacheExtent:F1} " +
$"cacheOrigin: {this.cacheOrigin:F1})";
}

float? scrollOffsetCorrection = null,
float? cacheExtent = null
) {
D.assert(scrollOffsetCorrection != 0.0);
D.assert(scrollOffsetCorrection != 0.0f);
this.scrollExtent = scrollExtent;
this.paintExtent = paintExtent;

this.maxScrollObstructionExtent = maxScrollObstructionExtent;
this.hitTestExtent = hitTestExtent ?? paintExtent;
this.visible = visible ?? paintExtent > 0.0;
this.visible = visible ?? paintExtent > 0.0f;
this.hasVisualOverflow = hasVisualOverflow;
this.scrollOffsetCorrection = scrollOffsetCorrection;
this.cacheExtent = cacheExtent ?? layoutExtent ?? paintExtent;

public readonly float? scrollOffsetCorrection;
public readonly float cacheExtent;
internal static string _debugCompareFloats(string labelA, double valueA, string labelB, double valueB) {
internal static string _debugCompareFloats(string labelA, float valueA, string labelB, float valueB) {
if (valueA.ToString("F1") != valueB.ToString("F1")) {
return $"The {labelA} is {valueA:F1}, but the {labelB} is {valueB:F1}. ";
}

throw new UIWidgetsError($"{this.GetType()} is not valid: {message}\n{information}");
});
verify(this.scrollExtent >= 0.0, "The \"scrollExtent\" is negative.");
verify(this.paintExtent >= 0.0, "The \"paintExtent\" is negative.");
verify(this.layoutExtent >= 0.0, "The \"layoutExtent\" is negative.");
verify(this.cacheExtent >= 0.0, "The \"cacheExtent\" is negative.");
verify(this.scrollExtent >= 0.0f, "The \"scrollExtent\" is negative.");
verify(this.paintExtent >= 0.0f, "The \"paintExtent\" is negative.");
verify(this.layoutExtent >= 0.0f, "The \"layoutExtent\" is negative.");
verify(this.cacheExtent >= 0.0f, "The \"cacheExtent\" is negative.");
if (this.layoutExtent > this.paintExtent) {
verify(false,
"The \"layoutExtent\" exceeds the \"paintExtent\".\n" +

);
}
verify(this.hitTestExtent >= 0.0, "The \"hitTestExtent\" is negative.");
verify(this.scrollOffsetCorrection != 0.0, "The \"scrollOffsetCorrection\" is zero.");
verify(this.hitTestExtent >= 0.0f, "The \"hitTestExtent\" is negative.");
verify(this.scrollOffsetCorrection != 0.0f, "The \"scrollOffsetCorrection\" is zero.");
return true;
});
return true;

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DoubleProperty("scrollExtent", this.scrollExtent));
if (this.paintExtent > 0.0) {
properties.add(new DoubleProperty("paintExtent", this.paintExtent,
properties.add(new floatProperty("scrollExtent", this.scrollExtent));
if (this.paintExtent > 0.0f) {
properties.add(new floatProperty("paintExtent", this.paintExtent,
else if (this.paintExtent == 0.0) {
else if (this.paintExtent == 0.0f) {
properties.add(new DoubleProperty("paintExtent", this.paintExtent,
properties.add(new floatProperty("paintExtent", this.paintExtent,
unit: this.visible ? null : " but visible"));
}

properties.add(new DoubleProperty("paintExtent", this.paintExtent, tooltip: "!"));
properties.add(new floatProperty("paintExtent", this.paintExtent, tooltip: "!"));
properties.add(new DoubleProperty("paintOrigin", this.paintOrigin,
defaultValue: 0.0));
properties.add(new DoubleProperty("layoutExtent", this.layoutExtent,
properties.add(new floatProperty("paintOrigin", this.paintOrigin,
defaultValue: 0.0f));
properties.add(new floatProperty("layoutExtent", this.layoutExtent,
properties.add(new DoubleProperty("maxPaintExtent", this.maxPaintExtent));
properties.add(new DoubleProperty("hitTestExtent", this.hitTestExtent,
properties.add(new floatProperty("maxPaintExtent", this.maxPaintExtent));
properties.add(new floatProperty("hitTestExtent", this.hitTestExtent,
properties.add(new DoubleProperty("scrollOffsetCorrection", this.scrollOffsetCorrection,
properties.add(new floatProperty("scrollOffsetCorrection", this.scrollOffsetCorrection,
properties.add(new DoubleProperty("cacheExtent", this.cacheExtent,
defaultValue: 0.0));
properties.add(new floatProperty("cacheExtent", this.cacheExtent,
defaultValue: 0.0f));
double mainAxisPosition = 0.0,
double crossAxisPosition = 0.0
float mainAxisPosition = 0.0f,
float crossAxisPosition = 0.0f
) : base(target) {
this.mainAxisPosition = mainAxisPosition;
this.crossAxisPosition = crossAxisPosition;

get { return (RenderSliver) base.target; }
}
public readonly double mainAxisPosition;
public readonly float mainAxisPosition;
public readonly double crossAxisPosition;
public readonly float crossAxisPosition;
public override string ToString() {
return $"{this.target.GetType()}@(mainAix: {this.mainAxisPosition}, crossAix: {this.crossAxisPosition})";

public Offset paintOffset = Offset.zero;
public void applyPaintTransform(Matrix3 transform) {
transform.preTranslate((float) this.paintOffset.dx, (float) this.paintOffset.dy);
transform.preTranslate(this.paintOffset.dx, this.paintOffset.dy);
}
public override string ToString() {

case Axis.horizontal:
return Rect.fromLTWH(
0.0f, 0.0f,
(float) this.geometry.paintExtent,
this.geometry.paintExtent,
this.constraints.crossAxisExtent
);
case Axis.vertical:

(float) this.geometry.paintExtent
this.geometry.paintExtent
);
}

}
public bool hitTest(HitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
if (mainAxisPosition >= 0.0 && mainAxisPosition < this.geometry.hitTestExtent &&
crossAxisPosition >= 0.0 && crossAxisPosition < this.constraints.crossAxisExtent) {
if (mainAxisPosition >= 0.0f && mainAxisPosition < this.geometry.hitTestExtent &&
crossAxisPosition >= 0.0f && crossAxisPosition < this.constraints.crossAxisExtent) {
if (this.hitTestChildren(result, mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition) ||
this.hitTestSelf(mainAxisPosition: mainAxisPosition, crossAxisPosition: crossAxisPosition)) {

return false;
}
protected virtual bool hitTestSelf(double mainAxisPosition = 0, float crossAxisPosition = 0) {
protected virtual bool hitTestSelf(float mainAxisPosition = 0, float crossAxisPosition = 0) {
return false;
}

switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(
this.constraints.axisDirection, this.constraints.growthDirection)) {
case AxisDirection.up:
return new Size(this.constraints.crossAxisExtent, (float) -this.geometry.paintExtent);
return new Size(this.constraints.crossAxisExtent, -this.geometry.paintExtent);
return new Size((float) this.geometry.paintExtent, this.constraints.crossAxisExtent);
return new Size(this.geometry.paintExtent, this.constraints.crossAxisExtent);
return new Size(this.constraints.crossAxisExtent, (float) this.geometry.paintExtent);
return new Size(this.constraints.crossAxisExtent, this.geometry.paintExtent);
return new Size((float) -this.geometry.paintExtent, this.constraints.crossAxisExtent);
return new Size(-this.geometry.paintExtent, this.constraints.crossAxisExtent);
}
D.assert(false);

}
D.assert(p0.dx == p1.dx || p0.dy == p1.dy);
double d = (p1 - p0).distance * 0.2;
float d = (p1 - p0).distance * 0.2f;
double dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
float dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
switch (direction) {
case GrowthDirection.forward:
dx1 = dx2 = dy1 = dy2 = d;

public override void debugPaint(PaintingContext context, Offset offset) {
D.assert(() => {
if (D.debugPaintSizeEnabled) {
double strokeWidth = Math.Min(4.0, this.geometry.paintExtent / 30.0);
float strokeWidth = Mathf.Min(4.0f, this.geometry.paintExtent / 30.0f);
double arrowExtent = this.geometry.paintExtent;
double padding = Math.Max(2.0, strokeWidth);
float arrowExtent = this.geometry.paintExtent;
float padding = Mathf.Max(2.0f, strokeWidth);
Canvas canvas = context.canvas;
// canvas.drawCircle(
// offset.translate(padding, padding),

case Axis.vertical:
// canvas.drawLine(
// offset,
// offset.translate(constraints.crossAxisExtent, 0.0),
// offset.translate(constraints.crossAxisExtent, 0.0f),
offset.translate(this.constraints.crossAxisExtent * 1.0f / 4.0f, (float) padding),
offset.translate(this.constraints.crossAxisExtent * 1.0f / 4.0f, padding),
(float) (arrowExtent - padding)),
(arrowExtent - padding)),
offset.translate(this.constraints.crossAxisExtent * 3.0f / 4.0f, (float) padding),
offset.translate(this.constraints.crossAxisExtent * 3.0f / 4.0f, padding),
(float) (arrowExtent - padding)),
(arrowExtent - padding)),
this.constraints.normalizedGrowthDirection
);
break;

// offset.translate(0.0, constraints.crossAxisExtent),
// offset.translate(0.0f, constraints.crossAxisExtent),
offset.translate((float) padding, this.constraints.crossAxisExtent * 1.0f / 4.0f),
offset.translate((float) (arrowExtent - padding),
offset.translate(padding, this.constraints.crossAxisExtent * 1.0f / 4.0f),
offset.translate((arrowExtent - padding),
this.constraints.crossAxisExtent * 1.0f / 4.0f),
this.constraints.normalizedGrowthDirection
);

offset.translate((float) padding, this.constraints.crossAxisExtent * 3.0f / 4.0f),
offset.translate((float) (arrowExtent - padding),
offset.translate(padding, this.constraints.crossAxisExtent * 3.0f / 4.0f),
offset.translate((arrowExtent - padding),
this.constraints.crossAxisExtent * 3.0f / 4.0f),
this.constraints.normalizedGrowthDirection
);

}
public static bool hitTestBoxChild(this RenderSliver it, HitTestResult result, RenderBox child,
double mainAxisPosition = 0.0, double crossAxisPosition = 0.0) {
float mainAxisPosition = 0.0f, float crossAxisPosition = 0.0f) {
double absolutePosition = mainAxisPosition - it.childMainAxisPosition(child);
double absoluteCrossAxisPosition = crossAxisPosition - it.childCrossAxisPosition(child);
float absolutePosition = mainAxisPosition - it.childMainAxisPosition(child);
float absoluteCrossAxisPosition = crossAxisPosition - it.childCrossAxisPosition(child);
switch (it.constraints.axis) {
case Axis.horizontal:
if (!rightWayUp) {

return child.hitTest(result,
position: new Offset((float) absolutePosition, (float) absoluteCrossAxisPosition));
position: new Offset(absolutePosition, absoluteCrossAxisPosition));
case Axis.vertical:
if (!rightWayUp) {
absolutePosition = child.size.height - absolutePosition;

position: new Offset((float) absoluteCrossAxisPosition, (float) absolutePosition));
position: new Offset(absoluteCrossAxisPosition, absolutePosition));
}
return false;

Matrix3 transform) {
bool rightWayUp = _getRightWayUp(it.constraints);
double delta = it.childMainAxisPosition(child);
double crossAxisDelta = it.childCrossAxisPosition(child);
float delta = it.childMainAxisPosition(child);
float crossAxisDelta = it.childCrossAxisPosition(child);
switch (it.constraints.axis) {
case Axis.horizontal:
if (!rightWayUp) {

transform.preTranslate((float) delta, (float) crossAxisDelta);
transform.preTranslate(delta, crossAxisDelta);
break;
case Axis.vertical:
if (!rightWayUp) {

transform.preTranslate((float) crossAxisDelta, (float) delta);
transform.preTranslate(crossAxisDelta, delta);
break;
}
}

constraints.growthDirection)) {
case AxisDirection.up:
childParentData.paintOffset = new Offset(0.0f,
-(float) (geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)));
-(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)));
break;
case AxisDirection.right:
childParentData.paintOffset = new Offset(-constraints.scrollOffset, 0.0f);

break;
case AxisDirection.left:
childParentData.paintOffset =
new Offset(-(float) (geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)),
new Offset(-(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)),
0.0f);
break;
}

float crossAxisPosition = 0.0f) {
D.assert(this.geometry.hitTestExtent > 0.0);
D.assert(this.geometry.hitTestExtent > 0.0f);
if (this.child != null) {
return this.hitTestBoxChild(result, this.child, mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition);

float cacheExtent = this.calculateCacheOffset(this.constraints, from: 0.0f, to: childExtent);
D.assert(paintedChildSize.isFinite());
D.assert(paintedChildSize >= 0.0);
D.assert(paintedChildSize >= 0.0f);
this.geometry = new SliverGeometry(
scrollExtent: childExtent,

hitTestExtent: paintedChildSize,
hasVisualOverflow: childExtent > this.constraints.remainingPaintExtent
|| this.constraints.scrollOffset > 0.0
|| this.constraints.scrollOffset > 0.0f
);
this.setChildParentData(this.child, this.constraints, this.geometry);

6
Runtime/rendering/sliver_fill.cs


}
protected override int getMinChildIndexForScrollOffset(float scrollOffset, float itemExtent) {
return base.getMinChildIndexForScrollOffset(Math.Max(scrollOffset - this._padding, 0.0f), itemExtent);
return base.getMinChildIndexForScrollOffset(Mathf.Max(scrollOffset - this._padding, 0.0f), itemExtent);
return base.getMaxChildIndexForScrollOffset(Math.Max(scrollOffset - this._padding, 0.0f), itemExtent);
return base.getMaxChildIndexForScrollOffset(Mathf.Max(scrollOffset - this._padding, 0.0f), itemExtent);
}
protected override float estimateMaxScrollOffset(SliverConstraints constraints,

}
protected override void performLayout() {
float extent = this.constraints.remainingPaintExtent - Math.Min(this.constraints.overlap, 0.0f);
float extent = this.constraints.remainingPaintExtent - Mathf.Min(this.constraints.overlap, 0.0f);
if (this.child != null) {
this.child.layout(this.constraints.asBoxConstraints(minExtent: extent, maxExtent: extent),
parentUsesSize: true);

15
Runtime/rendering/sliver_fixed_extent_list.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.rendering {
public abstract class RenderSliverFixedExtentBoxAdaptor : RenderSliverMultiBoxAdaptor {

}
protected virtual int getMinChildIndexForScrollOffset(float scrollOffset, float itemExtent) {
return itemExtent > 0.0 ? Math.Max(0, (int) (scrollOffset / itemExtent)) : 0;
return itemExtent > 0.0 ? Mathf.Max(0, (int) (scrollOffset / itemExtent)) : 0;
return itemExtent > 0.0 ? Math.Max(0, (int) Math.Ceiling(scrollOffset / itemExtent) - 1) : 0;
return itemExtent > 0.0 ? Mathf.Max(0, (int) Mathf.Ceil(scrollOffset / itemExtent) - 1) : 0;
}
protected virtual float estimateMaxScrollOffset(SliverConstraints constraints,

float paintExtent = this.calculatePaintOffset(
this.constraints,
from: (float) leadingScrollOffset,
to: (float) trailingScrollOffset
from: leadingScrollOffset,
to: trailingScrollOffset
from: (float) leadingScrollOffset,
to: (float) trailingScrollOffset
from: leadingScrollOffset,
to: trailingScrollOffset
int? targetLastIndexForPaint = !double.IsInfinity(targetEndScrollOffsetForPaint)
int? targetLastIndexForPaint = !float.IsInfinity(targetEndScrollOffsetForPaint)
? this.getMaxChildIndexForScrollOffset(targetEndScrollOffsetForPaint, itemExtent)
: (int?) null;
this.geometry = new SliverGeometry(

4
Runtime/rendering/sliver_list.cs


float scrollOffset = this.constraints.scrollOffset + this.constraints.cacheOrigin;
D.assert(scrollOffset >= 0.0);
double remainingExtent = this.constraints.remainingCacheExtent;
float remainingExtent = this.constraints.remainingCacheExtent;
double targetEndScrollOffset = scrollOffset + remainingExtent;
float targetEndScrollOffset = scrollOffset + remainingExtent;
BoxConstraints childConstraints = this.constraints.asBoxConstraints();
int leadingGarbage = 0;
int trailingGarbage = 0;

2
Runtime/rendering/sliver_multi_box_adaptor.cs


case AxisDirection.left:
mainAxisUnit = new Offset(-1.0f, 0.0f);
crossAxisUnit = new Offset(0.0f, 1.0f);
originOffset = offset + new Offset((float) this.geometry.paintExtent, 0.0f);
originOffset = offset + new Offset(this.geometry.paintExtent, 0.0f);
addExtent = true;
break;
}

34
Runtime/rendering/sliver_padding.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class RenderSliverPadding : RenderObjectWithChildMixinRenderSliver<RenderSliver> {

if (this.child == null) {
this.geometry = new SliverGeometry(
scrollExtent: mainAxisPadding,
paintExtent: Math.Min(mainAxisPadding, this.constraints.remainingPaintExtent),
paintExtent: Mathf.Min(mainAxisPadding, this.constraints.remainingPaintExtent),
maxPaintExtent: mainAxisPadding
);
return;

this.constraints.copyWith(
scrollOffset: (float) Math.Max(0.0, this.constraints.scrollOffset - beforePadding),
cacheOrigin: (float) Math.Min(0.0, this.constraints.cacheOrigin + beforePadding),
scrollOffset: Mathf.Max(0.0f, this.constraints.scrollOffset - beforePadding),
cacheOrigin: Mathf.Min(0.0f, this.constraints.cacheOrigin + beforePadding),
crossAxisExtent: (float) Math.Max(0.0, this.constraints.crossAxisExtent - crossAxisPadding)
crossAxisExtent: Mathf.Max(0.0f, this.constraints.crossAxisExtent - crossAxisPadding)
),
parentUsesSize: true
);

return;
}
double beforePaddingPaintExtent = this.calculatePaintOffset(
float beforePaddingPaintExtent = this.calculatePaintOffset(
double afterPaddingPaintExtent = this.calculatePaintOffset(
float afterPaddingPaintExtent = this.calculatePaintOffset(
double mainAxisPaddingPaintExtent = beforePaddingPaintExtent + afterPaddingPaintExtent;
double beforePaddingCacheExtent = this.calculateCacheOffset(
float mainAxisPaddingPaintExtent = beforePaddingPaintExtent + afterPaddingPaintExtent;
float beforePaddingCacheExtent = this.calculateCacheOffset(
double afterPaddingCacheExtent = this.calculateCacheOffset(
float afterPaddingCacheExtent = this.calculateCacheOffset(
double mainAxisPaddingCacheExtent = afterPaddingCacheExtent + beforePaddingCacheExtent;
double paintExtent = Math.Min(
beforePaddingPaintExtent + Math.Max(childLayoutGeometry.paintExtent,
float mainAxisPaddingCacheExtent = afterPaddingCacheExtent + beforePaddingCacheExtent;
float paintExtent = Mathf.Min(
beforePaddingPaintExtent + Mathf.Max(childLayoutGeometry.paintExtent,
childLayoutGeometry.layoutExtent + afterPaddingPaintExtent),
this.constraints.remainingPaintExtent
);

paintExtent: (float) paintExtent,
layoutExtent: (float) Math.Min(mainAxisPaddingPaintExtent + childLayoutGeometry.layoutExtent,
paintExtent: paintExtent,
layoutExtent: Mathf.Min(mainAxisPaddingPaintExtent + childLayoutGeometry.layoutExtent,
cacheExtent: (float) Math.Min(mainAxisPaddingCacheExtent + childLayoutGeometry.cacheExtent,
cacheExtent: Mathf.Min(mainAxisPaddingCacheExtent + childLayoutGeometry.cacheExtent,
hitTestExtent: (float) Math.Max(
hitTestExtent: Mathf.Max(
mainAxisPaddingPaintExtent + childLayoutGeometry.paintExtent,
beforePaddingPaintExtent + childLayoutGeometry.hitTestExtent
),

24
Runtime/rendering/stack.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class RelativeRect : IEquatable<RelativeRect> {

public RelativeRect intersect(RelativeRect other) {
return fromLTRB(
Math.Max(this.left, other.left),
Math.Max(this.top, other.top),
Math.Max(this.right, other.right),
Math.Max(this.bottom, other.bottom)
Mathf.Max(this.left, other.left),
Mathf.Max(this.top, other.top),
Mathf.Max(this.right, other.right),
Mathf.Max(this.bottom, other.bottom)
);
}

}
}
public delegate double mainChildSizeGetter(RenderBox child);
public delegate float mainChildSizeGetter(RenderBox child);
float _getIntrinsicDimension(mainChildSizeGetter getter) {
float extent = 0.0f;

if (!childParentData.isPositioned) {
extent = (float) Math.Max(extent, getter(child));
extent = Mathf.Max(extent, getter(child));
}
D.assert(child.parentData == childParentData);

child.layout(nonPositionedConstraints, parentUsesSize: true);
Size childSize = child.size;
width = Math.Max(width, childSize.width);
height = Math.Max(height, childSize.height);
width = Mathf.Max(width, childSize.width);
height = Mathf.Max(height, childSize.height);
}
child = childParentData.nextSibling;

child.layout(childConstraints, parentUsesSize: true);
double x;
float x;
if (childParentData.left != null) {
x = childParentData.left.Value;
}

this._hasVisualOverflow = true;
}
double y;
float y;
if (childParentData.top != null) {
y = childParentData.top.Value;
}

this._hasVisualOverflow = true;
}
childParentData.offset = new Offset((float) x, (float) y);
childParentData.offset = new Offset(x, y);
}
D.assert(child.parentData == childParentData);

2
Runtime/rendering/view.cs


});
properties.add(new DiagnosticsProperty<Size>("window size", Window.instance.physicalSize,
tooltip: "in physical pixels"));
properties.add(new DoubleProperty("device pixel ratio", Window.instance.devicePixelRatio,
properties.add(new floatProperty("device pixel ratio", Window.instance.devicePixelRatio,
tooltip: "physical pixels per logical pixel"));
properties.add(new DiagnosticsProperty<ViewConfiguration>("configuration", this.configuration,
tooltip: "in logical pixels"));

96
Runtime/rendering/viewport.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public interface RenderAbstractViewport {

while (child != null) {
float sliverScrollOffset = scrollOffset <= 0.0 ? 0.0f : scrollOffset;
float correctedCacheOrigin = (float) Math.Max(cacheOrigin, -sliverScrollOffset);
float correctedCacheOrigin = Mathf.Max(cacheOrigin, -sliverScrollOffset);
float cacheExtentCorrection = cacheOrigin - correctedCacheOrigin;
D.assert(sliverScrollOffset >= correctedCacheOrigin.abs());

userScrollDirection: adjustedUserScrollDirection,
scrollOffset: sliverScrollOffset,
overlap: maxPaintOffset - layoutOffset,
remainingPaintExtent: (float) Math.Max(0.0,
remainingPaintExtent: Mathf.Max(0.0f,
remainingCacheExtent: (float) Math.Max(0.0, remainingCacheExtent + cacheExtentCorrection),
cacheOrigin: (float) correctedCacheOrigin
remainingCacheExtent: Mathf.Max(0.0f, remainingCacheExtent + cacheExtentCorrection),
cacheOrigin: correctedCacheOrigin
), parentUsesSize: true);
var childLayoutGeometry = child.geometry;

this.updateChildLayoutOffset(child, -scrollOffset + initialLayoutOffset, growthDirection);
}
maxPaintOffset = (float) Math.Max(effectiveLayoutOffset + childLayoutGeometry.paintExtent,
maxPaintOffset = Mathf.Max(effectiveLayoutOffset + childLayoutGeometry.paintExtent,
maxPaintOffset);
scrollOffset -= childLayoutGeometry.scrollExtent;
layoutOffset += childLayoutGeometry.layoutExtent;

cacheOrigin = (float) Math.Min(correctedCacheOrigin + childLayoutGeometry.cacheExtent, 0.0);
cacheOrigin = Mathf.Min(correctedCacheOrigin + childLayoutGeometry.cacheExtent, 0.0f);
}
this.updateOutOfBandData(growthDirection, childLayoutGeometry);

RevealedOffset leadingEdgeOffset = viewport.getOffsetToReveal(descendant, 0.0f, rect: rect);
RevealedOffset trailingEdgeOffset = viewport.getOffsetToReveal(descendant, 1.0f, rect: rect);
double currentOffset = offset.pixels;
float currentOffset = offset.pixels;
double leadingEdgeDiff = (offset.pixels - leadingEdgeOffset.offset).abs();
double trailingEdgeDiff = (offset.pixels - trailingEdgeOffset.offset).abs();
float leadingEdgeDiff = (offset.pixels - leadingEdgeOffset.offset).abs();
float trailingEdgeDiff = (offset.pixels - trailingEdgeOffset.offset).abs();
targetOffset = leadingEdgeDiff < trailingEdgeDiff ? leadingEdgeOffset : trailingEdgeOffset;
}
else if (currentOffset > leadingEdgeOffset.offset) {

AxisDirection axisDirection = AxisDirection.down,
AxisDirection crossAxisDirection = AxisDirection.right,
ViewportOffset offset = null,
double anchor = 0.0,
float anchor = 0.0f,
List<RenderSliver> children = null,
RenderSliver center = null,
float cacheExtent = RenderViewportUtils.defaultCacheExtent

}
}
public double anchor {
public float anchor {
get { return this._anchor; }
set {
D.assert(value >= 0.0 && value <= 1.0);

}
}
public double _anchor;
public float _anchor;
public RenderSliver center {
get { return this._center; }

const int _maxLayoutCycles = 10;
double _minScrollExtent;
double _maxScrollExtent;
float _minScrollExtent;
float _maxScrollExtent;
this._minScrollExtent = 0.0;
this._maxScrollExtent = 0.0;
this._minScrollExtent = 0.0f;
this._maxScrollExtent = 0.0f;
this._hasVisualOverflow = false;
this.offset.applyContentDimensions(0.0f, 0.0f);
return;

}
else {
if (this.offset.applyContentDimensions(
(float) Math.Min(0.0, this._minScrollExtent + mainAxisExtent * this.anchor),
(float) Math.Max(0.0, this._maxScrollExtent - mainAxisExtent * (1.0 - this.anchor))
Mathf.Min(0.0f, this._minScrollExtent + mainAxisExtent * this.anchor),
Mathf.Max(0.0f, this._maxScrollExtent - mainAxisExtent * (1.0f - this.anchor))
)) {
break;
}

D.assert(crossAxisExtent >= 0.0);
D.assert(correctedOffset.isFinite());
this._minScrollExtent = 0.0;
this._maxScrollExtent = 0.0;
this._minScrollExtent = 0.0f;
this._maxScrollExtent = 0.0f;
double centerOffset = mainAxisExtent * this.anchor - correctedOffset;
double reverseDirectionRemainingPaintExtent = centerOffset.clamp(0.0, mainAxisExtent);
double forwardDirectionRemainingPaintExtent = (mainAxisExtent - centerOffset).clamp(0.0, mainAxisExtent);
float centerOffset = mainAxisExtent * this.anchor - correctedOffset;
float reverseDirectionRemainingPaintExtent = centerOffset.clamp(0.0f, mainAxisExtent);
float forwardDirectionRemainingPaintExtent = (mainAxisExtent - centerOffset).clamp(0.0f, mainAxisExtent);
double fullCacheExtent = mainAxisExtent + 2 * this.cacheExtent;
double centerCacheOffset = centerOffset + this.cacheExtent;
double reverseDirectionRemainingCacheExtent = centerCacheOffset.clamp(0.0, fullCacheExtent);
double forwardDirectionRemainingCacheExtent =
(fullCacheExtent - centerCacheOffset).clamp(0.0, fullCacheExtent);
float fullCacheExtent = mainAxisExtent + 2 * this.cacheExtent;
float centerCacheOffset = centerOffset + this.cacheExtent;
float reverseDirectionRemainingCacheExtent = centerCacheOffset.clamp(0.0f, fullCacheExtent);
float forwardDirectionRemainingCacheExtent =
(fullCacheExtent - centerCacheOffset).clamp(0.0f, fullCacheExtent);
RenderSliver leadingNegativeChild = this.childBefore(this.center);

scrollOffset: (float) Math.Max(mainAxisExtent, centerOffset) - mainAxisExtent,
scrollOffset: Mathf.Max(mainAxisExtent, centerOffset) - mainAxisExtent,
layoutOffset: (float) forwardDirectionRemainingPaintExtent,
remainingPaintExtent: (float) reverseDirectionRemainingPaintExtent,
layoutOffset: forwardDirectionRemainingPaintExtent,
remainingPaintExtent: reverseDirectionRemainingPaintExtent,
remainingCacheExtent: (float) reverseDirectionRemainingCacheExtent,
cacheOrigin: (float) (mainAxisExtent - centerOffset).clamp(-this.cacheExtent, 0.0)
remainingCacheExtent: reverseDirectionRemainingCacheExtent,
cacheOrigin: (mainAxisExtent - centerOffset).clamp(-this.cacheExtent, 0.0f)
if (result != 0.0) {
if (result != 0.0f) {
return -result;
}
}

scrollOffset: (float) Math.Max(0.0, -centerOffset),
overlap: leadingNegativeChild == null ? (float) Math.Min(0.0, -centerOffset) : 0.0f,
scrollOffset: Mathf.Max(0.0f, -centerOffset),
overlap: leadingNegativeChild == null ? Mathf.Min(0.0f, -centerOffset) : 0.0f,
? (float) centerOffset
: (float) reverseDirectionRemainingPaintExtent,
remainingPaintExtent: (float) forwardDirectionRemainingPaintExtent,
? centerOffset
: reverseDirectionRemainingPaintExtent,
remainingPaintExtent: forwardDirectionRemainingPaintExtent,
remainingCacheExtent: (float) forwardDirectionRemainingCacheExtent,
cacheOrigin: (float) centerOffset.clamp(-this.cacheExtent, 0.0)
remainingCacheExtent: forwardDirectionRemainingCacheExtent,
cacheOrigin: centerOffset.clamp(-this.cacheExtent, 0.0f)
);
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DoubleProperty("anchor", this.anchor));
properties.add(new floatProperty("anchor", this.anchor));
}
}

bool didAcceptViewportDimension = this.offset.applyViewportDimension(effectiveExtent);
bool didAcceptContentDimension =
this.offset.applyContentDimensions(0.0f,
(float) Math.Max(0.0, this._maxScrollExtent - effectiveExtent));
Mathf.Max(0.0f, this._maxScrollExtent - effectiveExtent));
if (didAcceptViewportDimension && didAcceptContentDimension) {
break;
}

return this.layoutChildSequence(
child: this.firstChild,
scrollOffset: (float) Math.Max(0.0, correctedOffset),
overlap: (float) Math.Min(0.0, correctedOffset),
scrollOffset: Mathf.Max(0.0f, correctedOffset),
overlap: Mathf.Min(0.0f, correctedOffset),
layoutOffset: 0.0f,
remainingPaintExtent: mainAxisExtent,
mainAxisExtent: mainAxisExtent,

D.assert(child != null);
Offset offset = this.paintOffsetOf((RenderSliver) child);
transform.preTranslate((float) offset.dx, (float) offset.dy);
transform.preTranslate(offset.dx, offset.dy);
}
protected override float computeChildMainAxisPosition(RenderSliver child, float parentMainAxisPosition) {

4
Runtime/scheduler/binding.cs


Window.instance.onDrawFrame += this._handleDrawFrame;
}
public double timeDilation {
public float timeDilation {
get { return this._timeDilation; }
set {
if (this._timeDilation == value) {

}
}
double _timeDilation = 1.0;
float _timeDilation = 1.0f;
int _nextFrameCallbackId = 0;
Dictionary<int, _FrameCallbackEntry> _transientCallbacks = new Dictionary<int, _FrameCallbackEntry>();

14
Runtime/service/text_input.cs


public TextEditingValue moveExtent(int move) {
int offset = this.selection.extentOffset + move;
offset = Math.Max(0, offset);
offset = Math.Min(offset, this.text.Length);
offset = Mathf.Max(0, offset);
offset = Mathf.Min(offset, this.text.Length);
offset = Math.Max(0, offset);
offset = Math.Min(offset, this.text.Length);
offset = Mathf.Max(0, offset);
offset = Mathf.Min(offset, this.text.Length);
return this.copyWith(selection: TextSelection.collapsed(offset, affinity: this.selection.affinity));
}

this._textInput.keyboardManager.setEditingState(value);
}
public void setCompositionCursorPos(double x, double y) {
public void setCompositionCursorPos(float x, float y) {
D.assert(this.attached);
this._textInput.setCompositionCursorPos(x, y);
}

return connection;
}
public void setCompositionCursorPos(double x, double y) {
Input.compositionCursorPos = new Vector2((float) x, (float) y);
public void setCompositionCursorPos(float x, float y) {
Input.compositionCursorPos = new Vector2(x, y);
}
internal void _updateEditingState(int client, TextEditingValue value) {

115
Runtime/ui/geometry.cs


namespace Unity.UIWidgets.ui {
public static class MathUtils {
public static double clamp(this double value, double min, double max) {
if (value < min) {
value = min;
}
else if (value > max) {
value = max;
}
return value;
}
public static float clamp(this float value, float min, float max) {
if (value < min) {
value = min;

}
return value;
}
public static double abs(this double value) {
return Math.Abs(value);
}
public static float abs(this float value) {

public static int sign(this double value) {
return Math.Sign(value);
}
public static int sign(this float value) {
return (int) Mathf.Sign(value);
}

return float.IsNaN(it);
}
public static double lerpDouble(double a, double b, double t) {
public static float lerpfloat(float a, float b, float t) {
public static float? lerpNullableDouble(float? a, float? b, float t) {
public static float? lerpNullablefloat(float? a, float? b, float t) {
if (a == null && b == null) {
return null;
}

return (float) a + ((float) b - (float) a) * t;
return a + (b - a) * t;
}
public static float? lerpNullableFloat(float? a, float? b, float t) {

a = a ?? b;
b = b ?? a;
return (float) a + ((float) b - (float) a) * t;
return a + (b - a) * t;
}
public static float lerpFloat(float a, float b, float t) {

public static int round(this double value) {
return (int) Math.Round(value);
}
public static int floor(this double value) {
return (int) Math.Floor(value);
}
public static int ceil(this double value) {
return (int) Math.Ceiling(value);
}
public static int round(this float value) {
return Mathf.RoundToInt(value);
}

}
public float distance {
get { return (float) Math.Sqrt(this._dx * this._dx + this._dy * this._dy); }
get { return Mathf.Sqrt(this._dx * this._dx + this._dy * this._dy); }
}
public float distanceSquared {

}
public float shortestSide {
get { return Math.Min(this.width.abs(), this.height.abs()); }
get { return Mathf.Min(this.width.abs(), this.height.abs()); }
get { return Math.Max(this.width.abs(), this.height.abs()); }
get { return Mathf.Max(this.width.abs(), this.height.abs()); }
}
public Offset topLeft(Offset origin) {

public static Rect fromPoints(Offset a, Offset b) {
return new Rect(
Math.Min(a.dx, b.dx),
Math.Min(a.dy, b.dy),
Math.Max(a.dx, b.dx),
Math.Max(a.dy, b.dy)
Mathf.Min(a.dx, b.dx),
Mathf.Min(a.dy, b.dy),
Mathf.Max(a.dx, b.dx),
Mathf.Max(a.dy, b.dy)
);
}

public Rect intersect(Rect other) {
return fromLTRB(
Math.Max(this.left, other.left),
Math.Max(this.top, other.top),
Math.Min(this.right, other.right),
Math.Min(this.bottom, other.bottom)
Mathf.Max(this.left, other.left),
Mathf.Max(this.top, other.top),
Mathf.Min(this.right, other.right),
Mathf.Min(this.bottom, other.bottom)
Math.Min(this.left, other.left),
Math.Min(this.top, other.top),
Math.Max(this.right, other.right),
Math.Max(this.bottom, other.bottom)
Mathf.Min(this.left, other.left),
Mathf.Min(this.top, other.top),
Mathf.Max(this.right, other.right),
Mathf.Max(this.bottom, other.bottom)
);
}

}
public float shortestSide {
get { return Math.Min(Math.Abs(this.width), Math.Abs(this.height)); }
get { return Mathf.Min(Mathf.Abs(this.width), Mathf.Abs(this.height)); }
get { return Math.Max(Math.Abs(this.width), Math.Abs(this.height)); }
get { return Mathf.Max(Mathf.Abs(this.width), Mathf.Abs(this.height)); }
}
public Offset topLeft {

public Rect round() {
return fromLTRB(
(float) Math.Round(this.left), (float) Math.Round(this.top),
(float) Math.Round(this.right), (float) Math.Round(this.bottom));
Mathf.Round(this.left), Mathf.Round(this.top),
Mathf.Round(this.right), Mathf.Round(this.bottom));
(float) Math.Floor(this.left), (float) Math.Floor(this.top),
(float) Math.Ceiling(this.right), (float) Math.Ceiling(this.bottom));
Mathf.Floor(this.left), Mathf.Floor(this.top),
Mathf.Ceil(this.right), Mathf.Ceil(this.bottom));
(float) Math.Ceiling(this.left), (float) Math.Ceiling(this.top),
(float) Math.Floor(this.right), (float) Math.Floor(this.bottom));
Mathf.Ceil(this.left), Mathf.Ceil(this.top),
Mathf.Floor(this.right), Mathf.Floor(this.bottom));
}
public static Rect lerp(Rect a, Rect b, float t) {

get {
const float kInsetFactor = 0.29289321881f; // 1-cos(pi/4)
float leftRadius = Math.Max(this.blRadiusX, this.tlRadiusX);
float topRadius = Math.Max(this.tlRadiusY, this.trRadiusY);
float rightRadius = Math.Max(this.trRadiusX, this.brRadiusX);
float bottomRadius = Math.Max(this.brRadiusY, this.blRadiusY);
float leftRadius = Mathf.Max(this.blRadiusX, this.tlRadiusX);
float topRadius = Mathf.Max(this.tlRadiusY, this.trRadiusY);
float rightRadius = Mathf.Max(this.trRadiusX, this.brRadiusX);
float bottomRadius = Mathf.Max(this.brRadiusY, this.blRadiusY);
return Rect.fromLTRB(
this.left + leftRadius * kInsetFactor,

public Rect middleRect {
get {
float leftRadius = Math.Max(this.blRadiusX, this.tlRadiusX);
float topRadius = Math.Max(this.tlRadiusY, this.trRadiusY);
float rightRadius = Math.Max(this.trRadiusX, this.brRadiusX);
float bottomRadius = Math.Max(this.brRadiusY, this.blRadiusY);
float leftRadius = Mathf.Max(this.blRadiusX, this.tlRadiusX);
float topRadius = Mathf.Max(this.tlRadiusY, this.trRadiusY);
float rightRadius = Mathf.Max(this.trRadiusX, this.brRadiusX);
float bottomRadius = Mathf.Max(this.brRadiusY, this.blRadiusY);
return Rect.fromLTRB(
this.left + leftRadius,

public Rect wideMiddleRect {
get {
float topRadius = Math.Max(this.tlRadiusY, this.trRadiusY);
float bottomRadius = Math.Max(this.brRadiusY, this.blRadiusY);
float topRadius = Mathf.Max(this.tlRadiusY, this.trRadiusY);
float bottomRadius = Mathf.Max(this.brRadiusY, this.blRadiusY);
return Rect.fromLTRB(
this.left,

public Rect tallMiddleRect {
get {
float leftRadius = Math.Max(this.blRadiusX, this.tlRadiusX);
float rightRadius = Math.Max(this.trRadiusX, this.brRadiusX);
float leftRadius = Mathf.Max(this.blRadiusX, this.tlRadiusX);
float rightRadius = Mathf.Max(this.trRadiusX, this.brRadiusX);
return Rect.fromLTRB(
this.left + leftRadius,

}
public float shortestSide {
get { return Math.Min(this.width.abs(), this.height.abs()); }
get { return Mathf.Min(this.width.abs(), this.height.abs()); }
get { return Math.Max(this.width.abs(), this.height.abs()); }
get { return Mathf.Max(this.width.abs(), this.height.abs()); }
}
public Offset center {

float _getMin(float min, float radius1, float radius2, float limit) {
float sum = radius1 + radius2;
if (sum > limit && sum != 0.0) {
return Math.Min(min, limit / sum);
return Mathf.Min(min, limit / sum);
}
return min;

58
Runtime/ui/matrix.cs


public static Matrix3 makeTrans(Offset offset) {
var m = new Matrix3();
m.setTranslate((float) offset.dx, (float) offset.dy);
m.setTranslate(offset.dx, offset.dy);
return m;
}

}
static float muladdmul(float a, float b, float c, float d) {
return (float) ((double) a * b + (double) c * d);
return (a * b + c * d);
}
public void setConcat(Matrix3 a, Matrix3 b) {

}
else {
var points = new[] {
this.mapXY((float) src.left, (float) src.top),
this.mapXY((float) src.right, (float) src.top),
this.mapXY((float) src.right, (float) src.bottom),
this.mapXY((float) src.left, (float) src.bottom),
this.mapXY(src.left, src.top),
this.mapXY(src.right, src.top),
this.mapXY(src.right, src.bottom),
this.mapXY(src.left, src.bottom),
};
var minX = points[0].dx;

for (int i = 1; i < 4; ++i) {
minX = Math.Min(minX, points[i].dx);
minY = Math.Min(minY, points[i].dy);
maxX = Math.Max(maxX, points[i].dx);
maxY = Math.Max(maxY, points[i].dy);
minX = Mathf.Min(minX, points[i].dx);
minY = Mathf.Min(minY, points[i].dy);
maxX = Mathf.Max(maxX, points[i].dx);
maxY = Mathf.Max(maxY, points[i].dy);
}
dst = Rect.fromLTRB(minX, minY, maxX, maxY);

kRectStaysRect_Shift
}
static void ComputeInv(float[] dst, float[] src, double invDet, bool isPersp) {
static void ComputeInv(float[] dst, float[] src, float invDet, bool isPersp) {
D.assert(src != dst);
D.assert(src != null && dst != null);

}
else {
// not perspective
dst[kMScaleX] = (float) (src[kMScaleY] * invDet);
dst[kMSkewX] = (float) (-src[kMSkewX] * invDet);
dst[kMScaleX] = (src[kMScaleY] * invDet);
dst[kMSkewX] = (-src[kMSkewX] * invDet);
dst[kMSkewY] = (float) (-src[kMSkewY] * invDet);
dst[kMScaleY] = (float) (src[kMScaleX] * invDet);
dst[kMSkewY] = (-src[kMSkewY] * invDet);
dst[kMScaleY] = (src[kMScaleX] * invDet);
dst[kMTransY] =
ScalarUtils.dcross_dscale(src[kMSkewY], src[kMTransX], src[kMScaleX],
src[kMTransY], invDet);

if (count > 0) {
for (int i = 0; i < count; ++i) {
var sy = (float) src[i].dy;
var sx = (float) src[i].dx;
var sy = src[i].dy;
var sx = src[i].dx;
var x = ScalarUtils.sdot(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]) +
m.fMat[kMTransX];
var y = ScalarUtils.sdot(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]) +

}
int isPersp = (int) (mask & TypeMask.kPerspective_Mask);
double invDet = ScalarUtils.inv_determinant(this.fMat, isPersp);
float invDet = ScalarUtils.inv_determinant(this.fMat, isPersp);
if (invDet == 0) {
// underflow

public Offset mapPoint(Offset point) {
return this.mapXY((float) point.dx, (float) point.dy);
return this.mapXY(point.dx, point.dy);
}
}

return a * b - c * d;
}
public static double dcross(double a, double b, double c, double d) {
public static float dcross(float a, float b, float c, float d) {
float c, float d, double scale) {
return (float) (scross(a, b, c, d) * scale);
float c, float d, float scale) {
return (scross(a, b, c, d) * scale);
public static float dcross_dscale(double a, double b,
double c, double d, double scale) {
return (float) (dcross(a, b, c, d) * scale);
public static float dcross_dscale(float a, float b,
float c, float d, float scale) {
return (dcross(a, b, c, d) * scale);
}
public static bool is_degenerate_2x2(

kScalarNearlyZero * kScalarNearlyZero);
}
public static double inv_determinant(float[] mat, int isPerspective) {
double det;
public static float inv_determinant(float[] mat, int isPerspective) {
float det;
if (isPerspective != 0) {
det = mat[Matrix3.kMScaleX] *

// Since the determinant is on the order of the cube of the matrix members,
// compare to the cube of the default nearly-zero constant (although an
// estimate of the condition number would be better if it wasn't so expensive).
if (ScalarNearlyZero((float) det,
if (ScalarNearlyZero(det,
return 1.0 / det;
return 1.0f / det;
}
}
}

4
Runtime/ui/painting/canvas.cs


void drawOval(Rect rect, Paint paint);
void drawCircle(Offset c, double radius, Paint paint);
void drawCircle(Offset c, float radius, Paint paint);
void drawArc(Rect rect, float startAngle, float sweepAngle, bool useCenter, Paint paint);

});
}
public void drawCircle(Offset c, double radius, Paint paint) {
public void drawCircle(Offset c, float radius, Paint paint) {
var path = new Path();
path.addCircle(c.dx, c.dy, radius);

12
Runtime/ui/painting/canvas_clip.cs


// }
//
// var offset = this._invMat.mapXY(x, y);
// x = (float) offset.dx;
// y = (float) offset.dy;
// x = offset.dx;
// y = offset.dy;
// }
//
// for (var i = 0; i < this.mesh.vertices.Count; i++) {

// this seems to be inefficient. disable it for now.
// if (this.convex) {
// return this._convexContains((float) rect.left, (float) rect.top) &&
// this._convexContains((float) rect.left, (float) rect.bottom) &&
// this._convexContains((float) rect.right, (float) rect.top) &&
// this._convexContains((float) rect.right, (float) rect.bottom);
// return this._convexContains(rect.left, rect.top) &&
// this._convexContains(rect.left, rect.bottom) &&
// this._convexContains(rect.right, rect.top) &&
// this._convexContains(rect.right, rect.bottom);
// }
return false;

80
Runtime/ui/painting/canvas_impl.cs


var state = this._getState();
var textureWidth = Mathf.CeilToInt(
(float) bounds.width * state.scale * this._devicePixelRatio);
bounds.width * state.scale * this._devicePixelRatio);
(float) bounds.height * state.scale * this._devicePixelRatio);
bounds.height * state.scale * this._devicePixelRatio);
textureHeight = Mathf.Max(textureHeight, 1);
var parentLayer = this._getLayer();

state.matrix = matrix;
}
else {
var matrix = Matrix3.makeRotate(radians, (float) offset.dx, (float) offset.dy);
var matrix = Matrix3.makeRotate(radians, offset.dx, offset.dy);
matrix.postConcat(state.matrix);
state.matrix = matrix;
}

this.drawPath(path, paint);
}
public void drawCircle(Offset c, double radius, Paint paint) {
public void drawCircle(Offset c, float radius, Paint paint) {
var path = new Path();
path.addCircle(c.dx, c.dy, radius);
this.drawPath(path, paint);

RenderLayer _createMaskLayer(RenderLayer parentLayer, Rect maskBounds, Action<Paint> drawCallback,
Paint paint) {
var textureWidth = Mathf.CeilToInt((float) maskBounds.width * this._devicePixelRatio);
var textureWidth = Mathf.CeilToInt(maskBounds.width * this._devicePixelRatio);
var textureHeight = Mathf.CeilToInt((float) maskBounds.height * this._devicePixelRatio);
var textureHeight = Mathf.CeilToInt(maskBounds.height * this._devicePixelRatio);
textureHeight = Mathf.Max(1, textureHeight);
var maskLayer = new RenderLayer {

RenderLayer _createBlurLayer(RenderLayer maskLayer, float sigma, RenderLayer parentLayer) {
sigma = BlurUtils.adjustSigma(sigma, out var scaleFactor, out var radius);
var textureWidth = Mathf.CeilToInt((float) maskLayer.width / scaleFactor);
var textureWidth = Mathf.CeilToInt(maskLayer.width / scaleFactor);
var textureHeight = Mathf.CeilToInt((float) maskLayer.height / scaleFactor);
var textureHeight = Mathf.CeilToInt(maskLayer.height / scaleFactor);
textureHeight = Mathf.Max(1, textureHeight);
var blurXLayer = new RenderLayer {

}
var state = this._getState();
float sigma = state.scale * (float) maskFilter.sigma;
float sigma = state.scale * maskFilter.sigma;
if (sigma <= 0) {
return;
}

}
else {
var state = this._getState();
float strokeWidth = ((float) paint.strokeWidth * state.scale).clamp(0, 200.0f);
float strokeWidth = (paint.strokeWidth * state.scale).clamp(0, 200.0f);
float alpha = 1.0f;
if (strokeWidth == 0) {

strokeWidth / state.scale * 0.5f,
paint.strokeCap,
paint.strokeJoin,
(float) paint.strokeMiterLimit).transform(state.matrix);
paint.strokeMiterLimit).transform(state.matrix);
Action<Paint> drawMesh = (Paint p) => {
if (!this._applyClip(mesh.bounds)) {

var scale = state.scale * this._devicePixelRatio;
var matrix = new Matrix3(state.matrix);
matrix.preTranslate((float) offset.dx, (float) offset.dy);
matrix.preTranslate(offset.dx, offset.dy);
var mesh = MeshGenerator.generateMesh(textBlob, scale)?.transform(matrix);
if (mesh == null) {
return;

get {
if (!this._viewport.HasValue) {
this._viewport = new Vector4(
(float) this.layerBounds.left,
(float) this.layerBounds.top,
(float) this.layerBounds.width,
(float) this.layerBounds.height);
this.layerBounds.left,
this.layerBounds.top,
this.layerBounds.width,
this.layerBounds.height);
}
return this._viewport.Value;

var vertices = new List<Vector3>(4);
var uv = new List<Vector2>(4);
float uvx0 = (float) src.left;
float uvx1 = (float) src.right;
float uvy0 = 1.0f - (float) src.top;
float uvy1 = 1.0f - (float) src.bottom;
float uvx0 = src.left;
float uvx1 = src.right;
float uvy0 = 1.0f - src.top;
float uvy1 = 1.0f - src.bottom;
vertices.Add(new Vector2((float) dst.left, (float) dst.top));
vertices.Add(new Vector2(dst.left, dst.top));
vertices.Add(new Vector2((float) dst.left, (float) dst.bottom));
vertices.Add(new Vector2(dst.left, dst.bottom));
vertices.Add(new Vector2((float) dst.right, (float) dst.bottom));
vertices.Add(new Vector2(dst.right, dst.bottom));
vertices.Add(new Vector2((float) dst.right, (float) dst.top));
vertices.Add(new Vector2(dst.right, dst.top));
uv.Add(new Vector2(uvx1, uvy0));
return new MeshMesh(matrix, vertices, _imageTriangles, uv);

Rect dst) {
float x0 = (float) dst.left;
float x3 = (float) dst.right;
float x1 = x0 + (float) ((center.left - src.left) * srcWidth);
float x2 = x3 - (float) ((src.right - center.right) * srcWidth);
float x0 = dst.left;
float x3 = dst.right;
float x1 = x0 + ((center.left - src.left) * srcWidth);
float x2 = x3 - ((src.right - center.right) * srcWidth);
float y0 = (float) dst.top;
float y3 = (float) dst.bottom;
float y1 = y0 + (float) ((center.top - src.top) * srcHeight);
float y2 = y3 - (float) ((src.bottom - center.bottom) * srcHeight);
float y0 = dst.top;
float y3 = dst.bottom;
float y1 = y0 + ((center.top - src.top) * srcHeight);
float y2 = y3 - ((src.bottom - center.bottom) * srcHeight);
float tx0 = (float) src.left;
float tx1 = (float) center.left;
float tx2 = (float) center.right;
float tx3 = (float) src.right;
float ty0 = 1 - (float) src.top;
float ty1 = 1 - (float) center.top;
float ty2 = 1 - (float) center.bottom;
float ty3 = 1 - (float) src.bottom;
float tx0 = src.left;
float tx1 = center.left;
float tx2 = center.right;
float tx3 = src.right;
float ty0 = 1 - src.top;
float ty1 = 1 - center.top;
float ty2 = 1 - center.bottom;
float ty3 = 1 - src.bottom;
var vertices = new List<Vector3>(16);
var uv = new List<Vector2>(16);

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存