浏览代码

Merge branch 'double_to_float' into 'master'

Change double to float.

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!68
/main
Xingwei Zhu 6 年前
当前提交
befbb3d0
共有 205 个文件被更改,包括 1646 次插入1507 次删除
  1. 2
      Editor/EditorExample.cs
  2. 1
      Editor/editor/EditorUtils.cs
  3. 2
      Editor/editor/WidgetCanvasEditor.cs
  4. 4
      Runtime/animation/animation.cs
  5. 116
      Runtime/animation/animation_controller.cs
  6. 107
      Runtime/animation/animations.cs
  7. 152
      Runtime/animation/curves.cs
  8. 58
      Runtime/animation/tween.cs
  9. 4
      Runtime/async/coroutine.cs
  10. 12
      Runtime/async/timer.cs
  11. 2
      Runtime/debugger/inpsector_panel.cs
  12. 15
      Runtime/editor/editor_window.cs
  13. 8
      Runtime/editor/scroll_input.cs
  14. 16
      Runtime/editor/surface.cs
  15. 10
      Runtime/engine/DisplayMetrics.cs
  16. 32
      Runtime/engine/WidgetCanvas.cs
  17. 4
      Runtime/flow/layer_tree.cs
  18. 2
      Runtime/flow/picture_layer.cs
  19. 10
      Runtime/flow/raster_cache.cs
  20. 5
      Runtime/foundation/basic_types.cs
  21. 2
      Runtime/foundation/debug.cs
  22. 20
      Runtime/foundation/diagnostics.cs
  23. 12
      Runtime/gestures/constants.cs
  24. 2
      Runtime/gestures/converter.cs
  25. 8
      Runtime/gestures/drag_details.cs
  26. 64
      Runtime/gestures/lsq_resolver.cs
  27. 43
      Runtime/gestures/monodrag.cs
  28. 2
      Runtime/gestures/multitap.cs
  29. 2
      Runtime/gestures/recognizer.cs
  30. 25
      Runtime/gestures/velocity_tracker.cs
  31. 62
      Runtime/material/arc.cs
  32. 20
      Runtime/material/button.cs
  33. 6
      Runtime/material/button_bar.cs
  34. 66
      Runtime/material/button_theme.cs
  35. 12
      Runtime/material/card.cs
  36. 2
      Runtime/material/color_scheme.cs
  37. 12
      Runtime/material/constants.cs
  38. 12
      Runtime/material/divider.cs
  39. 19
      Runtime/material/drawer.cs
  40. 6
      Runtime/material/drawer_header.cs
  41. 15
      Runtime/material/expand_icon.cs
  42. 8
      Runtime/material/expansion_panel.cs
  43. 12
      Runtime/material/expansion_tile.cs
  44. 2
      Runtime/material/flat_button.cs
  45. 12
      Runtime/material/grid_tile.cs
  46. 12
      Runtime/material/icon_button.cs
  47. 12
      Runtime/material/ink_decoration.cs
  48. 26
      Runtime/material/ink_ripple.cs
  49. 10
      Runtime/material/ink_splash.cs
  50. 8
      Runtime/material/ink_well.cs
  51. 110
      Runtime/material/list_tile.cs
  52. 24
      Runtime/material/material.cs
  53. 20
      Runtime/material/material_button.cs
  54. 38
      Runtime/material/mergeable_material.cs
  55. 26
      Runtime/material/raised_button.cs
  56. 4
      Runtime/material/scrollbar.cs
  57. 60
      Runtime/material/shadows.cs
  58. 20
      Runtime/material/text_selection.cs
  59. 6
      Runtime/material/text_theme.cs
  60. 2
      Runtime/material/theme.cs
  61. 10
      Runtime/material/theme_data.cs
  62. 40
      Runtime/material/tooltip.cs
  63. 188
      Runtime/material/typography.cs
  64. 58
      Runtime/material/utils.cs
  65. 72
      Runtime/painting/alignment.cs
  66. 51
      Runtime/painting/beveled_rectangle_border.cs
  67. 22
      Runtime/painting/border_radius.cs
  68. 60
      Runtime/painting/borders.cs
  69. 24
      Runtime/painting/box_border.cs
  70. 22
      Runtime/painting/box_decoration.cs
  71. 10
      Runtime/painting/box_fit.cs
  72. 32
      Runtime/painting/box_shadow.cs
  73. 15
      Runtime/painting/circle_border.cs
  74. 15
      Runtime/painting/decoration.cs
  75. 14
      Runtime/painting/decoration_image.cs
  76. 52
      Runtime/painting/edge_insets.cs
  77. 21
      Runtime/painting/geometry.cs
  78. 129
      Runtime/painting/gradient.cs
  79. 26
      Runtime/painting/image_provider.cs
  80. 4
      Runtime/painting/image_resolution.cs
  81. 8
      Runtime/painting/image_stream.cs
  82. 7
      Runtime/painting/matrix_utils.cs
  83. 40
      Runtime/painting/rounded_rectangle_border.cs
  84. 40
      Runtime/painting/shape_decoration.cs
  85. 128
      Runtime/painting/stadium_border.cs
  86. 44
      Runtime/painting/text_painter.cs
  87. 2
      Runtime/painting/text_span.cs
  88. 60
      Runtime/painting/text_style.cs
  89. 22
      Runtime/physics/clamped_simulation.cs
  90. 59
      Runtime/physics/friction_simulation.cs
  91. 24
      Runtime/physics/gravity_simulation.cs
  92. 6
      Runtime/physics/simulation.cs
  93. 143
      Runtime/physics/spring_simulation.cs
  94. 14
      Runtime/physics/tolerance.cs
  95. 6
      Runtime/physics/utils.cs
  96. 6
      Runtime/rendering/animated_size.cs
  97. 243
      Runtime/rendering/box.cs
  98. 13
      Runtime/rendering/box.mixin.gen.cs
  99. 13
      Runtime/rendering/box.mixin.njk
  100. 24
      Runtime/rendering/custom_layout.cs

2
Editor/EditorExample.cs


return parameter3 ? (parameter1 + parameter2) : (parameter1 - parameter2);
}
}
}
}

1
Editor/editor/EditorUtils.cs


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

2
Editor/editor/WidgetCanvasEditor.cs


this.serializedObject.ApplyModifiedProperties();
}
}
}
}

4
Runtime/animation/animation.cs


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

116
Runtime/animation/animation_controller.cs


}
public class AnimationController :
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<double> {
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<float> {
double? value = null,
float? value = null,
double lowerBound = 0.0,
double upperBound = 1.0,
float lowerBound = 0.0f,
float upperBound = 1.0f,
TickerProvider vsync = null
) {
D.assert(upperBound >= lowerBound);

}
AnimationController(
double value = 0.0,
float value = 0.0f,
this.lowerBound = double.NegativeInfinity;
this.upperBound = double.PositiveInfinity;
this.lowerBound = float.NegativeInfinity;
this.upperBound = float.PositiveInfinity;
this._direction = _AnimationDirection.forward;
this.duration = duration;

}
public static AnimationController unbounded(
double value = 0.0,
float value = 0.0f,
TimeSpan? duration = null,
string debugLabel = null,
TickerProvider vsync = null

public readonly double lowerBound;
public readonly float lowerBound;
public readonly double upperBound;
public readonly float upperBound;
public Animation<double> view {
public Animation<float> view {
get { return this; }
}

Simulation _simulation;
public override double value {
public override float value {
double _value;
float _value;
public void setValue(double newValue) {
public void setValue(float newValue) {
this.stop();
this._internalSetValue(newValue);
this.notifyListeners();

this.setValue(this.lowerBound);
}
public double velocity {
public float velocity {
return 0.0;
return 0.0f;
return this._simulation.dx((double) this.lastElapsedDuration.Value.Ticks / TimeSpan.TicksPerSecond);
return this._simulation.dx((float) this.lastElapsedDuration.Value.Ticks / TimeSpan.TicksPerSecond);
void _internalSetValue(double newValue) {
void _internalSetValue(float newValue) {
this._value = newValue.clamp(this.lowerBound, this.upperBound);
if (this._value == this.lowerBound) {
this._status = AnimationStatus.dismissed;

AnimationStatus _status;
public TickerFuture forward(double? from = null) {
public TickerFuture forward(float? from = null) {
D.assert(() => {
if (this.duration == null) {
throw new UIWidgetsError(

return this._animateToInternal(this.upperBound);
}
public TickerFuture reverse(double? from = null) {
public TickerFuture reverse(float? from = null) {
D.assert(() => {
if (this.duration == null) {
throw new UIWidgetsError(

return this._animateToInternal(this.lowerBound);
}
public TickerFuture animateTo(double target, TimeSpan? duration = null, Curve curve = null) {
public TickerFuture animateTo(float target, TimeSpan? duration = null, Curve curve = null) {
curve = curve ?? Curves.linear;
this._direction = _AnimationDirection.forward;

TickerFuture _animateToInternal(double target, TimeSpan? duration = null, Curve curve = null) {
TickerFuture _animateToInternal(float target, TimeSpan? duration = null, Curve curve = null) {
curve = curve ?? Curves.linear;
TimeSpan? simulationDuration = duration;

return true;
});
double range = this.upperBound - this.lowerBound;
double remainingFraction = range.isFinite() ? (target - this._value).abs() / range : 1.0;
float range = this.upperBound - this.lowerBound;
float remainingFraction = range.isFinite() ? (target - this._value).abs() / range : 1.0f;
simulationDuration = TimeSpan.FromTicks((long) (this.duration.Value.Ticks * remainingFraction));
}
else if (target == this.value) {

new _InterpolationSimulation(this._value, target, simulationDuration.Value, curve));
}
public TickerFuture repeat(double? min = null, double? max = null, TimeSpan? period = null) {
public TickerFuture repeat(float? min = null, float? max = null, TimeSpan? period = null) {
min = min ?? this.lowerBound;
max = max ?? this.upperBound;
period = period ?? this.duration;

return this.animateWith(new _RepeatingSimulation(min.Value, max.Value, period.Value));
}
public TickerFuture fling(double velocity = 1.0) {
public TickerFuture fling(float velocity = 1.0f) {
double target = velocity < 0.0
float target = velocity < 0.0f
? this.lowerBound - _kFlingTolerance.distance
: this.upperBound + _kFlingTolerance.distance;
Simulation simulation = new SpringSimulation(_kFlingSpringDescription, this.value,

D.assert(!this.isAnimating);
this._simulation = simulation;
this._lastElapsedDuration = TimeSpan.Zero;
this._value = simulation.x(0.0).clamp(this.lowerBound, this.upperBound);
this._value = simulation.x(0.0f).clamp(this.lowerBound, this.upperBound);
var result = this._ticker.start();
this._status = (this._direction == _AnimationDirection.forward)
? AnimationStatus.forward

void _tick(TimeSpan elapsed) {
this._lastElapsedDuration = elapsed;
double elapsedInSeconds = (double) elapsed.Ticks / TimeSpan.TicksPerSecond;
float elapsedInSeconds = (float) elapsed.Ticks / TimeSpan.TicksPerSecond;
D.assert(elapsedInSeconds >= 0.0);
this._value = this._simulation.x(elapsedInSeconds).clamp(this.lowerBound, this.upperBound);
if (this._simulation.isDone(elapsedInSeconds)) {

}
static readonly SpringDescription _kFlingSpringDescription = SpringDescription.withDampingRatio(
mass: 1.0,
stiffness: 500.0,
ratio: 1.0
mass: 1.0f,
stiffness: 500.0f,
ratio: 1.0f
velocity: double.PositiveInfinity,
distance: 0.01
velocity: float.PositiveInfinity,
distance: 0.01f
internal _InterpolationSimulation(double begin, double end, TimeSpan duration, Curve curve) {
internal _InterpolationSimulation(float begin, float end, TimeSpan duration, Curve curve) {
this._durationInSeconds = (double) duration.Ticks / TimeSpan.TicksPerSecond;
this._durationInSeconds = (float) duration.Ticks / TimeSpan.TicksPerSecond;
readonly double _durationInSeconds;
readonly double _begin;
readonly double _end;
readonly float _durationInSeconds;
readonly float _begin;
readonly float _end;
public override double x(double timeInSeconds) {
double t = (timeInSeconds / this._durationInSeconds).clamp(0.0, 1.0);
if (t == 0.0) {
public override float x(float timeInSeconds) {
float t = (timeInSeconds / this._durationInSeconds).clamp(0.0f, 1.0f);
if (t == 0.0f) {
else if (t == 1.0) {
else if (t == 1.0f) {
return this._end;
}
else {

public override double dx(double timeInSeconds) {
double epsilon = this.tolerance.time;
public override float dx(float timeInSeconds) {
float epsilon = this.tolerance.time;
public override bool isDone(double timeInSeconds) {
public override bool isDone(float timeInSeconds) {
internal _RepeatingSimulation(double min, double max, TimeSpan period) {
internal _RepeatingSimulation(float min, float max, TimeSpan period) {
this._periodInSeconds = (double) period.Ticks / TimeSpan.TicksPerSecond;
D.assert(this._periodInSeconds > 0.0);
this._periodInSeconds = (float) period.Ticks / TimeSpan.TicksPerSecond;
D.assert(this._periodInSeconds > 0.0f);
readonly double _min;
readonly double _max;
readonly double _periodInSeconds;
readonly float _min;
readonly float _max;
readonly float _periodInSeconds;
public override double x(double timeInSeconds) {
D.assert(timeInSeconds >= 0.0);
double t = (timeInSeconds / this._periodInSeconds) % 1.0;
return MathUtils.lerpDouble(this._min, this._max, t);
public override float x(float timeInSeconds) {
D.assert(timeInSeconds >= 0.0f);
float t = (timeInSeconds / this._periodInSeconds) % 1.0f;
return MathUtils.lerpFloat(this._min, this._max, t);
public override double dx(double timeInSeconds) {
public override float dx(float timeInSeconds) {
public override bool isDone(double timeInSeconds) {
public override bool isDone(float timeInSeconds) {
return false;
}
}

107
Runtime/animation/animations.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
class _AlwaysCompleteAnimation : Animation<double> {
class _AlwaysCompleteAnimation : Animation<float> {
internal _AlwaysCompleteAnimation() {
}

}
public override double value {
get { return 1.0; }
public override float value {
get { return 1.0f; }
}
public override string ToString() {

class _AlwaysDismissedAnimation : Animation<double> {
class _AlwaysDismissedAnimation : Animation<float> {
internal _AlwaysDismissedAnimation() {
}

}
public override double value {
get { return 0.0; }
public override float value {
get { return 0.0f; }
}
public override string ToString() {

}
public class ProxyAnimation :
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<double> {
public ProxyAnimation(Animation<double> animation = null) {
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<float> {
public ProxyAnimation(Animation<float> animation = null) {
this._value = 0.0;
this._value = 0.0f;
double _value;
float _value;
public Animation<double> parent {
public Animation<float> parent {
get { return this._parent; }
set {
if (value == this._parent) {

}
}
Animation<double> _parent;
Animation<float> _parent;
protected override void didStartListening() {
if (this._parent != null) {

get { return this._parent != null ? this._parent.status : this._status; }
}
public override double value {
public override float value {
get { return this._parent != null ? this._parent.value : this._value; }
}

}
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) {

}
}
public class CurvedAnimation : AnimationWithParentMixin<double, double> {
public class CurvedAnimation : AnimationWithParentMixin<float, float> {
Animation<double> parent = null,
Animation<float> parent = null,
Curve curve = null,
Curve reverseCurve = null
) {

parent.addStatusListener(this._updateCurveDirection);
}
public override Animation<double> parent {
public override Animation<float> parent {
readonly Animation<double> _parent;
readonly Animation<float> _parent;
public Curve curve;

}
}
public override double value {
public override float value {
double t = this.parent.value;
float t = this.parent.value;
if (activeCurve == null) {
return t;
}

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(

}
public class TrainHoppingAnimation :
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<double> {
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<float> {
Animation<double> currentTrain = null,
Animation<double> nextTrain = null,
Animation<float> currentTrain = null,
Animation<float> nextTrain = null,
VoidCallback onSwitchedTrain = null) {
D.assert(currentTrain != null);
this._currentTrain = currentTrain;

}
}
public Animation<double> currentTrain {
public Animation<float> currentTrain {
Animation<double> _currentTrain;
Animation<double> _nextTrain;
Animation<float> _currentTrain;
Animation<float> _nextTrain;
_TrainHoppingMode _mode;
public VoidCallback onSwitchedTrain;

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 override double value {
public override float value {
get { return this._currentTrain.value; }
}

}
}
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); }
public static readonly Animation<double> kAlwaysCompleteAnimation = new _AlwaysCompleteAnimation();
public static readonly Animation<float> kAlwaysCompleteAnimation = new _AlwaysCompleteAnimation();
public static readonly Animation<double> kAlwaysDismissedAnimation = new _AlwaysDismissedAnimation();
public static readonly Animation<float> kAlwaysDismissedAnimation = new _AlwaysDismissedAnimation();
}
}

152
Runtime/animation/curves.cs


using System;
using UnityEngine;
public abstract double transform(double t);
public abstract float transform(float t);
public Curve flipped {
get { return new FlippedCurve(this); }

}
class _Linear : Curve {
public override double transform(double t) {
public override float transform(float t) {
return t;
}
}

public readonly int count;
public override double transform(double t) {
public override float transform(float t) {
if (t == 1.0) {
return 1.0;
if (t == 1.0f) {
return 1.0f;
}
t *= this.count;

}
public class Interval : Curve {
public Interval(double begin, double end, Curve curve = null) {
public Interval(float begin, float end, Curve curve = null) {
public readonly double begin;
public readonly float begin;
public readonly double end;
public readonly float end;
public override double transform(double t) {
public override float transform(float t) {
D.assert(t >= 0.0 && t <= 1.0);
D.assert(this.begin >= 0.0);
D.assert(this.begin <= 1.0);

return t;
}
t = ((t - this.begin) / (this.end - this.begin)).clamp(0.0, 1.0);
t = ((t - this.begin) / (this.end - this.begin)).clamp(0.0f, 1.0f);
if (t == 0.0 || t == 1.0) {
return t;
}

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

return t < this.threshold ? 0.0 : 1.0;
return t < this.threshold ? 0.0f : 1.0f;
public Cubic(double a, double b, double c, double d) {
public Cubic(float a, float b, float c, float d) {
this.a = a;
this.b = b;
this.c = c;

public readonly double a;
public readonly float a;
public readonly double b;
public readonly float b;
public readonly double c;
public readonly float c;
public readonly double d;
public readonly float d;
const double _cubicErrorBound = 0.001;
const float _cubicErrorBound = 0.001f;
double _evaluateCubic(double a, double b, double m) {
float _evaluateCubic(float a, float b, float m) {
public override double transform(double t) {
public override float transform(float t) {
double start = 0.0;
double end = 1.0;
float start = 0.0f;
float end = 1.0f;
double midpoint = (start + end) / 2;
double estimate = this._evaluateCubic(this.a, this.c, midpoint);
float midpoint = (start + end) / 2;
float estimate = this._evaluateCubic(this.a, this.c, midpoint);
if ((t - estimate).abs() < _cubicErrorBound) {
return this._evaluateCubic(this.b, this.d, midpoint);
}

public readonly Curve curve;
public override double transform(double t) {
return 1.0 - this.curve.transform(1.0 - t);
public override float transform(float t) {
return 1.0f - this.curve.transform(1.0f - t);
}
public override string ToString() {

internal _DecelerateCurve() {
}
public override double transform(double t) {
public override float transform(float t) {
t = 1.0 - t;
return 1.0 - t * t;
t = 1.0f - t;
return 1.0f - t * t;
}
}

public override double transform(double t) {
public override float transform(float t) {
return 1.0 - Curves._bounce(1.0 - t);
return 1.0f - Curves._bounce(1.0f - t);
}
}

public override double transform(double t) {
D.assert(t >= 0.0 && t <= 1.0);
public override float transform(float t) {
D.assert(t >= 0.0f && t <= 1.0f);
return Curves._bounce(t);
}
}

}
public override double transform(double t) {
D.assert(t >= 0.0 && t <= 1.0);
if (t < 0.5) {
return (1.0 - Curves._bounce(1.0 - t)) * 0.5;
public override float transform(float t) {
D.assert(t >= 0.0 && t <= 1.0f);
if (t < 0.5f) {
return (1.0f - Curves._bounce(1.0f - t)) * 0.5f;
return Curves._bounce(t * 2.0 - 1.0) * 0.5 + 0.5;
return Curves._bounce(t * 2.0f - 1.0f) * 0.5f + 0.5f;
public ElasticInCurve(double period = 0.4) {
public ElasticInCurve(float period = 0.4f) {
public readonly double period;
public readonly float period;
public override double transform(double t) {
public override float transform(float t) {
double s = this.period / 4.0;
t = t - 1.0;
return -Math.Pow(2.0, 10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period);
float s = this.period / 4.0f;
t = t - 1.0f;
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;
public override double transform(double t) {
public override float transform(float t) {
double s = this.period / 4.0;
return 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;
public override double transform(double t) {
public override float transform(float t) {
double s = this.period / 4.0;
t = 2.0 * t - 1.0;
float s = this.period / 4.0f;
t = 2.0f * t - 1.0f;
return -0.5 * Math.Pow(2.0, 10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period);
return -0.5f * Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period);
return Math.Pow(2.0, -10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period) * 0.5 + 1.0;
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period) * 0.5f +
1.0f;
}
}

public static readonly Curve decelerate = new _DecelerateCurve();
public static readonly Curve ease = new Cubic(0.25, 0.1, 0.25, 1.0);
public static readonly Curve ease = new Cubic(0.25f, 0.1f, 0.25f, 1.0f);
public static readonly Curve easeIn = new Cubic(0.42, 0.0, 1.0, 1.0);
public static readonly Curve easeIn = new Cubic(0.42f, 0.0f, 1.0f, 1.0f);
public static readonly Curve easeOut = new Cubic(0.0, 0.0, 0.58, 1.0);
public static readonly Curve easeOut = new Cubic(0.0f, 0.0f, 0.58f, 1.0f);
public static readonly Curve easeInOut = new Cubic(0.42, 0.0, 0.58, 1.0);
public static readonly Curve easeInOut = new Cubic(0.42f, 0.0f, 0.58f, 1.0f);
public static readonly Curve fastOutSlowIn = new Cubic(0.4, 0.0, 0.2, 1.0);
public static readonly Curve fastOutSlowIn = new Cubic(0.4f, 0.0f, 0.2f, 1.0f);
public static readonly Curve bounceIn = new _BounceInCurve();

public static readonly Curve elasticInOut = new ElasticInOutCurve();
internal static double _bounce(double t) {
if (t < 1.0 / 2.75) {
return 7.5625 * t * t;
internal static float _bounce(float t) {
if (t < 1.0f / 2.75f) {
return 7.5625f * t * t;
else if (t < 2 / 2.75) {
t -= 1.5 / 2.75;
return 7.5625 * t * t + 0.75;
else if (t < 2 / 2.75f) {
t -= 1.5f / 2.75f;
return 7.5625f * t * t + 0.75f;
else if (t < 2.5 / 2.75) {
t -= 2.25 / 2.75;
return 7.5625 * t * t + 0.9375;
else if (t < 2.5f / 2.75f) {
t -= 2.25f / 2.75f;
return 7.5625f * t * t + 0.9375f;
t -= 2.625 / 2.75;
return 7.5625 * t * t + 0.984375;
t -= 2.625f / 2.75f;
return 7.5625f * t * t + 0.984375f;
}
}
}

58
Runtime/animation/tween.cs


namespace Unity.UIWidgets.animation {
public abstract class Animatable<T> {
public abstract T evaluate(Animation<double> animation);
public abstract T evaluate(Animation<float> animation);
public Animation<T> animate(Animation<double> parent) {
public Animation<T> animate(Animation<float> parent) {
public Animatable<T> chain(Animatable<double> parent) {
public Animatable<T> chain(Animatable<float> parent) {
class _AnimatedEvaluation<T> : AnimationWithParentMixin<double, T> {
internal _AnimatedEvaluation(Animation<double> parent, Animatable<T> evaluatable) {
class _AnimatedEvaluation<T> : AnimationWithParentMixin<float, T> {
internal _AnimatedEvaluation(Animation<float> parent, Animatable<T> evaluatable) {
public override Animation<double> parent {
public override Animation<float> parent {
readonly Animation<double> _parent;
readonly Animation<float> _parent;
readonly Animatable<T> _evaluatable;

class _ChainedEvaluation<T> : Animatable<T> {
internal _ChainedEvaluation(Animatable<double> parent, Animatable<T> evaluatable) {
internal _ChainedEvaluation(Animatable<float> parent, Animatable<T> evaluatable) {
readonly Animatable<double> _parent;
readonly Animatable<float> _parent;
public override T evaluate(Animation<double> animation) {
double value = this._parent.evaluate(animation);
return this._evaluatable.evaluate(new AlwaysStoppedAnimation<double>(value));
public override T evaluate(Animation<float> animation) {
float value = this._parent.evaluate(animation);
return this._evaluatable.evaluate(new AlwaysStoppedAnimation<float>(value));
}
public override string ToString() {

public T end;
public abstract T lerp(double t);
public abstract T lerp(float t);
public override T evaluate(Animation<double> animation) {
double t = animation.value;
public override T evaluate(Animation<float> animation) {
float t = animation.value;
if (t == 0.0) {
return this.begin;
}

public readonly Tween<T> parent;
public override T lerp(double t) {
return this.parent.lerp(1.0 - t);
public override T lerp(float t) {
return this.parent.lerp(1.0f - t);
}
}

public override Color lerp(double t) {
public override Color lerp(float t) {
return Color.lerp(this.begin, this.end, t);
}
}

}
public override Size lerp(double t) {
public override Size lerp(float t) {
return Size.lerp(this.begin, this.end, t);
}
}

}
public override Rect lerp(double t) {
public override Rect lerp(float t) {
return Rect.lerp(this.begin, this.end, t);
}
}

}
public override int lerp(double t) {
public override int lerp(float t) {
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(double t) {
public override float lerp(float t) {
return this.begin + (this.end - this.begin) * t;
}
}

}
public override int lerp(double t) {
public override int lerp(float t) {
return (this.begin + (this.end - this.begin) * t).floor();
}
}

}
public override Offset lerp(double t) {
public override Offset lerp(float t) {
public class CurveTween : Animatable<double> {
public class CurveTween : Animatable<float> {
public CurveTween(Curve curve = null) {
D.assert(curve != null);
this.curve = curve;

public override double evaluate(Animation<double> animation) {
double t = animation.value;
public override float evaluate(Animation<float> animation) {
float t = animation.value;
if (t == 0.0 || t == 1.0) {
D.assert(this.curve.transform(t).round() == t);
return 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);

15
Runtime/editor/editor_window.cs


get { return this.editorWindow.titleContent; }
}
protected override double queryDevicePixelRatio() {
protected override float queryDevicePixelRatio() {
return EditorGUIUtility.pixelsPerPoint;
}

if (this._devicePixelRatio != this.queryDevicePixelRatio()) {
return true;
}
var size = this.queryWindowSize();
if (this._lastWindowWidth != size.x
|| this._lastWindowHeight != size.y) {

get { return null; }
}
protected abstract double queryDevicePixelRatio();
protected abstract float queryDevicePixelRatio();
protected abstract Vector2 queryWindowSize();
protected virtual Surface createSurface() {

);
}
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
);
}

if (this._textInput != null) {
this._textInput.keyboardManager.Update();
}
this._timerProvider.update(this.flushMicrotasks);
this.flushMicrotasks();
}

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;

10
Runtime/engine/DisplayMetrics.cs


using System;
using System.Runtime.InteropServices;
using UnityEngine;
static float _devicePixelRatio = 0;
static Func<float> _devicePixelRatioGetter;

}
if (_devicePixelRatioGetter != null) {
return _devicePixelRatioGetter();
}

displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")
) {
displayInstance.Call("getMetrics", metricsInstance);
return metricsInstance.Get<float>("density");
return metricsInstance.Get<float>("density");
}
}
}

#endif
}
}

32
Runtime/engine/WidgetCanvas.cs


protected override void updateSafeArea() {
this._padding = new WindowPadding(
Screen.safeArea.x,
Screen.safeArea.y,
Screen.safeArea.x,
Screen.safeArea.y,
Screen.width - Screen.safeArea.width,
Screen.height - Screen.safeArea.height);
}

if (this.displayMetricsChanged()) {
this._needsPaint = true;
}
if (evt.type == EventType.Repaint) {
if (!this._needsPaint) {
return;

get { return new GUIContent(this._widgetCanvas.gameObject.name); }
}
protected override double queryDevicePixelRatio() {
protected override float queryDevicePixelRatio() {
size = size * this._widgetCanvas.canvas.scaleFactor / (float)this._widgetCanvas.devicePixelRatio;
return new Vector2 (Mathf.Round (size.x), Mathf.Round (size.y));
size = size * this._widgetCanvas.canvas.scaleFactor / this._widgetCanvas.devicePixelRatio;
return new Vector2(Mathf.Round(size.x), Mathf.Round(size.y));
}
}

static Event _repaintEvent;
[SerializeField]
protected double devicePixelRatioOverride;
[SerializeField] protected float devicePixelRatioOverride;
WindowAdapter _windowAdapter;
Texture _texture;
Vector2 _lastMouseMove;

this._lastMouseMove = Input.mousePosition;
}
public double devicePixelRatio {
get { return this.devicePixelRatioOverride > 0 ? this.devicePixelRatioOverride : DisplayMetrics.devicePixelRatio; }
public float devicePixelRatio {
get {
return this.devicePixelRatioOverride > 0
? this.devicePixelRatioOverride
: DisplayMetrics.devicePixelRatio;
}
}
protected virtual Dictionary<string, WidgetBuilder> routes {

return (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) => builder(context)
pageBuilder: (BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) => builder(context)
);
}
}

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; }
}

2
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);

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();

5
Runtime/foundation/basic_types.cs


hashCode = (hashCode * 397) ^ item.GetHashCode();
}
}
public static bool equalsList<T>(this IList<T> it, IList<T> list) {
if (it == null && list == null) {
return true;

return true;
}
public static string toStringList<T>(this IList<T> it) {
return "{ " + string.Join(", ", it.Select(item => item.ToString())) + " }";
}

2
Runtime/foundation/debug.cs


// canvas.drawPath(path, paint);
}
public static void debugPaintPadding(Canvas canvas, Rect outerRect, Rect innerRect, double outlineWidth = 2.0) {
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));

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") + "%";
}
}

12
Runtime/gestures/constants.cs


namespace Unity.UIWidgets.gestures {
public static class Constants {
public const double kTouchSlop = 18.0;
public const float kTouchSlop = 18.0f;
public const double kDoubleTapTouchSlop = kTouchSlop;
public const float kDoubleTapTouchSlop = kTouchSlop;
public const double kDoubleTapSlop = 100.0;
public const float kDoubleTapSlop = 100.0f;
public const double kPanSlop = kTouchSlop * 2.0;
public const float kPanSlop = kTouchSlop * 2.0f;
public static readonly TimeSpan kPressTimeout = new TimeSpan(0, 0, 0, 0, 100);

public const double kMinFlingVelocity = 50.0;
public const float kMinFlingVelocity = 50.0f;
public const double kMaxFlingVelocity = 8000.0;
public const float kMaxFlingVelocity = 8000.0f;
}
}

2
Runtime/gestures/converter.cs


() => new _PointerState(position));
}
public static IEnumerable<PointerEvent> expand(IEnumerable<PointerData> data, double devicePixelRatio) {
public static IEnumerable<PointerEvent> expand(IEnumerable<PointerData> data, float devicePixelRatio) {
foreach (PointerData datum in data) {
var position = new Offset(datum.physicalX, datum.physicalY) / devicePixelRatio;
var timeStamp = datum.timeStamp;

8
Runtime/gestures/drag_details.cs


public DragUpdateDetails(
TimeSpan sourceTimeStamp,
Offset delta = null,
double? primaryDelta = null,
float? primaryDelta = null,
Offset globalPosition = null,
bool isScroll = false) {
this.sourceTimeStamp = sourceTimeStamp;

public readonly Offset delta;
public readonly double? primaryDelta;
public readonly float? primaryDelta;
public readonly Offset globalPosition;

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 + ")";

64
Runtime/gestures/lsq_resolver.cs


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

this._elements = Enumerable.Repeat(0.0, size).ToList();
this._elements = Enumerable.Repeat(0.0f, size).ToList();
_Vector(List<double> values, int offset, int length) {
_Vector(List<float> values, int offset, int length) {
internal static _Vector fromVOL(List<double> values, int offset, int length) {
internal static _Vector fromVOL(List<float> values, int offset, int length) {
return new _Vector(values, offset, length);
}

readonly List<double> _elements;
readonly List<float> _elements;
public double this[int i] {
public float this[int i] {
public static double operator *(_Vector a, _Vector b) {
double result = 0.0;
public static float operator *(_Vector a, _Vector b) {
float result = 0.0f;
for (int i = 0; i < a._length; i += 1) {
result += a[i] * b[i];
}

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

this._elements = Enumerable.Repeat(0.0, rows * cols).ToList();
this._elements = Enumerable.Repeat(0.0f, rows * cols).ToList();
readonly List<double> _elements;
readonly List<float> _elements;
public double this[int row, int col] {
public float this[int row, int col] {
get { return this._elements[row * this._columns + col]; }
set { this._elements[row * this._columns + col] = value; }
}

public class PolynomialFit {
public PolynomialFit(int degree) {
this.coefficients = Enumerable.Repeat(0.0, degree + 1).ToList();
this.coefficients = Enumerable.Repeat(0.0f, degree + 1).ToList();
public readonly List<double> coefficients;
public readonly List<float> coefficients;
public double confidence;
public float confidence;
public LeastSquaresSolver(List<double> x, List<double> y, List<double> w) {
public LeastSquaresSolver(List<float> x, List<float> y, List<float> w) {
D.assert(x != null && y != null && w != null);
D.assert(x.Count == y.Count);
D.assert(y.Count == w.Count);

}
public readonly List<double> x;
public readonly List<float> x;
public readonly List<double> y;
public readonly List<float> y;
public readonly List<double> w;
public readonly List<float> w;
/// Fits a polynomial of the given degree to the data points.
public PolynomialFit solve(int degree) {

}
for (int i = 0; i < j; i += 1) {
double dot = q.getRow(j) * q.getRow(i);
float dot = q.getRow(j) * q.getRow(i);
double norm = q.getRow(j).norm();
if (norm < 0.000001) {
float norm = q.getRow(j).norm();
if (norm < 0.000001f) {
double inverseNorm = 1.0 / norm;
float inverseNorm = 1.0f / norm;
r[j, i] = i < j ? 0.0 : q.getRow(j) * a.getRow(i);
r[j, i] = i < j ? 0.0f : q.getRow(j) * a.getRow(i);
}
}

// ...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;
}
}

43
Runtime/gestures/monodrag.cs


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

public GestureDragCancelCallback onCancel;
public double? minFlingDistance;
public float? minFlingDistance;
public double? minFlingVelocity;
public float? minFlingVelocity;
public double? maxFlingVelocity;
public float? maxFlingVelocity;
_DragState _state = _DragState.ready;
Offset _initialPosition;

protected abstract bool _isFlingGesture(VelocityEstimate estimate);
protected abstract Offset _getDeltaForDetails(Offset delta);
protected abstract double? _getPrimaryValueFromOffset(Offset value);
protected abstract float? _getPrimaryValueFromOffset(Offset value);
protected abstract bool _hasSufficientPendingDragDeltaToAccept { get; }
readonly Dictionary<int, VelocityTracker> _velocityTrackers = new Dictionary<int, VelocityTracker>();

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; }
return new Offset(0.0, delta.dy);
return new Offset(0.0f, delta.dy);
protected override double? _getPrimaryValueFromOffset(Offset value) {
protected override float? _getPrimaryValueFromOffset(Offset value) {
return value.dy;
}

}
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; }
return new Offset(delta.dx, 0.0);
return new Offset(delta.dx, 0.0f);
protected override double? _getPrimaryValueFromOffset(Offset value) {
protected override float? _getPrimaryValueFromOffset(Offset value) {
return value.dx;
}

}
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;
}

return delta;
}
protected override double? _getPrimaryValueFromOffset(Offset value) {
protected override float? _getPrimaryValueFromOffset(Offset value) {
return null;
}

2
Runtime/gestures/multitap.cs


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

2
Runtime/gestures/recognizer.cs


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

25
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> {

pixelsPerSecond: a.pixelsPerSecond + b.pixelsPerSecond);
}
public Velocity clampMagnitude(double minValue, double maxValue) {
public Velocity clampMagnitude(float minValue, float maxValue) {
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;

}
public VelocityEstimate getVelocityEstimate() {
List<double> x = new List<double>();
List<double> y = new List<double>();
List<double> w = new List<double>();
List<double> time = new List<double>();
List<float> x = new List<float>();
List<float> y = new List<float>();
List<float> w = new List<float>();
List<float> time = new List<float>();
int sampleCount = 0;
int index = this._index;

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

Offset position = sample.point;
x.Add(position.dx);
y.Add(position.dy);
w.Add(1.0);
w.Add(1.0f);
time.Add(-age);
index = (index == 0 ? _historySize : index) - 1;

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

62
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> {

D.assert(this.end != null);
Offset delta = this.end - this.begin;
double deltaX = delta.dx.abs();
double deltaY = delta.dy.abs();
double distanceFromAtoB = delta.distance;
float deltaX = delta.dx.abs();
float deltaY = delta.dy.abs();
float distanceFromAtoB = delta.distance;
double sweepAngle() {
return 2.0 * Math.Asin(distanceFromAtoB / (2.0 * this._radius));
float sweepAngle() {
return 2.0f * Mathf.Asin(distanceFromAtoB / (2.0f * this._radius));
this._radius = distanceFromAtoB * distanceFromAtoB / (c - this.begin).distance / 2.0;
this._radius = distanceFromAtoB * distanceFromAtoB / (c - this.begin).distance / 2.0f;
this._endAngle = 0.0;
this._endAngle = 0.0f;
this._beginAngle = Math.PI + sweepAngle() * (this.end.dy - this.begin.dy).sign();
this._endAngle = Math.PI;
this._beginAngle = (Mathf.PI + sweepAngle() * (this.end.dy - this.begin.dy).sign());
this._endAngle = Mathf.PI;
this._radius = distanceFromAtoB * distanceFromAtoB / (c - this.end).distance / 2.0;
this._radius = distanceFromAtoB * distanceFromAtoB / (c - this.end).distance / 2.0f;
this._beginAngle = -Math.PI / 2.0;
this._beginAngle = -Mathf.PI / 2.0f;
this._beginAngle = Math.PI / 2.0;
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;

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

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

}
}
double? _endAngle;
float? _endAngle;
public new Offset begin {
get { return base.begin; }

}
}
public override Offset lerp(double t) {
public override Offset lerp(float t) {
if (this._dirty) {
this._initialze();
}

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;
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);
}

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;
}

}
}
public override Rect lerp(double t) {
public override Rect lerp(float t) {
if (this._dirty) {
this._initialize();
}

}
}
public override Rect lerp(double t) {
public override Rect lerp(float t) {
if (this._dirty) {
this._initialize();
}

}
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);
center.dx - width / 2.0,
center.dy - height / 2.0,
(center.dx - width / 2.0f),
(center.dy - height / 2.0f),
width,
height);
}

20
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,

MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
shape = shape ?? new RoundedRectangleBorder();
padding = padding ?? EdgeInsets.zero;
constraints = constraints ?? new BoxConstraints(minWidth: 88.0, minHeight: 36.0);
constraints = constraints ?? new BoxConstraints(minWidth: 88.0f, minHeight: 36.0f);
TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.onPressed = onPressed;

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;

child: new Container(
padding: this.widget.padding,
child: new Center(
widthFactor: 1.0,
heightFactor: 1.0,
widthFactor: 1.0f,
heightFactor: 1.0f,
child: this.widget.child)
)
)

6
Runtime/material/button_bar.cs


public override Widget build(BuildContext context) {
ButtonThemeData buttonTheme = ButtonTheme.of(context);
double paddingUnit = buttonTheme.padding.horizontal / 4.0;
float paddingUnit = buttonTheme.padding.horizontal / 4.0f;
List<Widget> _children = new List<Widget>();
foreach (Widget _child in this.children) {
_children.Add(

case ButtonBarLayoutBehavior.padded:
return new Padding(
padding: EdgeInsets.symmetric(
vertical: 2.0 * paddingUnit,
vertical: 2.0f * paddingUnit,
horizontal: paddingUnit
),
child: child

padding: EdgeInsets.symmetric(horizontal: paddingUnit),
constraints: new BoxConstraints(minHeight: 52.0),
constraints: new BoxConstraints(minHeight: 52.0f),
alignment: Alignment.center,
child: child
);

66
Runtime/material/button_theme.cs


Key key = null,
ButtonTextTheme textTheme = ButtonTextTheme.normal,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded,
double minWidth = 88.0,
double height = 36.0,
float minWidth = 88.0f,
float height = 36.0f,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool alignedDropdown = false,

public class ButtonThemeData : Diagnosticable {
public ButtonThemeData(
ButtonTextTheme textTheme = ButtonTextTheme.normal,
double minWidth = 88.0,
double height = 36.0,
float minWidth = 88.0f,
float height = 36.0f,
EdgeInsets padding = null,
ShapeBorder shape = null,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded,

}
public readonly double minWidth;
public readonly float minWidth;
public readonly double height;
public readonly float height;
public readonly ButtonTextTheme textTheme;

switch (this.textTheme) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return EdgeInsets.symmetric(horizontal: 16.0);
return EdgeInsets.symmetric(horizontal: 16.0f);
return EdgeInsets.symmetric(horizontal: 24.0);
return EdgeInsets.symmetric(horizontal: 24.0f);
}
D.assert(false);

case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)));
borderRadius: BorderRadius.all(Radius.circular(2.0f)));
borderRadius: BorderRadius.all(Radius.circular(4.0)));
borderRadius: BorderRadius.all(Radius.circular(4.0f)));
}
return new RoundedRectangleBorder();

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;
}

}
if (button is MaterialButtonWithIconMixin) {
return EdgeInsets.fromLTRB(12.0, 0.0, 16.0, 0.0);
return EdgeInsets.fromLTRB(12.0f, 0.0f, 16.0f, 0.0f);
}
if (this._padding != null) {

switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return EdgeInsets.symmetric(horizontal: 16.0);
return EdgeInsets.symmetric(horizontal: 16.0f);
return EdgeInsets.symmetric(horizontal: 24.0);
return EdgeInsets.symmetric(horizontal: 24.0f);
}
D.assert(false);

public ButtonThemeData copyWith(
ButtonTextTheme? textTheme = null,
ButtonBarLayoutBehavior? layoutBehavior = null,
double? minWidth = null,
double? height = null,
float? minWidth = null,
float? height = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool? alignedDropdown = null,

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));

12
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,

this.shape = shape;
this.margin = margin ?? EdgeInsets.all(4.0);
this.margin = margin ?? EdgeInsets.all(4.0f);
this.clipBehavior = clipBehavior;
this.child = child;
}

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

public override Widget build(BuildContext context) {
return new Container(
margin: this.margin ?? EdgeInsets.all(4.0),
margin: this.margin ?? EdgeInsets.all(4.0f),
elevation: this.elevation ?? 1.0,
elevation: this.elevation ?? 1.0f,
borderRadius: BorderRadius.all(Radius.circular(4.0))
borderRadius: BorderRadius.all(Radius.circular(4.0f))
),
clipBehavior: this.clipBehavior,
child: this.child)

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),

12
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);

public static readonly EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0);
public static readonly EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0f);
public static readonly EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0);
public static readonly EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0f);
}
}

12
Runtime/material/divider.cs


public class Divider : StatelessWidget {
public Divider(
Key key = null,
double height = 16.0,
double indent = 0.0,
float height = 16.0f,
float indent = 0.0f,
Color color = null) : base(key: key) {
D.assert(height >= 0.0);
this.height = height;

public readonly double height;
public readonly float height;
public readonly double indent;
public readonly float indent;
public static BorderSide createBorderSide(BuildContext context, Color color = null, double width = 0.0) {
public static BorderSide createBorderSide(BuildContext context, Color color = null, float width = 0.0f) {
return new BorderSide(
color: color ?? Theme.of(context).dividerColor,
width: width);

height: this.height,
child: new Center(
child: new Container(
height: 0.0,
height: 0.0f,
margin: EdgeInsets.only(this.indent),
decoration: new BoxDecoration(
border: new Border(

19
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;

public readonly GlobalKey _drawerKey = GlobalKey.key();
double _width {
float _width {
get {
RenderBox box = (RenderBox) this._drawerKey.currentContext?.findRenderObject();
if (box != null) {

bool _previouslyOpened = false;
void _move(DragUpdateDetails details) {
double delta = (details.primaryDelta ?? 0) / this._width;
float delta = (details.primaryDelta ?? 0) / this._width;
switch (this.widget.alignment) {
case DrawerAlignment.start:
break;

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

}
public void open() {
this._controller.fling(velocity: 1.0);
this._controller.fling(velocity: 1.0f);
if (this.widget.drawerCallback != null) {
this.widget.drawerCallback(true);
}

this._controller.fling(velocity: -1.0);
this._controller.fling(velocity: -1.0f);
if (this.widget.drawerCallback != null) {
this.widget.drawerCallback(false);
}

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,

6
Runtime/material/drawer_header.cs


) : base(key: key) {
D.assert(child != null);
this.decoration = decoration;
this.margin = margin ?? EdgeInsets.only(bottom: 8.0);
this.padding = padding ?? EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0);
this.margin = margin ?? EdgeInsets.only(bottom: 8.0f);
this.padding = padding ?? EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 8.0f);
this.duration = duration ?? new TimeSpan(0, 0, 0, 0, 250);
this.curve = curve ?? Curves.fastOutSlowIn;
this.child = child;

public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
double statusBarHeight = MediaQuery.of(context).padding.top;
float statusBarHeight = MediaQuery.of(context).padding.top;
return new Container(
height: statusBarHeight + DrawerHeaderUtils._kDrawerHeaderHeight,
margin: this.margin,

15
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,
this.padding = padding ?? EdgeInsets.all(8.0);
this.padding = padding ?? EdgeInsets.all(8.0f);
public readonly double size;
public readonly float size;
public readonly ValueChanged<bool> onPressed;

public class _ExpandIconState : SingleTickerProviderStateMixin<ExpandIcon> {
AnimationController _controller;
Animation<double> _iconTurns;
Animation<float> _iconTurns;
static readonly Animatable<double> _iconTurnTween =
new DoubleTween(begin: 0.0, end: 0.5).chain(new CurveTween(curve: Curves.fastOutSlowIn));
static readonly Animatable<float> _iconTurnTween =
new FloatTween(begin: 0.0f, end: 0.5f).chain(new CurveTween(curve: Curves.fastOutSlowIn));
public override void initState() {
base.initState();

this._controller.setValue(Math.PI);
this._controller.setValue(Mathf.PI);
}
}

8
Runtime/material/expansion_panel.cs


margin: EdgeInsets.fromLTRB(0, 0, 8, 0),
child: new ExpandIcon(
isExpanded: this._isChildExpanded(index),
padding: EdgeInsets.all(16.0),
padding: EdgeInsets.all(16.0f),
onPressed: (bool isExpanded) => this._handlePressed(isExpanded, expandIndex)
)
)

children: new List<Widget> {
header,
new AnimatedCrossFade(
firstChild: new Container(height: 0.0),
firstChild: new Container(height: 0.0f),
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
firstCurve: new Interval(0.0f, 0.6f, curve: Curves.fastOutSlowIn),
secondCurve: new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn),
sizeCurve: Curves.fastOutSlowIn,
crossFadeState: this._isChildExpanded(index)
? CrossFadeState.showSecond

12
Runtime/material/expansion_tile.cs


}
public class _ExpansionTileState : SingleTickerProviderStateMixin<ExpansionTile> {
static readonly Animatable<double> _easeOutTween = new CurveTween(curve: Curves.easeOut);
static readonly Animatable<double> _easeInTween = new CurveTween(curve: Curves.easeIn);
static readonly Animatable<double> _halfTween = new DoubleTween(begin: 0.0, end: 0.5);
static readonly Animatable<float> _easeOutTween = new CurveTween(curve: Curves.easeOut);
static readonly Animatable<float> _easeInTween = new CurveTween(curve: Curves.easeIn);
static readonly Animatable<float> _halfTween = new FloatTween(begin: 0.0f, end: 0.5f);
readonly ColorTween _borderColorTween = new ColorTween();
readonly ColorTween _headerColorTween = new ColorTween();

AnimationController _controller;
Animation<double> _iconTurns;
Animation<double> _heightFactor;
Animation<float> _iconTurns;
Animation<float> _heightFactor;
Animation<Color> _borderColor;
Animation<Color> _headerColor;
Animation<Color> _iconColor;

: (bool) PageStorage.of(this.context)?.readState(this.context);
if (this._isExpanded) {
this._controller.setValue(1.0);
this._controller.setValue(1.0f);
}
}

2
Runtime/material/flat_button.cs


mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
icon,
new SizedBox(width: 8.0),
new SizedBox(width: 8.0f),
label
}
)) {

12
Runtime/material/grid_tile.cs


};
if (this.header != null) {
children.Add(new Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
top: 0.0f,
left: 0.0f,
right: 0.0f,
left: 0.0,
bottom: 0.0,
right: 0.0,
left: 0.0f,
bottom: 0.0f,
right: 0.0f,
child: this.footer));
}

12
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;
double iconSize = 24.0,
float iconSize = 24.0f,
EdgeInsets padding = null,
Alignment alignment = null,
Widget icon = null,

D.assert(icon != null);
this.iconSize = iconSize;
this.padding = padding ?? EdgeInsets.all(8.0);
this.padding = padding ?? EdgeInsets.all(8.0f);
this.alignment = alignment ?? Alignment.center;
this.icon = icon;
this.color = color;

this.tooltip = tooltip;
}
public readonly double iconSize;
public readonly float iconSize;
public readonly EdgeInsets padding;

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

12
Runtime/material/ink_decoration.cs


EdgeInsets padding = null,
Color color = null,
Decoration decoration = null,
double? width = null,
double? height = null,
float? width = null,
float? height = null,
Widget child = null) : base(key: key) {
D.assert(padding == null || padding.isNonNegative);
D.assert(decoration == null || decoration.debugAssertIsValid());

Alignment alignment = null,
Rect centerSlice = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
double? width = null,
double? height = null,
float? width = null,
float? height = null,
Widget child = null
) {
D.assert(padding == null || padding.isNonNegative);

public readonly Decoration decoration;
public readonly double? width;
public readonly float? width;
public readonly double? height;
public readonly float? height;
public EdgeInsets _paddingIncludingDecoration {
get {

26
Runtime/material/ink_ripple.cs


RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
float? radius = null,
VoidCallback onRemoved = null
) {
D.assert(controller != null);

RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
float? radius = null,
VoidCallback onRemoved = null
) : base(
controller: controller,

vsync: controller.vsync);
this._radiusController.addListener(controller.markNeedsPaint);
this._radiusController.forward();
this._radius = this._radiusController.drive(new DoubleTween(
begin: this._targetRadius * 0.30,
end: this._targetRadius + 5.0
this._radius = this._radiusController.drive(new FloatTween(
begin: this._targetRadius * 0.30f,
end: this._targetRadius + 5.0f
).chain(_easeCurveTween)
);

readonly ShapeBorder _customBorder;
readonly double _targetRadius;
readonly float _targetRadius;
Animation<double> _radius;
Animation<float> _radius;
AnimationController _radiusController;
Animation<int> _fadeIn;

public static InteractiveInkFeatureFactory splashFactory = new _InkRippleFactory();
static readonly Animatable<double> _easeCurveTween = new CurveTween(curve: Curves.ease);
static readonly Animatable<float> _easeCurveTween = new CurveTween(curve: Curves.ease);
static readonly Animatable<double> _fadeOutIntervalTween =
new CurveTween(curve: new Interval(InkRippleUtils._kFadeOutIntervalStart, 1.0));
static readonly Animatable<float> _fadeOutIntervalTween =
new CurveTween(curve: new Interval(InkRippleUtils._kFadeOutIntervalStart, 1.0f));
this._fadeOutController.animateTo(1.0, duration: InkRippleUtils._kFadeOutDuration);
this._fadeOutController.animateTo(1.0f, duration: InkRippleUtils._kFadeOutDuration);
double fadeOutValue = 1.0 - this._fadeInController.value;
float fadeOutValue = 1.0f - this._fadeInController.value;
this._fadeOutController.animateTo(1.0, duration: InkRippleUtils._kCancelDuration);
this._fadeOutController.animateTo(1.0f, duration: InkRippleUtils._kCancelDuration);
}
}

10
Runtime/material/ink_splash.cs


RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
float? radius = null,
VoidCallback onRemoved = null
) {
D.assert(controller != null);

RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
float? radius = null,
VoidCallback onRemoved = null
) : base(
controller: controller,

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 ShapeBorder _customBorder;
readonly double _targetRadius;
readonly float _targetRadius;
Animation<double> _radius;
Animation<float> _radius;
AnimationController _radiusController;
Animation<int> _alpha;

8
Runtime/material/ink_well.cs


RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
float? radius = null,
VoidCallback onRemoved = null);
}

ValueChanged<bool> onHighlightChanged = null,
bool containedInkWell = false,
BoxShape highlightShape = BoxShape.circle,
double? radius = null,
float? radius = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
Color highlightColor = null,

public readonly BoxShape highlightShape;
public readonly double? radius;
public readonly float? radius;
public readonly BorderRadius borderRadius;

Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
double? radius = null,
float? radius = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null
) : base(

110
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 {

Color color = this._textColor(theme, tileTheme, style.color);
return this._isDenseLayout(tileTheme)
? style.copyWith(fontSize: 13.0, color: color)
? style.copyWith(fontSize: 13.0f, color: color)
: style.copyWith(color: color);
}

return this._isDenseLayout(tileTheme)
? style.copyWith(color: color, fontSize: 12.0)
? style.copyWith(color: color, fontSize: 12.0f)
: style.copyWith(color: color);
}

child: this.trailing);
}
EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0);
EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0f);
EdgeInsets resolvedContentPadding =
this.contentPadding ?? tileTheme?.contentPadding ?? _defaultContentPadding;

this._subtitleBaselineType = subtitleBaselineType;
}
const double _minLeadingWidth = 40.0;
const float _minLeadingWidth = 40.0f;
const double _horizontalTitleGap = 16.0;
const float _horizontalTitleGap = 16.0f;
const double _minVerticalPadding = 4.0;
const float _minVerticalPadding = 4.0f;
public readonly Dictionary<_ListTileSlot, RenderBox> slotToChild = new Dictionary<_ListTileSlot, RenderBox>();
public readonly Dictionary<RenderBox, _ListTileSlot> childToSlot = new Dictionary<RenderBox, _ListTileSlot>();

get { return false; }
}
static double _minWidth(RenderBox box, double height) {
return box == null ? 0.0 : box.getMinIntrinsicWidth(height);
static float _minWidth(RenderBox box, float height) {
return box == null ? 0.0f : box.getMinIntrinsicWidth(height);
static double _maxWidth(RenderBox box, double height) {
return box == null ? 0.0 : box.getMaxIntrinsicWidth(height);
static float _maxWidth(RenderBox box, float height) {
return box == null ? 0.0f : box.getMaxIntrinsicWidth(height);
protected override double computeMinIntrinsicWidth(double height) {
double leadingWidth = this.leading != null
? Math.Max(this.leading.getMinIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
: 0.0;
return leadingWidth + Math.Max(_minWidth(this.title, height), _minWidth(this.subtitle, height)) +
protected override float computeMinIntrinsicWidth(float height) {
float leadingWidth = this.leading != null
? Mathf.Max(this.leading.getMinIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
: 0.0f;
return leadingWidth + Mathf.Max(_minWidth(this.title, height), _minWidth(this.subtitle, height)) +
protected override double computeMaxIntrinsicWidth(double height) {
double leadingWidth = this.leading != null
? Math.Max(this.leading.getMaxIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
: 0.0;
return leadingWidth + Math.Max(_maxWidth(this.title, height), _maxWidth(this.subtitle, height)) +
protected override float computeMaxIntrinsicWidth(float height) {
float leadingWidth = this.leading != null
? Mathf.Max(this.leading.getMaxIntrinsicWidth(height), _minLeadingWidth) + _horizontalTitleGap
: 0.0f;
return leadingWidth + Mathf.Max(_maxWidth(this.title, height), _maxWidth(this.subtitle, height)) +
double _defaultTileHeight {
float _defaultTileHeight {
get {
bool hasSubtitle = this.subtitle != null;
bool isTwoLine = !this.isThreeLine && hasSubtitle;

return this.isDense ? 48.0 : 56.0;
return this.isDense ? 48.0f : 56.0f;
return this.isDense ? 64.0 : 72.0;
return this.isDense ? 64.0f : 72.0f;
return this.isDense ? 76.0 : 88.0;
return this.isDense ? 76.0f : 88.0f;
protected override double computeMinIntrinsicHeight(double width) {
return Math.Max(
protected override float computeMinIntrinsicHeight(float width) {
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 double computeMaxIntrinsicHeight(double width) {
protected override float computeMaxIntrinsicHeight(float width) {
protected override double? computeDistanceToActualBaseline(TextBaseline baseline) {
protected override float? computeDistanceToActualBaseline(TextBaseline 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) {

bool isOneLine = !this.isThreeLine && !hasSubtitle;
BoxConstraints looseConstraints = this.constraints.loosen();
double tileWidth = looseConstraints.maxWidth;
float tileWidth = looseConstraints.maxWidth;
double titleStart = hasLeading ? Math.Max(_minLeadingWidth, leadingSize.width) + _horizontalTitleGap : 0.0;
float titleStart = hasLeading
? Mathf.Max(_minLeadingWidth, leadingSize.width) + _horizontalTitleGap
: 0.0f;
width: tileWidth - titleStart - (hasTrailing ? trailingSize.width + _horizontalTitleGap : 0.0));
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;
double tileHeight = 0.0;
double titleY = 0.0;
double subtitleY = 0.0;
float tileHeight = 0.0f;
float titleY = 0.0f;
float subtitleY = 0.0f;
tileHeight = 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;
tileHeight = titleSize.height + subtitleSize.height + 2.0 * _minVerticalPadding;
tileHeight = titleSize.height + subtitleSize.height + 2.0f * _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.0, leadingY));
_positionBox(this.leading, new Offset(0.0f, leadingY));
}
_positionBox(this.title, new Offset(titleStart, titleY));

24
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)));

}
public const double defaultSplashRadius = 35.0;
public const float defaultSplashRadius = 35.0f;
}

ShapeBorder end = null) : base(begin: begin, end: end) {
}
public override ShapeBorder lerp(double t) {
public override ShapeBorder lerp(float t) {
return ShapeBorder.lerp(this.begin, this.end, t);
}
}

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,

20
Runtime/material/material_button.cs


Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,
double? elevation = null,
double? highlightElevation = null,
double? disabledElevation = null,
float? elevation = null,
float? highlightElevation = null,
float? disabledElevation = null,
double? minWidth = null,
double? height = null,
float? minWidth = null,
float? height = null,
Widget child = null
) : base(key: key) {
this.onPressed = onPressed;

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;

public readonly MaterialTapTargetSize? materialTapTargetSize;
public readonly double? minWidth;
public readonly float? minWidth;
public readonly double? height;
public readonly float? height;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);

38
Runtime/material/mergeable_material.cs


public class MaterialGap : MergeableMaterialItem {
public MaterialGap(
LocalKey key = null,
double size = 16.0) : base(key: key) {
float size = 16.0f) : base(key: key) {
public readonly double size;
public readonly float size;
public override string ToString() {
return "MaterialGap(key: " + this.key + ", child: " + this.size + ")";

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() {

CurvedAnimation startAnimation = null,
CurvedAnimation endAnimation = null,
CurvedAnimation gapAnimation = null,
double gapStart = 0.0) {
float gapStart = 0.0f) {
this.controller = controller;
this.startAnimation = startAnimation;
this.endAnimation = endAnimation;

public readonly CurvedAnimation gapAnimation;
public double gapStart;
public float gapStart;
}

for (int i = 0; i < this._children.Count; i++) {
if (this._children[i] is MaterialGap) {
this._initGap((MaterialGap) this._children[i]);
this._animationTuples[this._children[i].key].controller.setValue(1.0);
this._animationTuples[this._children[i].key].controller.setValue(1.0f);
}
}

if (newLength > 0) {
if (oldLength > 1 || oldLength == 1 && this._children[startOld] is MaterialSlice) {
if (newLength == 1 && newChildren[startNew] is MaterialGap) {
double gapSizeSum = 0.0;
float gapSizeSum = 0.0f;
while (startOld < j) {
if (this._children[startOld] is MaterialGap) {

this._animationTuples[newChildren[startNew].key].controller.forward();
}
else {
double gapSize = this._getGapSize(startOld);
float gapSize = this._getGapSize(startOld);
this._removeChild(startOld);

j += (newLength - 1);
double gapSizeSum = 0.0;
float gapSizeSum = 0.0f;
for (int k = startNew; k < i; k++) {
if (newChildren[k] is MaterialGap) {

MaterialGap gap = (MaterialGap) newChildren[k];
this._animationTuples[gap.key].gapStart = gapSize * gap.size / gapSizeSum;
this._animationTuples[gap.key].controller.setValue(0.0);
this._animationTuples[gap.key].controller.setValue(0.0f);
this._animationTuples[gap.key].controller.forward();
}
}

}
else {
if (oldLength > 1 || oldLength == 1 && this._children[startOld] is MaterialSlice) {
double gapSizeSum = 0.0;
float gapSizeSum = 0.0f;
while (startOld < j) {
if (this._children[startOld] is MaterialGap) {

if (gapSizeSum != 0.0) {
MaterialGap gap = new MaterialGap(key: new UniqueKey(), size: gapSizeSum);
this._insertChild(startOld, gap);
this._animationTuples[gap.key].gapStart = 0.0;
this._animationTuples[gap.key].controller.setValue(1.0);
this._animationTuples[gap.key].gapStart = 0.0f;
this._animationTuples[gap.key].controller.setValue(1.0f);
this._animationTuples[gap.key].controller.reverse();
j++;
}

this._animationTuples[gap.key].gapStart = 0.0;
this._animationTuples[gap.key].gapStart = 0.0f;
this._animationTuples[gap.key].controller.reverse();
}
}

}
double _getGapSize(int index) {
float _getGapSize(int index) {
return MathUtils.lerpDouble(this._animationTuples[gap.key].gapStart,
return MathUtils.lerpFloat(this._animationTuples[gap.key].gapStart,
gap.size,
this._animationTuples[gap.key].gapAnimation.value);
}

slices = new List<Widget>();
widgets.Add(
new SizedBox(
width: this.widget.mainAxis == Axis.horizontal ? this._getGapSize(i) : (double?) null,
height: this.widget.mainAxis == Axis.vertical ? this._getGapSize(i) : (double?) null)
width: this.widget.mainAxis == Axis.horizontal ? this._getGapSize(i) : (float?) null,
height: this.widget.mainAxis == Axis.vertical ? this._getGapSize(i) : (float?) null)
);
}
else {

Border border;
BorderSide divider = Divider.createBorderSide(
context,
width: 0.5
width: 0.5f
);
if (i == 0) {

26
Runtime/material/raised_button.cs


Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,
double? elevation = null,
double? highlightElevation = null,
double? disabledElevation = null,
float? elevation = null,
float? highlightElevation = null,
float? disabledElevation = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
Clip? clipBehavior = Clip.none,

Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,
double? elevation = null,
double? highlightElevation = null,
double? disabledElevation = null,
float? elevation = null,
float? highlightElevation = null,
float? disabledElevation = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
Clip? clipBehavior = null,

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));

Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,
double? elevation = null,
double? highlightElevation = null,
double? disabledElevation = null,
float? elevation = null,
float? highlightElevation = null,
float? disabledElevation = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
Clip? clipBehavior = Clip.none,

mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
icon,
new SizedBox(width: 8.0),
new SizedBox(width: 8.0f),
label
}
)) {

4
Runtime/material/scrollbar.cs


public Color _themeColor;
public AnimationController _fadeoutAnimationController;
public Animation<double> _FadeoutOpacityAnimation;
public Animation<float> _FadeoutOpacityAnimation;
public Timer _fadeoutTimer;
public override void initState() {

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();
}

60
Runtime/material/shadows.cs


new Dictionary<int, List<BoxShadow>> {
{
1, new List<BoxShadow> {
new BoxShadow(offset: new Offset(0.0, 2.0), blurRadius: 1.0, spreadRadius: -1.0,
new BoxShadow(offset: new Offset(0.0f, 2.0f), blurRadius: 1.0f, spreadRadius: -1.0f,
new BoxShadow(offset: new Offset(0.0, 1.0), blurRadius: 1.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 1.0f), blurRadius: 1.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 1.0), blurRadius: 3.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 1.0f), blurRadius: 3.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 3.0), blurRadius: 1.0, spreadRadius: -2.0,
new BoxShadow(offset: new Offset(0.0f, 3.0f), blurRadius: 1.0f, spreadRadius: -2.0f,
new BoxShadow(offset: new Offset(0.0, 2.0), blurRadius: 2.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 2.0f), blurRadius: 2.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 1.0), blurRadius: 5.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 1.0f), blurRadius: 5.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 3.0), blurRadius: 3.0, spreadRadius: -2.0,
new BoxShadow(offset: new Offset(0.0f, 3.0f), blurRadius: 3.0f, spreadRadius: -2.0f,
new BoxShadow(offset: new Offset(0.0, 3.0), blurRadius: 4.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 3.0f), blurRadius: 4.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 1.0), blurRadius: 8.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 1.0f), blurRadius: 8.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 2.0), blurRadius: 4.0, spreadRadius: -1.0,
new BoxShadow(offset: new Offset(0.0f, 2.0f), blurRadius: 4.0f, spreadRadius: -1.0f,
new BoxShadow(offset: new Offset(0.0, 4.0), blurRadius: 5.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 4.0f), blurRadius: 5.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 1.0), blurRadius: 10.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 1.0f), blurRadius: 10.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 3.0), blurRadius: 5.0, spreadRadius: -1.0,
new BoxShadow(offset: new Offset(0.0f, 3.0f), blurRadius: 5.0f, spreadRadius: -1.0f,
new BoxShadow(offset: new Offset(0.0, 6.0), blurRadius: 10.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 6.0f), blurRadius: 10.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 1.0), blurRadius: 18.0, spreadRadius: 0.0,
new BoxShadow(offset: new Offset(0.0f, 1.0f), blurRadius: 18.0f, spreadRadius: 0.0f,
new BoxShadow(offset: new Offset(0.0, 5.0), blurRadius: 5.0, spreadRadius: -3.0,
new BoxShadow(offset: new Offset(0.0f, 5.0f), blurRadius: 5.0f, spreadRadius: -3.0f,
new BoxShadow(offset: new Offset(0.0, 8.0), blurRadius: 10.0, spreadRadius: 1.0,
new BoxShadow(offset: new Offset(0.0f, 8.0f), blurRadius: 10.0f, spreadRadius: 1.0f,
new BoxShadow(offset: new Offset(0.0, 3.0), blurRadius: 14.0, spreadRadius: 2.0,
new BoxShadow(offset: new Offset(0.0f, 3.0f), blurRadius: 14.0f, spreadRadius: 2.0f,
new BoxShadow(offset: new Offset(0.0, 5.0), blurRadius: 6.0, spreadRadius: -3.0,
new BoxShadow(offset: new Offset(0.0f, 5.0f), blurRadius: 6.0f, spreadRadius: -3.0f,
new BoxShadow(offset: new Offset(0.0, 9.0), blurRadius: 12.0, spreadRadius: 1.0,
new BoxShadow(offset: new Offset(0.0f, 9.0f), blurRadius: 12.0f, spreadRadius: 1.0f,
new BoxShadow(offset: new Offset(0.0, 3.0), blurRadius: 16.0, spreadRadius: 2.0,
new BoxShadow(offset: new Offset(0.0f, 3.0f), blurRadius: 16.0f, spreadRadius: 2.0f,
new BoxShadow(offset: new Offset(0.0, 7.0), blurRadius: 8.0, spreadRadius: -4.0,
new BoxShadow(offset: new Offset(0.0f, 7.0f), blurRadius: 8.0f, spreadRadius: -4.0f,
new BoxShadow(offset: new Offset(0.0, 12.0), blurRadius: 17.0, spreadRadius: 2.0,
new BoxShadow(offset: new Offset(0.0f, 12.0f), blurRadius: 17.0f, spreadRadius: 2.0f,
new BoxShadow(offset: new Offset(0.0, 5.0), blurRadius: 22.0, spreadRadius: 4.0,
new BoxShadow(offset: new Offset(0.0f, 5.0f), blurRadius: 22.0f, spreadRadius: 4.0f,
new BoxShadow(offset: new Offset(0.0, 8.0), blurRadius: 10.0, spreadRadius: -5.0,
new BoxShadow(offset: new Offset(0.0f, 8.0f), blurRadius: 10.0f, spreadRadius: -5.0f,
new BoxShadow(offset: new Offset(0.0, 16.0), blurRadius: 24.0, spreadRadius: 2.0,
new BoxShadow(offset: new Offset(0.0f, 16.0f), blurRadius: 24.0f, spreadRadius: 2.0f,
new BoxShadow(offset: new Offset(0.0, 6.0), blurRadius: 30.0, spreadRadius: 5.0,
new BoxShadow(offset: new Offset(0.0f, 6.0f), blurRadius: 30.0f, spreadRadius: 5.0f,
new BoxShadow(offset: new Offset(0.0, 11.0), blurRadius: 15.0, spreadRadius: -7.0,
new BoxShadow(offset: new Offset(0.0f, 11.0f), blurRadius: 15.0f, spreadRadius: -7.0f,
new BoxShadow(offset: new Offset(0.0, 24.0), blurRadius: 38.0, spreadRadius: 3.0,
new BoxShadow(offset: new Offset(0.0f, 24.0f), blurRadius: 38.0f, spreadRadius: 3.0f,
new BoxShadow(offset: new Offset(0.0, 9.0), blurRadius: 46.0, spreadRadius: 8.0,
new BoxShadow(offset: new Offset(0.0f, 9.0f), blurRadius: 46.0f, spreadRadius: 8.0f,
color: _kAmbientShadowOpacity)
}
}

20
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 {

return new Container(
color: new Color(0xFFEFEFEF),
height: 44.0, child: new Row(mainAxisSize: MainAxisSize.min, children: items));
height: 44.0f, child: new Row(mainAxisSize: MainAxisSize.min, children: items));
}
}

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;

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

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

Widget child = null
) : base(key: key) {
this.onPressed = onPressed;
this.padding = padding ?? EdgeInsets.all(8.0);
this.padding = padding ?? EdgeInsets.all(8.0f);
this.backgroundColor = backgroundColor ?? new Color(0);
this.child = child;
}

6
Runtime/material/text_theme.cs


public TextTheme apply(
string fontFamily = null,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
float fontSizeFactor = 1.0f,
float fontSizeDelta = 0.0f,
Color displayColor = null,
Color bodyColor = null,
TextDecoration decoration = null,

);
}
public static TextTheme lerp(TextTheme a, TextTheme b, double t) {
public static TextTheme lerp(TextTheme a, TextTheme b, float t) {
D.assert(a != null);
D.assert(b != null);
return new TextTheme(

2
Runtime/material/theme.cs


) : base(begin: begin, end: end) {
}
public override ThemeData lerp(double t) {
public override ThemeData lerp(float t) {
return ThemeData.lerp(this.begin, this.end, t);
}
}

10
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;
}

public static ThemeData lerp(ThemeData a, ThemeData b, double t) {
public static ThemeData lerp(ThemeData a, ThemeData b, float t) {
D.assert(a != null);
D.assert(b != null);
return raw(

40
Runtime/material/tooltip.cs


public Tooltip(
Key key = null,
string message = null,
double height = 32.0,
float height = 32.0f,
double verticalOffset = 24.0,
float verticalOffset = 24.0f,
bool preferBelow = true,
Widget child = null
) : base(key: key) {

this.padding = padding ?? EdgeInsets.symmetric(horizontal: 16.0);
this.padding = padding ?? EdgeInsets.symmetric(horizontal: 16.0f);
this.verticalOffset = verticalOffset;
this.preferBelow = preferBelow;
this.child = child;

public readonly string message;
public readonly double height;
public readonly float height;
public readonly double verticalOffset;
public readonly float verticalOffset;
public readonly bool preferBelow;

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;

public _TooltipOverlay(
Key key = null,
string message = null,
double? height = null,
float? height = null,
Animation<double> animation = null,
Animation<float> animation = null,
double? verticalOffset = null,
float? verticalOffset = null,
bool? preferBelow = null
) : base(key: key) {
this.message = message;

public readonly string message;
public readonly double? height;
public readonly float? height;
public readonly Animation<double> animation;
public readonly Animation<float> animation;
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,
constraints: new BoxConstraints(minHeight: this.height ?? 0.0),
constraints: new BoxConstraints(minHeight: this.height ?? 0.0f),
borderRadius: BorderRadius.circular(2.0)),
borderRadius: BorderRadius.circular(2.0f)),
widthFactor: 1.0,
heightFactor: 1.0,
widthFactor: 1.0f,
heightFactor: 1.0f,
child: new Text(this.message, style: darkTheme.textTheme.body1)
)
)

188
Runtime/material/typography.cs


tall: tall ?? this.tall);
}
public static Typography lerp(Typography a, Typography b, double t) {
public static Typography lerp(Typography a, Typography b, float t) {
return new Typography(
black: TextTheme.lerp(a.black, b.black, t),
white: TextTheme.lerp(a.white, b.white, t),

public static readonly TextTheme englishLike2014 = new TextTheme(
display4: new TextStyle(debugLabel: "englishLike display4 2014", inherit: false, fontSize: 112.0,
display4: new TextStyle(debugLabel: "englishLike display4 2014", inherit: false, fontSize: 112.0f,
display3: new TextStyle(debugLabel: "englishLike display3 2014", inherit: false, fontSize: 56.0,
display3: new TextStyle(debugLabel: "englishLike display3 2014", inherit: false, fontSize: 56.0f,
display2: new TextStyle(debugLabel: "englishLike display2 2014", inherit: false, fontSize: 45.0,
display2: new TextStyle(debugLabel: "englishLike display2 2014", inherit: false, fontSize: 45.0f,
display1: new TextStyle(debugLabel: "englishLike display1 2014", inherit: false, fontSize: 34.0,
display1: new TextStyle(debugLabel: "englishLike display1 2014", inherit: false, fontSize: 34.0f,
headline: new TextStyle(debugLabel: "englishLike headline 2014", inherit: false, fontSize: 24.0,
headline: new TextStyle(debugLabel: "englishLike headline 2014", inherit: false, fontSize: 24.0f,
title: new TextStyle(debugLabel: "englishLike title 2014", inherit: false, fontSize: 20.0,
title: new TextStyle(debugLabel: "englishLike title 2014", inherit: false, fontSize: 20.0f,
subhead: new TextStyle(debugLabel: "englishLike subhead 2014", inherit: false, fontSize: 16.0,
subhead: new TextStyle(debugLabel: "englishLike subhead 2014", inherit: false, fontSize: 16.0f,
body2: new TextStyle(debugLabel: "englishLike body2 2014", inherit: false, fontSize: 14.0,
body2: new TextStyle(debugLabel: "englishLike body2 2014", inherit: false, fontSize: 14.0f,
body1: new TextStyle(debugLabel: "englishLike body1 2014", inherit: false, fontSize: 14.0,
body1: new TextStyle(debugLabel: "englishLike body1 2014", inherit: false, fontSize: 14.0f,
caption: new TextStyle(debugLabel: "englishLike caption 2014", inherit: false, fontSize: 12.0,
caption: new TextStyle(debugLabel: "englishLike caption 2014", inherit: false, fontSize: 12.0f,
button: new TextStyle(debugLabel: "englishLike button 2014", inherit: false, fontSize: 14.0,
button: new TextStyle(debugLabel: "englishLike button 2014", inherit: false, fontSize: 14.0f,
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1),
overline: new TextStyle(debugLabel: "englishLike overline 2014", inherit: false, fontSize: 10.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5)
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2014", inherit: false, fontSize: 14.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1f),
overline: new TextStyle(debugLabel: "englishLike overline 2014", inherit: false, fontSize: 10.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5f)
display4: new TextStyle(debugLabel: "englishLike display4 2018", fontSize: 96.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -1.5),
display3: new TextStyle(debugLabel: "englishLike display3 2018", fontSize: 60.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -0.5),
display2: new TextStyle(debugLabel: "englishLike display2 2018", fontSize: 48.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0),
display1: new TextStyle(debugLabel: "englishLike display1 2018", fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25),
headline: new TextStyle(debugLabel: "englishLike headline 2018", fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0),
title: new TextStyle(debugLabel: "englishLike title 2018", fontSize: 20.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15),
subhead: new TextStyle(debugLabel: "englishLike subhead 2018", fontSize: 16.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15),
body2: new TextStyle(debugLabel: "englishLike body2 2018", fontSize: 14.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25),
body1: new TextStyle(debugLabel: "englishLike body1 2018", fontSize: 16.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.5),
button: new TextStyle(debugLabel: "englishLike button 2018", fontSize: 14.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.75),
caption: new TextStyle(debugLabel: "englishLike caption 2018", fontSize: 12.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.4),
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2018", fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1),
overline: new TextStyle(debugLabel: "englishLike overline 2018", fontSize: 10.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5)
display4: new TextStyle(debugLabel: "englishLike display4 2018", fontSize: 96.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -1.5f),
display3: new TextStyle(debugLabel: "englishLike display3 2018", fontSize: 60.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -0.5f),
display2: new TextStyle(debugLabel: "englishLike display2 2018", fontSize: 48.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0f),
display1: new TextStyle(debugLabel: "englishLike display1 2018", fontSize: 34.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25f),
headline: new TextStyle(debugLabel: "englishLike headline 2018", fontSize: 24.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0f),
title: new TextStyle(debugLabel: "englishLike title 2018", fontSize: 20.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15f),
subhead: new TextStyle(debugLabel: "englishLike subhead 2018", fontSize: 16.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15f),
body2: new TextStyle(debugLabel: "englishLike body2 2018", fontSize: 14.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25f),
body1: new TextStyle(debugLabel: "englishLike body1 2018", fontSize: 16.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.5f),
button: new TextStyle(debugLabel: "englishLike button 2018", fontSize: 14.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.75f),
caption: new TextStyle(debugLabel: "englishLike caption 2018", fontSize: 12.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.4f),
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2018", fontSize: 14.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1f),
overline: new TextStyle(debugLabel: "englishLike overline 2018", fontSize: 10.0f,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5f)
display4: new TextStyle(debugLabel: "dense display4 2014", inherit: false, fontSize: 112.0,
display4: new TextStyle(debugLabel: "dense display4 2014", inherit: false, fontSize: 112.0f,
display3: new TextStyle(debugLabel: "dense display3 2014", inherit: false, fontSize: 56.0,
display3: new TextStyle(debugLabel: "dense display3 2014", inherit: false, fontSize: 56.0f,
display2: new TextStyle(debugLabel: "dense display2 2014", inherit: false, fontSize: 45.0,
display2: new TextStyle(debugLabel: "dense display2 2014", inherit: false, fontSize: 45.0f,
display1: new TextStyle(debugLabel: "dense display1 2014", inherit: false, fontSize: 34.0,
display1: new TextStyle(debugLabel: "dense display1 2014", inherit: false, fontSize: 34.0f,
headline: new TextStyle(debugLabel: "dense headline 2014", inherit: false, fontSize: 24.0,
headline: new TextStyle(debugLabel: "dense headline 2014", inherit: false, fontSize: 24.0f,
title: new TextStyle(debugLabel: "dense title 2014", inherit: false, fontSize: 21.0,
title: new TextStyle(debugLabel: "dense title 2014", inherit: false, fontSize: 21.0f,
subhead: new TextStyle(debugLabel: "dense subhead 2014", inherit: false, fontSize: 17.0,
subhead: new TextStyle(debugLabel: "dense subhead 2014", inherit: false, fontSize: 17.0f,
body2: new TextStyle(debugLabel: "dense body2 2014", inherit: false, fontSize: 15.0,
body2: new TextStyle(debugLabel: "dense body2 2014", inherit: false, fontSize: 15.0f,
body1: new TextStyle(debugLabel: "dense body1 2014", inherit: false, fontSize: 15.0,
body1: new TextStyle(debugLabel: "dense body1 2014", inherit: false, fontSize: 15.0f,
caption: new TextStyle(debugLabel: "dense caption 2014", inherit: false, fontSize: 13.0,
caption: new TextStyle(debugLabel: "dense caption 2014", inherit: false, fontSize: 13.0f,
button: new TextStyle(debugLabel: "dense button 2014", inherit: false, fontSize: 15.0,
button: new TextStyle(debugLabel: "dense button 2014", inherit: false, fontSize: 15.0f,
subtitle: new TextStyle(debugLabel: "dense subtitle 2014", inherit: false, fontSize: 15.0,
subtitle: new TextStyle(debugLabel: "dense subtitle 2014", inherit: false, fontSize: 15.0f,
overline: new TextStyle(debugLabel: "dense overline 2014", inherit: false, fontSize: 11.0,
overline: new TextStyle(debugLabel: "dense overline 2014", inherit: false, fontSize: 11.0f,
display4: new TextStyle(debugLabel: "dense display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400,
display4: new TextStyle(debugLabel: "dense display4 2018", fontSize: 96.0f, fontWeight: FontWeight.w400,
display3: new TextStyle(debugLabel: "dense display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400,
display3: new TextStyle(debugLabel: "dense display3 2018", fontSize: 60.0f, fontWeight: FontWeight.w400,
display2: new TextStyle(debugLabel: "dense display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400,
display2: new TextStyle(debugLabel: "dense display2 2018", fontSize: 48.0f, fontWeight: FontWeight.w400,
display1: new TextStyle(debugLabel: "dense display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400,
display1: new TextStyle(debugLabel: "dense display1 2018", fontSize: 34.0f, fontWeight: FontWeight.w400,
headline: new TextStyle(debugLabel: "dense headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400,
headline: new TextStyle(debugLabel: "dense headline 2018", fontSize: 24.0f, fontWeight: FontWeight.w400,
title: new TextStyle(debugLabel: "dense title 2018", fontSize: 21.0, fontWeight: FontWeight.w400,
title: new TextStyle(debugLabel: "dense title 2018", fontSize: 21.0f, fontWeight: FontWeight.w400,
subhead: new TextStyle(debugLabel: "dense subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
subhead: new TextStyle(debugLabel: "dense subhead 2018", fontSize: 17.0f, fontWeight: FontWeight.w400,
body2: new TextStyle(debugLabel: "dense body2 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
body2: new TextStyle(debugLabel: "dense body2 2018", fontSize: 17.0f, fontWeight: FontWeight.w400,
body1: new TextStyle(debugLabel: "dense body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
body1: new TextStyle(debugLabel: "dense body1 2018", fontSize: 15.0f, fontWeight: FontWeight.w400,
caption: new TextStyle(debugLabel: "dense caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400,
caption: new TextStyle(debugLabel: "dense caption 2018", fontSize: 13.0f, fontWeight: FontWeight.w400,
button: new TextStyle(debugLabel: "dense button 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
button: new TextStyle(debugLabel: "dense button 2018", fontSize: 15.0f, fontWeight: FontWeight.w400,
subtitle: new TextStyle(debugLabel: "dense subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
subtitle: new TextStyle(debugLabel: "dense subtitle 2018", fontSize: 15.0f, fontWeight: FontWeight.w400,
overline: new TextStyle(debugLabel: "dense overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400,
overline: new TextStyle(debugLabel: "dense overline 2018", fontSize: 11.0f, fontWeight: FontWeight.w400,
display4: new TextStyle(debugLabel: "tall display4 2014", inherit: false, fontSize: 112.0,
display4: new TextStyle(debugLabel: "tall display4 2014", inherit: false, fontSize: 112.0f,
display3: new TextStyle(debugLabel: "tall display3 2014", inherit: false, fontSize: 56.0,
display3: new TextStyle(debugLabel: "tall display3 2014", inherit: false, fontSize: 56.0f,
display2: new TextStyle(debugLabel: "tall display2 2014", inherit: false, fontSize: 45.0,
display2: new TextStyle(debugLabel: "tall display2 2014", inherit: false, fontSize: 45.0f,
display1: new TextStyle(debugLabel: "tall display1 2014", inherit: false, fontSize: 34.0,
display1: new TextStyle(debugLabel: "tall display1 2014", inherit: false, fontSize: 34.0f,
headline: new TextStyle(debugLabel: "tall headline 2014", inherit: false, fontSize: 24.0,
headline: new TextStyle(debugLabel: "tall headline 2014", inherit: false, fontSize: 24.0f,
title: new TextStyle(debugLabel: "tall title 2014", inherit: false, fontSize: 21.0,
title: new TextStyle(debugLabel: "tall title 2014", inherit: false, fontSize: 21.0f,
subhead: new TextStyle(debugLabel: "tall subhead 2014", inherit: false, fontSize: 17.0,
subhead: new TextStyle(debugLabel: "tall subhead 2014", inherit: false, fontSize: 17.0f,
body2: new TextStyle(debugLabel: "tall body2 2014", inherit: false, fontSize: 15.0,
body2: new TextStyle(debugLabel: "tall body2 2014", inherit: false, fontSize: 15.0f,
body1: new TextStyle(debugLabel: "tall body1 2014", inherit: false, fontSize: 15.0,
body1: new TextStyle(debugLabel: "tall body1 2014", inherit: false, fontSize: 15.0f,
caption: new TextStyle(debugLabel: "tall caption 2014", inherit: false, fontSize: 13.0,
caption: new TextStyle(debugLabel: "tall caption 2014", inherit: false, fontSize: 13.0f,
button: new TextStyle(debugLabel: "tall button 2014", inherit: false, fontSize: 15.0,
button: new TextStyle(debugLabel: "tall button 2014", inherit: false, fontSize: 15.0f,
subtitle: new TextStyle(debugLabel: "tall subtitle 2014", inherit: false, fontSize: 15.0,
subtitle: new TextStyle(debugLabel: "tall subtitle 2014", inherit: false, fontSize: 15.0f,
overline: new TextStyle(debugLabel: "tall overline 2014", inherit: false, fontSize: 11.0,
overline: new TextStyle(debugLabel: "tall overline 2014", inherit: false, fontSize: 11.0f,
display4: new TextStyle(debugLabel: "tall display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400,
display4: new TextStyle(debugLabel: "tall display4 2018", fontSize: 96.0f, fontWeight: FontWeight.w400,
display3: new TextStyle(debugLabel: "tall display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400,
display3: new TextStyle(debugLabel: "tall display3 2018", fontSize: 60.0f, fontWeight: FontWeight.w400,
display2: new TextStyle(debugLabel: "tall display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400,
display2: new TextStyle(debugLabel: "tall display2 2018", fontSize: 48.0f, fontWeight: FontWeight.w400,
display1: new TextStyle(debugLabel: "tall display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400,
display1: new TextStyle(debugLabel: "tall display1 2018", fontSize: 34.0f, fontWeight: FontWeight.w400,
headline: new TextStyle(debugLabel: "tall headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400,
headline: new TextStyle(debugLabel: "tall headline 2018", fontSize: 24.0f, fontWeight: FontWeight.w400,
title: new TextStyle(debugLabel: "tall title 2018", fontSize: 21.0, fontWeight: FontWeight.w700,
title: new TextStyle(debugLabel: "tall title 2018", fontSize: 21.0f, fontWeight: FontWeight.w700,
subhead: new TextStyle(debugLabel: "tall subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
subhead: new TextStyle(debugLabel: "tall subhead 2018", fontSize: 17.0f, fontWeight: FontWeight.w400,
body2: new TextStyle(debugLabel: "tall body2 2018", fontSize: 17.0, fontWeight: FontWeight.w700,
body2: new TextStyle(debugLabel: "tall body2 2018", fontSize: 17.0f, fontWeight: FontWeight.w700,
body1: new TextStyle(debugLabel: "tall body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
body1: new TextStyle(debugLabel: "tall body1 2018", fontSize: 15.0f, fontWeight: FontWeight.w400,
button: new TextStyle(debugLabel: "tall button 2018", fontSize: 15.0, fontWeight: FontWeight.w700,
button: new TextStyle(debugLabel: "tall button 2018", fontSize: 15.0f, fontWeight: FontWeight.w700,
caption: new TextStyle(debugLabel: "tall caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400,
caption: new TextStyle(debugLabel: "tall caption 2018", fontSize: 13.0f, fontWeight: FontWeight.w400,
subtitle: new TextStyle(debugLabel: "tall subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
subtitle: new TextStyle(debugLabel: "tall subtitle 2018", fontSize: 15.0f, fontWeight: FontWeight.w400,
overline: new TextStyle(debugLabel: "tall overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400,
overline: new TextStyle(debugLabel: "tall overline 2018", fontSize: 11.0f, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic)
);
}

58
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 {

public static readonly Dictionary<MaterialType, BorderRadius> kMaterialEdges =
new Dictionary<MaterialType, BorderRadius> {
{MaterialType.canvas, null},
{MaterialType.card, BorderRadius.circular(2.0)},
{MaterialType.card, BorderRadius.circular(2.0f)},
{MaterialType.button, BorderRadius.circular(2.0)},
{MaterialType.button, BorderRadius.circular(2.0f)},
{MaterialType.transparency, null}
};
}

public static readonly TimeSpan _kSplashFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
public const double _kSplashInitialSize = 0.0;
public const float _kSplashInitialSize = 0.0f;
public const double _kSplashConfirmedVelocity = 1.0;
public const float _kSplashConfirmedVelocity = 1.0f;
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell,
RectCallback rectCallback) {

return null;
}
public static double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
Offset position) {
if (containedInkWell) {
Size size = rectCallback != null ? rectCallback().size : referenceBox.size;

return Material.defaultSplashRadius;
}
static double _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();
static float _getSplashRadiusForPositionInSize(Size bounds, Offset position) {
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 readonly TimeSpan _kFadeOutDuration = new TimeSpan(0, 0, 0, 0, 375);
public static readonly TimeSpan _kCancelDuration = new TimeSpan(0, 0, 0, 0, 75);
public const double _kFadeOutIntervalStart = 225.0 / 375.0;
public const float _kFadeOutIntervalStart = 225.0f / 375.0f;
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell,
RectCallback rectCallback) {

return null;
}
public static double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
double d1 = size.bottomRight(Offset.zero).distance;
double d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).distance;
return 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 readonly TimeSpan _kScrollbarTimeToFade = TimeSpan.FromMilliseconds(600);
public const double _kScrollbarThickness = 6.0;
public const float _kScrollbarThickness = 6.0f;
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;

}
public static class ExpansionPanelUtils {
public const double _kPanelHeaderCollapsedHeight = 48.0;
public const double _kPanelHeaderExpandedHeight = 64.0;
public const float _kPanelHeaderCollapsedHeight = 48.0f;
public const float _kPanelHeaderExpandedHeight = 64.0f;
public const double _kMinButtonSize = 48.0;
public const float _kMinButtonSize = 48.0f;
public const double _kDrawerHeaderHeight = 160.0 + 1.0;
public const float _kDrawerHeaderHeight = 160.0f + 1.0f;
public const double _kWidth = 304.0;
public const double _kEdgeDragWidth = 20.0;
public const double _kMinFlingVelocity = 365.0;
public const float _kWidth = 304.0f;
public const float _kEdgeDragWidth = 20.0f;
public const float _kMinFlingVelocity = 365.0f;
public static readonly TimeSpan _kBaseSettleDuration = new TimeSpan(0, 0, 0, 0, 246);
}

72
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;
float centerX = other.dx / 2.0f;
float centerY = other.dy / 2.0f;
double centerX = other.width / 2.0;
double centerY = other.height / 2.0;
float centerX = other.width / 2.0f;
float centerY = other.height / 2.0f;
double halfWidth = rect.width / 2.0;
double halfHeight = rect.height / 2.0;
float halfWidth = rect.width / 2.0f;
float halfHeight = rect.height / 2.0f;
return new Offset(
rect.left + halfWidth + this.x * halfWidth,
rect.top + halfHeight + this.y * halfHeight

public Rect inscribe(Size size, Rect rect) {
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;
return Rect.fromLTWH(
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";
}

51
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> {

get { return EdgeInsets.all(this.side.width); }
}
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
return new BeveledRectangleBorder(
side: this.side.scale(t),
borderRadius: this.borderRadius * t

public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is BeveledRectangleBorder border) {
return new BeveledRectangleBorder(
side: BorderSide.lerp(border.side, this.side, t),

public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
if (b is BeveledRectangleBorder border) {
return new BeveledRectangleBorder(
side: BorderSide.lerp(this.side, border.side, t),

return base.lerpTo(b, t);
}

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, Math.Min(centerLeft.dy, rrect.top + tlRadiusY)),
new Offset(Math.Min(centerTop.dx, rrect.left + tlRadiusX), rrect.top),
new Offset(Math.Max(centerTop.dx, rrect.right - trRadiusX), rrect.top),
new Offset(rrect.right, Math.Min(centerRight.dy, rrect.top + trRadiusY)),
new Offset(rrect.right, Math.Max(centerRight.dy, rrect.bottom - brRadiusY)),
new Offset(Math.Max(centerBottom.dx, rrect.right - brRadiusX), rrect.bottom),
new Offset(Math.Min(centerBottom.dx, rrect.left + blRadiusX), rrect.bottom),
new Offset(rrect.left, 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();

if (rect.isEmpty) {
return;
}
switch (this.side.style) {
case BorderStyle.none:
break;

if (ReferenceEquals(null, other)) {
return false;
}
return Equals(this.side, other.side) && Equals(this.borderRadius, other.borderRadius);
}

}
return this.Equals((BeveledRectangleBorder) obj);
}

return $"{this.GetType()}({this.side}, {this.borderRadius})";
}
}
}
}

22
Runtime/painting/border_radius.cs


return only(radius, radius, radius, radius);
}
public static BorderRadius all(double radius) {
public static BorderRadius all(float radius) {
public static BorderRadius circular(double radius) {
public static BorderRadius circular(float radius) {
return all(Radius.circular(radius));
}

public static BorderRadius vertical(double? top = null, double? bottom = null) {
public static BorderRadius vertical(float? top = null, float? bottom = null) {
return only(top, top, bottom, bottom);
}

public static BorderRadius horizontal(double? left = null, double? right = null) {
public static BorderRadius horizontal(float? left = null, float? right = null) {
return only(left, right, right, left);
}

}
public static BorderRadius only(
double? topLeft = null, double? topRight = null,
double? bottomRight = null, double? bottomLeft = null) {
float? topLeft = null, float? topRight = null,
float? bottomRight = null, float? bottomLeft = null) {
var tlRadius = topLeft != null ? Radius.circular(topLeft.Value) : null;
var trRadius = topRight != null ? Radius.circular(topRight.Value) : null;
var brRadius = bottomRight != null ? Radius.circular(bottomRight.Value) : null;

);
}
public static BorderRadius operator *(BorderRadius it, double other) {
public static BorderRadius operator *(BorderRadius it, float other) {
return only(
topLeft: it.topLeft * other,
topRight: it.topRight * other,

}
public static BorderRadius operator /(BorderRadius it, double other) {
public static BorderRadius operator /(BorderRadius it, float other) {
return only(
topLeft: it.topLeft / other,
topRight: it.topRight / other,

}
public static BorderRadius operator %(BorderRadius it, double other) {
public static BorderRadius operator %(BorderRadius it, float other) {
return only(
topLeft: it.topLeft % other,
topRight: it.topRight % other,

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

}
if (b == null) {
return a * (1.0 - t);
return a * (1.0f - t);
}
return only(

60
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 class BorderSide : IEquatable<BorderSide> {
public BorderSide(
Color color = null,
double width = 1.0,
float width = 1.0f,
BorderStyle style = BorderStyle.solid
) {
this.color = color ?? Color.black;

}
public readonly Color color;
public readonly double width;
public readonly float width;
public static readonly BorderSide none = new BorderSide(width: 0.0);
public static readonly BorderSide none = new BorderSide(width: 0.0f);
double? width = null,
float? width = null,
BorderStyle? style = null
) {
D.assert(width == null || width >= 0.0);

);
}
public BorderSide scale(double t) {
public BorderSide scale(float t) {
width: 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
};
}

return a.style == b.style && a.color == b.color;
}
public static BorderSide lerp(BorderSide a, BorderSide b, double t) {
public static BorderSide lerp(BorderSide a, BorderSide b, float t) {
if (t == 0.0) {
if (t == 0.0f) {
if (t == 1.0) {
if (t == 1.0f) {
double width = MathUtils.lerpDouble(a.width, b.width, t);
float width = MathUtils.lerpFloat(a.width, b.width, t);
if (width < 0.0) {
return none;
}

new _CompoundBorder(new List<ShapeBorder> {other, it});
}
public abstract ShapeBorder scale(double t);
public abstract ShapeBorder scale(float t);
public virtual ShapeBorder lerpFrom(ShapeBorder a, double t) {
public virtual ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a == null) {
return this.scale(t);
}

public virtual ShapeBorder lerpTo(ShapeBorder b, double t) {
public virtual ShapeBorder lerpTo(ShapeBorder b, float t) {
return this.scale(1.0 - t);
return this.scale(1.0f - t);
public static ShapeBorder lerp(ShapeBorder a, ShapeBorder b, double t) {
public static ShapeBorder lerp(ShapeBorder a, ShapeBorder b, float t) {
ShapeBorder result = null;
if (b != null) {
result = b.lerpFrom(a, t);

return new _CompoundBorder(mergedBorders);
}
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
public new static _CompoundBorder lerp(ShapeBorder a, ShapeBorder b, double t) {
public new static _CompoundBorder lerp(ShapeBorder a, ShapeBorder b, float t) {
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;

}
if (localA != null) {
results.Add(localA.scale(1.0 - t));
results.Add(localA.scale(1.0f - t));
}
}

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 {

24
Runtime/painting/box_border.cs


public static Border all(
Color color = null,
double width = 1.0,
float width = 1.0f,
BorderStyle style = BorderStyle.solid
) {
BorderSide side = new BorderSide(color: color, width: width, style: style);

return null;
}
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
return new Border(
top: this.top.scale(t),
right: this.right.scale(t),

}
public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is Border border) {
return lerp(border, this, t);
}

public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
if (b is Border border) {
return lerp(this, border, t);
}

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

}
if (b == null) {
return (Border) a.scale(1.0 - t);
return (Border) a.scale(1.0f - t);
}
return new Border(

};
RRect outer = borderRadius.toRRect(rect);
double width = side.width;
float width = side.width;
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;
double width = side.width;
float width = side.width;
canvas.drawRect(rect.deflate(width / 2.0), paint);
canvas.drawRect(rect.deflate(width / 2.0f), paint);
}
public bool Equals(Border other) {

22
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> {

get { return this.border?.dimensions; }
}
public BoxDecoration scale(double factor) {
public BoxDecoration scale(float factor) {
return new BoxDecoration(
color: Color.lerp(null, this.color, factor),
image: this.image,

get { return this.boxShadow != null; }
}
public override Decoration lerpFrom(Decoration a, double t) {
public override Decoration lerpFrom(Decoration a, float t) {
if (a == null) {
return this.scale(t);
}

return base.lerpFrom(a, t);
}
public override Decoration lerpTo(Decoration b, double t) {
public override Decoration lerpTo(Decoration b, float t) {
return this.scale(1.0 - t);
return this.scale(1.0f - t);
}
if (b is BoxDecoration boxDecoration) {

return base.lerpTo(b, t);
}
public static BoxDecoration lerp(BoxDecoration a, BoxDecoration b, double t) {
public static BoxDecoration lerp(BoxDecoration a, BoxDecoration b, float t) {
if (a == null && b == null) {
return null;
}

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

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:

10
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(outputSize.height * aspectRatio, outputSize.height);
destinationSize = new Size(outputSize.height * aspectRatio,
outputSize.height);
}
if (destinationSize.width > outputSize.width) {

32
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> {

double blurRadius = 0.0,
double spreadRadius = 0.0
float blurRadius = 0.0f,
float spreadRadius = 0.0f
) {
this.color = color ?? Color.black;
this.offset = offset ?? Offset.zero;

public readonly Color color;
public readonly Offset offset;
public readonly double blurRadius;
public readonly double spreadRadius;
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); }
}

};
}
public BoxShadow scale(double factor) {
public BoxShadow scale(float factor) {
return new BoxShadow(
color: this.color,
offset: this.offset * factor,

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

}
if (b == null) {
return a.scale(1.0 - t);
return a.scale(1.0f - t);
blurRadius: MathUtils.lerpDouble(a.blurRadius, b.blurRadius, t),
spreadRadius: MathUtils.lerpDouble(a.spreadRadius, b.spreadRadius, t)
blurRadius: MathUtils.lerpFloat(a.blurRadius, b.blurRadius, t),
spreadRadius: MathUtils.lerpFloat(a.spreadRadius, b.spreadRadius, t)
public static List<BoxShadow> lerpList(List<BoxShadow> a, List<BoxShadow> b, double t) {
public static List<BoxShadow> lerpList(List<BoxShadow> a, List<BoxShadow> b, float t) {
if (a == null && b == null) {
return null;
}

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

15
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> {

get { return EdgeInsets.all(this.side.width); }
}
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is CircleBorder border) {
return new CircleBorder(side: BorderSide.lerp(border.side, this.side, t));
}

public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
if (b is CircleBorder border) {
return new CircleBorder(side: BorderSide.lerp(this.side, border.side, t));
}

var path = new Path();
path.addOval(Rect.fromCircle(
center: rect.center,
radius: 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;
}

path.addOval(Rect.fromCircle(
center: rect.center,
radius: rect.shortestSide / 2.0
radius: rect.shortestSide / 2.0f
));
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;
}
}

15
Runtime/painting/decoration.cs


get { return false; }
}
public virtual Decoration lerpFrom(Decoration a, double t) {
public virtual Decoration lerpFrom(Decoration a, float t) {
public virtual Decoration lerpTo(Decoration b, double t) {
public virtual Decoration lerpTo(Decoration b, float t) {
public static Decoration lerp(Decoration a, Decoration b, double t) {
public static Decoration lerp(Decoration a, Decoration b, float t) {
?? (t < 0.5 ? (a.lerpTo(null, t * 2.0) ?? a) : (b.lerpFrom(null, (t - 0.5) * 2.0) ?? b));
?? (t < 0.5 ? (a.lerpTo(null, t * 2.0f) ?? a) : (b.lerpFrom(null, (t - 0.5f) * 2.0f) ?? b));
}
public virtual bool hitTest(Size size, Offset position) {

public virtual void Dispose() {
}
}
}
}

14
Runtime/painting/decoration_image.cs


Canvas canvas = null,
Rect rect = null,
Image image = null,
double scale = 1.0,
float scale = 1.0f,
ColorFilter colorFilter = null,
BoxFit? fit = null,
Alignment alignment = null,

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;
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;

int startY = 0;
int stopX = 0;
int stopY = 0;
double strideX = fundamentalRect.width;
double strideY = fundamentalRect.height;
float strideX = fundamentalRect.width;
float strideY = fundamentalRect.height;
if (repeat == ImageRepeat.repeat || repeat == ImageRepeat.repeatX) {
startX = ((outputRect.left - fundamentalRect.left) / strideX).floor();

52
Runtime/painting/edge_insets.cs


namespace Unity.UIWidgets.painting {
public class EdgeInsets : IEquatable<EdgeInsets> {
EdgeInsets(double left, double top, double right, double bottom) {
EdgeInsets(float left, float top, float right, float bottom) {
this.left = left;
this.right = right;
this.top = top;

public readonly double left;
public readonly double right;
public readonly double top;
public readonly double bottom;
public readonly float left;
public readonly float right;
public readonly float top;
public readonly float bottom;
public bool isNonNegative {
get {

}
}
public double horizontal {
public float horizontal {
public double vertical {
public float vertical {
public double along(Axis axis) {
public float along(Axis axis) {
switch (axis) {
case Axis.horizontal:
return this.horizontal;

return new Size(size.width - this.horizontal, size.height - this.vertical);
}
public static EdgeInsets fromLTRB(double left, double top, double right, double bottom) {
public static EdgeInsets fromLTRB(float left, float top, float right, float bottom) {
public static EdgeInsets all(double value) {
public static EdgeInsets all(float value) {
public static EdgeInsets only(double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0) {
public static EdgeInsets only(float left = 0.0f, float top = 0.0f, float right = 0.0f, float bottom = 0.0f) {
public static EdgeInsets symmetric(double vertical = 0.0, double horizontal = 0.0) {
public static EdgeInsets symmetric(float vertical = 0.0f, float horizontal = 0.0f) {
public static EdgeInsets fromWindowPadding(WindowPadding padding, double devicePixelRatio) {
public static EdgeInsets fromWindowPadding(WindowPadding padding, float devicePixelRatio) {
return new EdgeInsets(
left: padding.left / devicePixelRatio,
top: padding.top / devicePixelRatio,

);
}
public static EdgeInsets operator *(EdgeInsets a, double b) {
public static EdgeInsets operator *(EdgeInsets a, float b) {
return fromLTRB(
a.left * b,
a.top * b,

}
public static EdgeInsets operator /(EdgeInsets a, double b) {
public static EdgeInsets operator /(EdgeInsets a, float b) {
return fromLTRB(
a.left / b,
a.top / b,

}
public static EdgeInsets operator %(EdgeInsets a, double b) {
public static EdgeInsets operator %(EdgeInsets a, float b) {
return fromLTRB(
a.left % b,
a.top % b,

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

}
if (b == null) {
return a * (1.0 - t);
return a * (1.0f - t);
MathUtils.lerpDouble(a.left, b.left, t),
MathUtils.lerpDouble(a.top, b.top, t),
MathUtils.lerpDouble(a.right, b.right, t),
MathUtils.lerpDouble(a.bottom, b.bottom, t)
MathUtils.lerpFloat(a.left, b.left, t),
MathUtils.lerpFloat(a.top, b.top, t),
MathUtils.lerpFloat(a.right, b.right, t),
MathUtils.lerpFloat(a.bottom, b.bottom, t)
double? left = null,
double? top = null,
double? right = null,
double? bottom = null
float? left = null,
float? top = null,
float? right = null,
float? bottom = null
) {
return only(
left: left ?? this.left,

21
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(margin, 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;
}
}

129
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() {
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);
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);
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 LinearGradient.lerp((LinearGradient) a, this, t);
}

protected override Gradient lerpTo(Gradient b, double t) {
protected override Gradient lerpTo(Gradient b, float t) {
public static LinearGradient lerp(LinearGradient a, LinearGradient b, double t) {
public static LinearGradient lerp(LinearGradient a, LinearGradient b, float t) {
return (LinearGradient) a.scale(1.0 - t);
return (LinearGradient) a.scale(1.0f - t);
}
_ColorsAndStops interpolated =

if (ReferenceEquals(null, other)) {
return false;
}
return
this.colors.equalsList(other.colors) &&
this.stops.equalsList(other.stops) &&

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((LinearGradient) obj);
}

}
public class RadialGradient : Gradient, IEquatable<RadialGradient> {
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 RadialGradient.lerp((RadialGradient) a, this, t);
}

protected override Gradient lerpTo(Gradient b, double t) {
protected override Gradient lerpTo(Gradient b, float t) {
public static RadialGradient lerp(RadialGradient a, RadialGradient b, double t) {
public static RadialGradient lerp(RadialGradient a, RadialGradient b, float t) {
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

if (ReferenceEquals(null, other)) {
return false;
}
return
this.colors.equalsList(other.colors) &&
this.stops.equalsList(other.stops) &&

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((RadialGradient) obj);
}

$"{this.colors.toStringList()}, {this.stops.toStringList()}, {this.tileMode})";
}
}
public class SweepGradient : Gradient, IEquatable<SweepGradient> {
public class SweepGradient : Gradient, IEquatable<SweepGradient> {
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 double endAngle;
public readonly float startAngle;
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 SweepGradient.lerp((SweepGradient) a, this, t);
}

protected override Gradient lerpTo(Gradient b, double t) {
protected override Gradient lerpTo(Gradient b, float t) {
return SweepGradient.lerp(this, (SweepGradient) b, t);
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) {
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

if (ReferenceEquals(null, other)) {
return false;
}
return
this.colors.equalsList(other.colors) &&
this.stops.equalsList(other.stops) &&

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((SweepGradient) obj);
}

26
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;

public AssetBundleImageKey(
AssetBundle bundle,
string name,
double scale
float scale
) {
D.assert(name != null);
D.assert(scale >= 0.0);

public readonly string name;
public readonly double scale;
public readonly float scale;
public bool Equals(AssetBundleImageKey other) {
if (ReferenceEquals(null, other)) {

public class NetworkImage : ImageProvider<NetworkImage>, IEquatable<NetworkImage> {
public NetworkImage(string url,
double scale = 1.0,
float scale = 1.0f,
IDictionary<string, string> headers = null) {
D.assert(url != null);
this.url = url;

public readonly string url;
public readonly double scale;
public readonly float scale;
public readonly IDictionary<string, string> headers;

}
public class FileImage : ImageProvider<FileImage>, IEquatable<FileImage> {
public FileImage(string file, double scale = 1.0) {
public FileImage(string file, float scale = 1.0f) {
D.assert(file != null);
this.file = file;
this.scale = scale;

public readonly double scale;
public readonly float scale;
protected override IPromise<FileImage> obtainKey(ImageConfiguration configuration) {
return Promise<FileImage>.Resolved(this);

}
public class MemoryImage : ImageProvider<MemoryImage>, IEquatable<MemoryImage> {
public MemoryImage(byte[] bytes, double scale = 1.0) {
public MemoryImage(byte[] bytes, float scale = 1.0f) {
D.assert(bytes != null);
this.bytes = bytes;
this.scale = scale;

public readonly double scale;
public readonly float scale;
protected override IPromise<MemoryImage> obtainKey(ImageConfiguration configuration) {
return Promise<MemoryImage>.Resolved(this);

public class ExactAssetImage : AssetBundleImageProvider, IEquatable<ExactAssetImage> {
public ExactAssetImage(
string assetName,
double scale = 1.0,
float scale = 1.0f,
AssetBundle bundle = null
) {
D.assert(assetName != null);

public readonly string assetName;
public readonly double scale;
public readonly float scale;
public readonly AssetBundle bundle;

4
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);

yield return new AssetBundleImageKey(
bundle,
this.assetName,
scale: 1.0
scale: 1.0f
);
}

8
Runtime/painting/image_stream.cs


namespace Unity.UIWidgets.painting {
public class ImageInfo : IEquatable<ImageInfo> {
public ImageInfo(Image image, double scale = 1.0) {
public ImageInfo(Image image, float scale = 1.0f) {
D.assert(image != null);
this.image = image;

public readonly Image image;
public readonly double scale;
public readonly float scale;
public bool Equals(ImageInfo other) {
if (ReferenceEquals(null, other)) {

public class MultiFrameImageStreamCompleter : ImageStreamCompleter {
public MultiFrameImageStreamCompleter(
IPromise<Codec> codec,
double scale,
float scale,
InformationCollector informationCollector = null
) {
D.assert(codec != null);

}
Codec _codec;
readonly double _scale;
readonly float _scale;
readonly InformationCollector _informationCollector;
FrameInfo _nextFrame;

7
Runtime/painting/matrix_utils.cs


return result;
}
public static Matrix4x4 toMatrix4x4(this Matrix3 matrix3) {
var matrix = Matrix4x4.identity;

matrix[3, 0] = matrix3[6]; // row 2
matrix[3, 1] = matrix3[7];
matrix[3, 3] = matrix3[8];

}
public class TransformProperty : DiagnosticsProperty<Matrix3> {

40
Runtime/painting/rounded_rectangle_border.cs


get { return EdgeInsets.all(this.side.width); }
}
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
return new RoundedRectangleBorder(
side: this.side.scale(t),
borderRadius: this.borderRadius * t

public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is RoundedRectangleBorder border) {
return new RoundedRectangleBorder(
side: BorderSide.lerp(border.side, this.side, t),

return new _RoundedRectangleToCircleBorder(
side: BorderSide.lerp(circleBorder.side, this.side, t),
borderRadius: this.borderRadius,
circleness: 1.0 - t
circleness: 1.0f - t
);
}

public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
if (b is RoundedRectangleBorder border) {
return new RoundedRectangleBorder(
side: BorderSide.lerp(this.side, border.side, t),

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

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

public readonly BorderRadius borderRadius;
public readonly double circleness;
public readonly float circleness;
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
return new _RoundedRectangleToCircleBorder(
side: this.side.scale(t),
borderRadius: this.borderRadius * t,

public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is RoundedRectangleBorder rectBorder) {
return new _RoundedRectangleToCircleBorder(
side: BorderSide.lerp(rectBorder.side, this.side, t),

return new _RoundedRectangleToCircleBorder(
side: BorderSide.lerp(circleBorder.side, this.side, t),
borderRadius: this.borderRadius,
circleness: this.circleness + (1.0 - this.circleness) * (1.0 - t)
circleness: this.circleness + (1.0f - this.circleness) * (1.0f - t)
);
}

borderRadius: BorderRadius.lerp(border.borderRadius, this.borderRadius, t),
circleness: MathUtils.lerpDouble(border.circleness, this.circleness, t)
circleness: MathUtils.lerpFloat(border.circleness, this.circleness, t)
);
}

public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
circleness: this.circleness * (1.0 - t)
circleness: this.circleness * (1.0f - t)
);
}

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

borderRadius: BorderRadius.lerp(this.borderRadius, border.borderRadius, t),
circleness: MathUtils.lerpDouble(this.circleness, border.circleness, t)
circleness: MathUtils.lerpFloat(this.circleness, border.circleness, t)
);
}

}
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;
return Rect.fromLTRB(
rect.left,
rect.top + delta,

}
else {
double delta = this.circleness * (rect.width - rect.height) / 2.0;
float delta = this.circleness * (rect.width - rect.height) / 2.0f;
return Rect.fromLTRB(
rect.left + delta,
rect.top,

BorderRadius _adjustBorderRadius(Rect rect) {
BorderRadius resolvedRadius = this.borderRadius;
if (this.circleness == 0.0) {
if (this.circleness == 0.0f) {
return BorderRadius.lerp(resolvedRadius, BorderRadius.circular(rect.shortestSide / 2.0), this.circleness);
return BorderRadius.lerp(resolvedRadius, BorderRadius.circular(rect.shortestSide / 2.0f), this.circleness);
}
public override Path getInnerPath(Rect rect) {

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

40
Runtime/painting/shape_decoration.cs


if (source.border != null) {
D.assert(source.border.isUniform);
shape = new CircleBorder(side: source.border.top);
} else {
}
else {
break;
case BoxShape.rectangle:
if (source.borderRadius != null) {

borderRadius: source.borderRadius
);
} else {
}
else {
return new ShapeDecoration(
color: source.color,
image: source.image,

get { return this.shadows != null; }
}
public override Decoration lerpFrom(Decoration a, double t) {
public override Decoration lerpFrom(Decoration a, float t) {
} else if (a == null || a is ShapeDecoration) {
}
else if (a == null || a is ShapeDecoration) {
public override Decoration lerpTo(Decoration b, double t) {
public override Decoration lerpTo(Decoration b, float t) {
return ShapeDecoration.lerp(this, ShapeDecoration.fromBoxDecoration(decoration), t);
} else if (b == null || b is ShapeDecoration) {
return ShapeDecoration.lerp(this, fromBoxDecoration(decoration), t);
}
else if (b == null || b is ShapeDecoration) {
public static ShapeDecoration lerp(ShapeDecoration a, ShapeDecoration b, double t) {
public static ShapeDecoration lerp(ShapeDecoration a, ShapeDecoration b, float t) {
if (t == 1.0) {
return b;
}

if (ReferenceEquals(null, other)) {
return false;
}
return Equals(this.color, other.color) && Equals(this.image, other.image) &&
Equals(this.gradient, other.gradient) && Equals(this.shadows, other.shadows) &&
Equals(this.shape, other.shape);

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((ShapeDecoration) obj);
}

this._interiorPaint.color = this._decoration.color;
}
}
if (this._decoration.shadows != null) {
if (this._shadowCount == null) {
this._shadowCount = this._decoration.shadows.Count;

this._shadowPaints[index] = this._decoration.shadows[index].toPaint();
}
}
for (int index = 0; index < this._shadowCount; index += 1) {
BoxShadow shadow = this._decoration.shadows[index];
this._shadowPaths[index] = this._decoration.shape.getOuterPath(

if (this._decoration.image != null) {
this._innerPath = this._decoration.shape.getInnerPath(rect);
}

if (this._decoration.image == null) {
return;
}
this._imagePainter = this._imagePainter ?? this._decoration.image.createPainter(this.onChanged);
this._imagePainter.paint(canvas, this._lastRect, this._innerPath, configuration);
}

this._decoration.shape.paint(canvas, rect);
}
}
}
}

128
Runtime/painting/stadium_border.cs


get { return EdgeInsets.all(this.side.width); }
}
public override ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
circleness: 1.0 - t
circleness: 1.0f - t
rectness: 1.0 - t
rectness: 1.0f - t
public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
if (b is StadiumBorder stadiumBorder) {
return new StadiumBorder(side: BorderSide.lerp(this.side, stadiumBorder.side, t));
}

circleness: t
);
}
if (b is RoundedRectangleBorder rectBorder) {
return new _StadiumToRoundedRectangleBorder(
side: BorderSide.lerp(this.side, rectBorder.side, t),

}
Radius radius = Radius.circular(rect.shortestSide / 2.0);
Radius radius = Radius.circular(rect.shortestSide / 2.0f);
var path = new Path();
path.addRRect(RRect.fromRectAndRadius(rect, radius).deflate(this.side.width));
return path;

Radius radius = Radius.circular(rect.shortestSide / 2.0);
Radius radius = Radius.circular(rect.shortestSide / 2.0f);
var path = new Path();
path.addRRect(RRect.fromRectAndRadius(rect, radius));
return path;

case BorderStyle.none:
break;
case BorderStyle.solid:
Radius radius = Radius.circular(rect.shortestSide / 2.0);
Radius radius = Radius.circular(rect.shortestSide / 2.0f);
RRect.fromRectAndRadius(rect, radius).deflate(this.side.width / 2.0),
RRect.fromRectAndRadius(rect, radius).deflate(this.side.width / 2.0f),
this.side.toPaint()
);
break;

if (ReferenceEquals(null, other)) {
return false;
}
return Equals(this.side, other.side);
}

}
return this.Equals((StadiumBorder) obj);
}

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 ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
return new _StadiumToCircleBorder(
side: this.side.scale(t),
circleness: t

public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is StadiumBorder stadiumBorder) {
return new _StadiumToCircleBorder(
side: BorderSide.lerp(stadiumBorder.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)
public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float 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)
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;
return Rect.fromLTRB(
rect.left,
rect.top + delta,

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

return BorderRadius.circular(rect.shortestSide / 2.0);
return BorderRadius.circular(rect.shortestSide / 2.0f);
}
public override Path getInnerPath(Rect rect) {

case BorderStyle.none:
break;
case BorderStyle.solid:
double width = this.side.width;
if (width == 0.0) {
float width = this.side.width;
if (width == 0.0f) {
} else {
}
else {
RRect outer = this._adjustBorderRadius(rect).toRRect(this._adjustRect(rect));
RRect inner = outer.deflate(width);
Paint paint = new Paint {

}
break;
}
}

return false;
}
return Equals(this.side, other.side) && this.circleness.Equals(other.circleness);
}

}
return this.Equals((_StadiumToCircleBorder) obj);
}

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 ShapeBorder scale(double t) {
public override ShapeBorder scale(float t) {
return new _StadiumToRoundedRectangleBorder(
side: this.side.scale(t),
borderRadius: this.borderRadius * t,

public override ShapeBorder lerpFrom(ShapeBorder a, double t) {
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is StadiumBorder stadiumBorder) {
return new _StadiumToRoundedRectangleBorder(
side: BorderSide.lerp(stadiumBorder.side, this.side, t),

}
rectness: this.rectness + (1.0 - this.rectness) * (1.0 - t)
rectness: this.rectness + (1.0f - this.rectness) * (1.0f - t)
rectness: MathUtils.lerpDouble(border.rectness, this.rectness, t)
rectness: MathUtils.lerpFloat(border.rectness, this.rectness, t)
public override ShapeBorder lerpTo(ShapeBorder b, double t) {
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
rectness: this.rectness * (1.0 - t)
rectness: this.rectness * (1.0f - t)
rectness: this.rectness + (1.0 - this.rectness) * t
rectness: this.rectness + (1.0f - this.rectness) * t
rectness: MathUtils.lerpDouble(this.rectness, border.rectness, t)
rectness: MathUtils.lerpFloat(this.rectness, border.rectness, t)
return base.lerpTo(b, t);
}

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

case BorderStyle.none:
break;
case BorderStyle.solid:
double width = this.side.width;
if (width == 0.0) {
float width = this.side.width;
if (width == 0.0f) {
} else {
}
else {
RRect outer = this._adjustBorderRadius(rect).toRRect(rect);
RRect inner = outer.deflate(width);
Paint paint = new Paint {

}
break;
}
}

return false;
}
return Equals(this.side, other.side) && Equals(this.borderRadius, other.borderRadius) &&
this.rectness.Equals(other.rectness);
}

return false;
}
return this.Equals((_StadiumToRoundedRectangleBorder) obj);
}

"RoundedRectangleBorder)";
}
}
}
}

44
Runtime/painting/text_painter.cs


TextSpan _text;
TextAlign _textAlign;
TextDirection? _textDirection;
double _textScaleFactor;
float _textScaleFactor;
double _lastMinWidth;
double _lastMaxWidth;
float _lastMinWidth;
float _lastMaxWidth;
double textScaleFactor = 1.0,
float textScaleFactor = 1.0f,
int? maxLines = null,
string ellipsis = "") {
this._text = text;

}
public double textScaleFactor {
public float textScaleFactor {
get { return this._textScaleFactor; }
set {
if (this._textScaleFactor == value) {

}
}
public double minIntrinsicWidth {
public float minIntrinsicWidth {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.minIntrinsicWidth);

public double maxIntrinsicWidth {
public float maxIntrinsicWidth {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.maxIntrinsicWidth);

public double height {
public float height {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.height);

public double width {
public float width {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.width);

public double computeDistanceToActualBaseline(TextBaseline baseline) {
public float computeDistanceToActualBaseline(TextBaseline baseline) {
Debug.Assert(!this._needsLayout);
switch (baseline) {
case TextBaseline.alphabetic:

}
return 0.0;
return 0.0f;
public void layout(double minWidth = 0.0, double maxWidth = double.PositiveInfinity) {
public void layout(float minWidth = 0.0f, float maxWidth = float.PositiveInfinity) {
Debug.Assert(this.text != null,
"TextPainter.text must be set to a non-null value before using the TextPainter.");
Debug.Assert(this.textDirection != null,

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;
}

this.ellipsis, this.maxLines, this.textScaleFactor);
}
public double preferredLineHeight {
public float preferredLineHeight {
get {
if (this._layoutTemplate == null) {
var builder = new ParagraphBuilder(this._createParagraphStyle(TextDirection.ltr)

builder.addText(" ");
this._layoutTemplate = builder.build();
this._layoutTemplate.layout(new ParagraphConstraints(double.PositiveInfinity));
this._layoutTemplate.layout(new ParagraphConstraints(float.PositiveInfinity));
}
return this._layoutTemplate.height;

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

case TextAlign.left:
return Offset.zero;
case TextAlign.right:
return new Offset(this.width, 0.0);
return new Offset(this.width, 0.0f);
return new Offset(this.width / 2.0, 0.0);
return new Offset(this.width / 2.0f, 0.0f);
return new Offset(this.width, 0.0);
return new Offset(this.width, 0.0f);
}
return Offset.zero;

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);

60
Runtime/painting/text_style.cs


namespace Unity.UIWidgets.painting {
public class TextStyle : Diagnosticable, IEquatable<TextStyle>, ParagraphBuilder.ITextStyleProvider {
public static readonly double _defaultFontSize = 14.0;
public static readonly float _defaultFontSize = 14.0f;
public readonly double? fontSize;
public readonly float? fontSize;
public readonly double? letterSpacing;
public readonly double? wordSpacing;
public readonly float? letterSpacing;
public readonly float? wordSpacing;
public readonly double? height;
public readonly float? height;
public readonly TextDecoration decoration;
public readonly Color decorationColor;
public readonly TextDecorationStyle? decorationStyle;

const string _kDefaultDebugLabel = "unknown";
public TextStyle(bool inherit = true, Color color = null, double? fontSize = null,
public TextStyle(bool inherit = true, Color color = null, float? fontSize = null,
FontStyle? fontStyle = null, double? letterSpacing = null, double? wordSpacing = null,
TextBaseline? textBaseline = null, double? height = null, Paint background = null,
FontStyle? fontStyle = null, float? letterSpacing = null, float? wordSpacing = null,
TextBaseline? textBaseline = null, float? height = null, Paint background = null,
TextDecoration decoration = null,
Color decorationColor = null, TextDecorationStyle? decorationStyle = null,
string fontFamily = null, string debugLabel = null) {

}
public ParagraphStyle getParagraphStyle(TextAlign textAlign,
TextDirection textDirection, string ellipsis, int? maxLines, double textScaleFactor = 1.0) {
TextDirection textDirection, string ellipsis, int? maxLines, float textScaleFactor = 1.0f) {
return new ParagraphStyle(
textAlign, textDirection, this.fontWeight, this.fontStyle,
maxLines, (this.fontSize ?? _defaultFontSize) * textScaleFactor, this.fontFamily, this.height,

Color decorationColor = null,
TextDecorationStyle? decorationStyle = null,
string fontFamily = null,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
float fontSizeFactor = 1.0f,
float fontSizeDelta = 0.0f,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0
float letterSpacingFactor = 1.0f,
float letterSpacingDelta = 0.0f,
float wordSpacingFactor = 1.0f,
float wordSpacingDelta = 0.0f,
float heightFactor = 1.0f,
float heightDelta = 0.0f
) {
D.assert(this.fontSize != null || (fontSizeFactor == 1.0 && fontSizeDelta == 0.0));
D.assert(this.fontWeight != null || fontWeightDelta == 0.0);

public TextStyle copyWith(Color color = null,
string fontFamily = null,
double? fontSize = null,
float? fontSize = null,
double? letterSpacing = null,
double? wordSpacing = null,
float? letterSpacing = null,
float? wordSpacing = null,
double? height = null,
float? height = null,
Paint background = null,
TextDecoration decoration = null,
Color decorationColor = null,

);
}
public static TextStyle lerp(TextStyle a, TextStyle b, double t) {
public static TextStyle lerp(TextStyle a, TextStyle b, float t) {
D.assert(a == null || b == null || a.inherit == b.inherit);
if (a == null && b == null) {
return null;

inherit: b.inherit,
color: Color.lerp(a.color, b.color, t),
fontFamily: t < 0.5 ? a.fontFamily : b.fontFamily,
fontSize: MathUtils.lerpNullableDouble(a.fontSize ?? b.fontSize, b.fontSize ?? a.fontSize, t),
fontSize: MathUtils.lerpNullableFloat(a.fontSize ?? b.fontSize, b.fontSize ?? a.fontSize, t),
letterSpacing: MathUtils.lerpNullableDouble(a.letterSpacing ?? b.letterSpacing,
letterSpacing: MathUtils.lerpNullableFloat(a.letterSpacing ?? b.letterSpacing,
wordSpacing: MathUtils.lerpNullableDouble(a.wordSpacing ?? b.wordSpacing,
wordSpacing: MathUtils.lerpNullableFloat(a.wordSpacing ?? b.wordSpacing,
height: MathUtils.lerpNullableDouble(a.height ?? b.height, b.height ?? a.height, t),
height: MathUtils.lerpNullableFloat(a.height ?? b.height, b.height ?? a.height, t),
background: t < 0.5 ? a.background : b.background,
decoration: t < 0.5 ? a.decoration : b.decoration,
decorationColor: Color.lerp(a.decorationColor, b.decorationColor, t),

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));

22
Runtime/physics/clamped_simulation.cs


namespace Unity.UIWidgets.physics {
public class ClampedSimulation : Simulation {
public ClampedSimulation(Simulation simulation,
double xMin = double.NegativeInfinity,
double xMax = double.PositiveInfinity,
double dxMin = double.NegativeInfinity,
double dxMax = double.PositiveInfinity
float xMin = float.NegativeInfinity,
float xMax = float.PositiveInfinity,
float dxMin = float.NegativeInfinity,
float dxMax = float.PositiveInfinity
) {
D.assert(simulation != null);
D.assert(xMax >= xMin);

public readonly Simulation simulation;
public readonly double xMin;
public readonly float xMin;
public readonly double xMax;
public readonly float xMax;
public readonly double dxMin;
public readonly float dxMin;
public readonly double dxMax;
public readonly float dxMax;
public override double x(double time) {
public override float x(float time) {
public override double dx(double time) {
public override float dx(float time) {
public override bool isDone(double time) {
public override bool isDone(float time) {
return this.simulation.isDone(time);
}
}

59
Runtime/physics/friction_simulation.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
double drag, double position, double velocity,
float drag, float position, float velocity,
this._dragLog = Math.Log(drag);
this._dragLog = Mathf.Log(drag);
public static FrictionSimulation through(double startPosition, double endPosition, double startVelocity,
double endVelocity) {
public static FrictionSimulation through(float startPosition, float endPosition, float startVelocity,
float endVelocity) {
D.assert(startVelocity == 0.0 || endVelocity == 0.0 || startVelocity.sign() == endVelocity.sign());
D.assert(startVelocity.abs() >= endVelocity.abs());
D.assert((endPosition - startPosition).sign() == startVelocity.sign());

);
}
readonly double _drag;
readonly double _dragLog;
readonly double _x;
readonly double _v;
readonly float _drag;
readonly float _dragLog;
readonly float _x;
readonly float _v;
static double _dragFor(double startPosition, double endPosition, double startVelocity, double endVelocity) {
return Math.Pow(Math.E, (startVelocity - endVelocity) / (startPosition - endPosition));
static float _dragFor(float startPosition, float endPosition, float startVelocity, float endVelocity) {
return Mathf.Pow((float) Math.E, (startVelocity - endVelocity) / (startPosition - endPosition));
public override double x(double time) {
return this._x + this._v * Math.Pow(this._drag, time) / this._dragLog - this._v / this._dragLog;
public override float x(float time) {
return this._x + this._v * Mathf.Pow(this._drag, time) / this._dragLog - this._v / this._dragLog;
public override double dx(double time) {
return this._v * Math.Pow(this._drag, time);
public override float dx(float time) {
return this._v * Mathf.Pow(this._drag, time);
public double finalX {
public float finalX {
public double timeAtX(double x) {
public float timeAtX(float x) {
return 0.0;
return 0.0f;
return double.PositiveInfinity;
return float.PositiveInfinity;
return 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(double time) {
public override bool isDone(float time) {
return this.dx(time).abs() < this.tolerance.velocity;
}
}

double drag,
double position,
double velocity,
double _minX,
double _maxX
float drag,
float position,
float velocity,
float _minX,
float _maxX
) : base(drag, position, velocity) {
D.assert(position.clamp(_minX, _maxX) == position);
this._minX = _minX;

readonly double _minX;
readonly float _minX;
readonly double _maxX;
readonly float _maxX;
public override double x(double time) {
public override float x(float time) {
public override bool isDone(double time) {
public override bool isDone(float time) {
return base.isDone(time) ||
(this.x(time) - this._minX).abs() < this.tolerance.distance ||
(this.x(time) - this._maxX).abs() < this.tolerance.distance;

24
Runtime/physics/gravity_simulation.cs


namespace Unity.UIWidgets.physics {
public class GravitySimulation : Simulation {
public GravitySimulation(
double acceleration,
double distance,
double endDistance,
double velocity
float acceleration,
float distance,
float endDistance,
float velocity
) {
D.assert(endDistance >= 0);
this._a = acceleration;

}
readonly double _x;
readonly double _v;
readonly double _a;
readonly double _end;
readonly float _x;
readonly float _v;
readonly float _a;
readonly float _end;
public override double x(double time) {
return this._x + this._v * time + 0.5 * this._a * time * time;
public override float x(float time) {
return this._x + this._v * time + 0.5f * this._a * time * time;
public override double dx(double time) {
public override float dx(float time) {
public override bool isDone(double time) {
public override bool isDone(float time) {
return this.x(time).abs() >= this._end;
}
}

6
Runtime/physics/simulation.cs


this.tolerance = tolerance ?? Tolerance.defaultTolerance;
}
public abstract double x(double time);
public abstract float x(float time);
public abstract double dx(double time);
public abstract float dx(float time);
public abstract bool isDone(double time);
public abstract bool isDone(float time);
public Tolerance tolerance;
}

143
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})";

public class SpringSimulation : Simulation {
public SpringSimulation(
SpringDescription spring,
double start,
double end,
double velocity,
float start,
float end,
float velocity,
Tolerance tolerance = null
) : base(tolerance: tolerance) {
this._endPosition = end;

protected readonly double _endPosition;
protected readonly float _endPosition;
readonly _SpringSolution _solution;
public SpringType type {

public override double x(double time) {
public override float x(float time) {
public override double dx(double time) {
public override float dx(float time) {
public override bool isDone(double time) {
public override bool isDone(float time) {
return PhysicsUtils.nearZero(this._solution.x(time), this.tolerance.distance) &&
PhysicsUtils.nearZero(this._solution.dx(time), this.tolerance.velocity);
}

public class ScrollSpringSimulation : SpringSimulation {
public ScrollSpringSimulation(
SpringDescription spring,
double start,
double end,
double velocity,
float start,
float end,
float velocity,
public override double x(double time) {
public override float x(float time) {
return this.isDone(time) ? this._endPosition : base.x(time);
}
}

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);

return _UnderdampedSolution.create(spring, initialPosition, initialVelocity);
}
public abstract double x(double time);
public abstract double dx(double time);
public abstract float x(float time);
public abstract float dx(float time);
public abstract SpringType type { get; }
}

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;
public override double x(double time) {
return (this._c1 + this._c2 * time) * Math.Pow(Math.E, this._r * time);
public override float x(float time) {
return ((this._c1 + this._c2 * time) * Mathf.Pow((float) Math.E, this._r * time));
public override double dx(double time) {
double power = Math.Pow(Math.E, this._r * time);
return this._r * (this._c1 + this._c2 * time) * power + this._c2 * power;
public override float dx(float time) {
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 {

class _OverdampedSolution : _SpringSolution {
internal new static _OverdampedSolution create(
SpringDescription spring,
double distance,
double velocity
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;
public override double x(double time) {
return this._c1 * Math.Pow(Math.E, this._r1 * time) +
this._c2 * Math.Pow(Math.E, this._r2 * time);
public override float x(float time) {
return (this._c1 * Mathf.Pow((float) Math.E, this._r1 * time) +
this._c2 * Mathf.Pow((float) Math.E, this._r2 * time));
public override double dx(double time) {
return this._c1 * this._r1 * Math.Pow(Math.E, this._r1 * time) +
this._c2 * this._r2 * Math.Pow(Math.E, this._r2 * time);
public override float dx(float 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;
public override double x(double time) {
return Math.Pow(Math.E, this._r * time) *
(this._c1 * Math.Cos(this._w * time) + this._c2 * Math.Sin(this._w * time));
public override float x(float time) {
return (Mathf.Pow((float) Math.E, this._r * time) *
(this._c1 * Mathf.Cos(this._w * time) + this._c2 * Mathf.Sin(this._w * time)));
public override double dx(double 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 power * (this._c2 * this._w * cosine - this._c1 * this._w * sine) +
this._r * power * (this._c2 * sine + this._c1 * cosine);
public override float dx(float time) {
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 {

14
Runtime/physics/tolerance.cs


namespace Unity.UIWidgets.physics {
public class Tolerance {
public Tolerance(
double distance = _epsilonDefault,
double time = _epsilonDefault,
double velocity = _epsilonDefault
float distance = _epsilonDefault,
float time = _epsilonDefault,
float velocity = _epsilonDefault
) {
this.distance = distance;
this.time = time;

const double _epsilonDefault = 1e-3;
const float _epsilonDefault = 1e-3f;
public readonly double distance;
public readonly float distance;
public readonly double time;
public readonly float time;
public readonly double velocity;
public readonly float velocity;
public override string ToString() {
return $"Tolerance(distance: ±{this.distance}, time: ±{this.time}, velocity: ±{this.velocity})";

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);
}
}
}

6
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._controller.forward(from: 0.0);
this._lastValue = 0.0f;
this._controller.forward(from: 0.0f);
}
void _layoutStart() {

243
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 {

public class BoxConstraints : Constraints, IEquatable<BoxConstraints> {
public BoxConstraints(
double minWidth = 0.0,
double maxWidth = double.PositiveInfinity,
double minHeight = 0.0,
double maxHeight = double.PositiveInfinity) {
float minWidth = 0.0f,
float maxWidth = float.PositiveInfinity,
float minHeight = 0.0f,
float maxHeight = float.PositiveInfinity) {
this.minWidth = minWidth;
this.maxWidth = maxWidth;
this.minHeight = minHeight;

public readonly double minWidth;
public readonly double maxWidth;
public readonly double minHeight;
public readonly double maxHeight;
public readonly float minWidth;
public readonly float maxWidth;
public readonly float minHeight;
public readonly float maxHeight;
public static BoxConstraints tight(Size size) {
return new BoxConstraints(

}
public static BoxConstraints tightFor(
double? width = null,
double? height = null
float? width = null,
float? height = null
width ?? 0.0,
width ?? double.PositiveInfinity,
height ?? 0.0,
height ?? double.PositiveInfinity
width ?? 0.0f,
width ?? float.PositiveInfinity,
height ?? 0.0f,
height ?? float.PositiveInfinity
double width = double.PositiveInfinity,
double height = double.PositiveInfinity
float width = float.PositiveInfinity,
float height = float.PositiveInfinity
!double.IsPositiveInfinity(width) ? width : 0.0,
!double.IsPositiveInfinity(width) ? width : double.PositiveInfinity,
!double.IsPositiveInfinity(height) ? height : 0.0,
!double.IsPositiveInfinity(height) ? height : double.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
);
}

}
public static BoxConstraints expand(
double? width = null,
double? height = null
float? width = null,
float? height = null
width ?? double.PositiveInfinity,
width ?? double.PositiveInfinity,
height ?? double.PositiveInfinity,
height ?? double.PositiveInfinity
width ?? float.PositiveInfinity,
width ?? float.PositiveInfinity,
height ?? float.PositiveInfinity,
height ?? float.PositiveInfinity
double? minWidth = null,
double? maxWidth = null,
double? minHeight = null,
double? maxHeight = null
float? minWidth = null,
float? maxWidth = null,
float? minHeight = null,
float? maxHeight = null
) {
return new BoxConstraints(
minWidth ?? this.minWidth,

public BoxConstraints deflate(EdgeInsets edges) {
D.assert(edges != null);
D.assert(this.debugAssertIsValid());
double horizontal = edges.horizontal;
double vertical = edges.vertical;
double deflatedMinWidth = Math.Max(0.0, this.minWidth - horizontal);
double deflatedMinHeight = Math.Max(0.0, this.minHeight - vertical);
float horizontal = edges.horizontal;
float vertical = edges.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)
);
}

minWidth: 0.0,
minWidth: 0.0f,
minHeight: 0.0,
minHeight: 0.0f,
maxHeight: this.maxHeight
);
}

}
public BoxConstraints tighten(
double? width = null,
double? height = null
float? width = null,
float? height = null
) {
return new BoxConstraints(
minWidth: width == null ? this.minWidth : width.Value.clamp(this.minWidth, this.maxWidth),

return new BoxConstraints(minHeight: this.minHeight, maxHeight: this.maxHeight);
}
public double constrainWidth(double width = double.PositiveInfinity) {
public float constrainWidth(float width = float.PositiveInfinity) {
public double constrainHeight(double height = double.PositiveInfinity) {
public float constrainHeight(float height = float.PositiveInfinity) {
D.assert(this.debugAssertIsValid());
return height.clamp(this.minHeight, this.maxHeight);
}

return result;
}
public Size constrainDimensions(double width, double height) {
public Size constrainDimensions(float width, float height) {
return new Size(this.constrainWidth(width), this.constrainHeight(height));
}

return result1;
}
double width = size.width;
double height = size.height;
float width = size.width;
float height = size.height;
double aspectRatio = width / height;
float aspectRatio = width / height;
if (width > this.maxWidth) {
width = this.maxWidth;

}
public Size smallest {
get { return new Size(this.constrainWidth(0.0), this.constrainHeight(0.0)); }
get { return new Size(this.constrainWidth(0.0f), this.constrainHeight(0.0f)); }
}
public bool hasTightWidth {

}
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) {

}
public static BoxConstraints operator *(BoxConstraints it, double factor) {
public static BoxConstraints operator *(BoxConstraints it, float factor) {
return new BoxConstraints(
minWidth: it.minWidth * factor,
maxWidth: it.maxWidth * factor,

}
public static BoxConstraints operator /(BoxConstraints it, double factor) {
public static BoxConstraints operator /(BoxConstraints it, float factor) {
return new BoxConstraints(
minWidth: it.minWidth / factor,
maxWidth: it.maxWidth / factor,

}
public static BoxConstraints operator %(BoxConstraints it, double value) {
public static BoxConstraints operator %(BoxConstraints it, float value) {
return new BoxConstraints(
minWidth: it.minWidth % value,
maxWidth: it.maxWidth % value,

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

}
if (b == null) {
return a * (1.0 - t);
return a * (1.0f - t);
}
D.assert(a.debugAssertIsValid());

(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),
? MathUtils.lerpDouble(a.minWidth, b.minWidth, t)
: double.PositiveInfinity,
? MathUtils.lerpFloat(a.minWidth, b.minWidth, t)
: float.PositiveInfinity,
? MathUtils.lerpDouble(a.maxWidth, b.maxWidth, t)
: double.PositiveInfinity,
? MathUtils.lerpFloat(a.maxWidth, b.maxWidth, t)
: float.PositiveInfinity,
? MathUtils.lerpDouble(a.minHeight, b.minHeight, t)
: double.PositiveInfinity,
? MathUtils.lerpFloat(a.minHeight, b.minHeight, t)
: float.PositiveInfinity,
? MathUtils.lerpDouble(a.maxHeight, b.maxHeight, t)
: double.PositiveInfinity
? MathUtils.lerpFloat(a.maxHeight, b.maxHeight, t)
: float.PositiveInfinity
);
}

return this;
}
var minWidth = this.minWidth >= 0.0 ? this.minWidth : 0.0;
var minHeight = this.minHeight >= 0.0 ? this.minHeight : 0.0;
var minWidth = this.minWidth >= 0.0 ? this.minWidth : 0.0f;
var minHeight = this.minHeight >= 0.0 ? this.minHeight : 0.0f;
return new BoxConstraints(
minWidth,

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)) {

}
}
Dictionary<_IntrinsicDimensionsCacheEntry, double> _cachedIntrinsicDimensions;
Dictionary<_IntrinsicDimensionsCacheEntry, float> _cachedIntrinsicDimensions;
double _computeIntrinsicDimension(_IntrinsicDimension dimension, double argument,
Func<double, double> computer) {
float _computeIntrinsicDimension(_IntrinsicDimension dimension, float argument,
Func<float, float> computer) {
D.assert(debugCheckingIntrinsics || !this.debugDoingThisResize);
bool shouldCache = true;
D.assert(() => {

if (shouldCache) {
this._cachedIntrinsicDimensions =
this._cachedIntrinsicDimensions
?? new Dictionary<_IntrinsicDimensionsCacheEntry, double>();
?? new Dictionary<_IntrinsicDimensionsCacheEntry, float>();
return this._cachedIntrinsicDimensions.putIfAbsent(
new _IntrinsicDimensionsCacheEntry(dimension, argument),
() => computer(argument));

}
public double getMinIntrinsicWidth(double height) {
public float getMinIntrinsicWidth(float height) {
D.assert(() => {
if (height < 0.0) {
throw new UIWidgetsError(

"getMinIntrinsicWidth, consider using math.max() or double.clamp() " +
"getMinIntrinsicWidth, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
);
}

return this._computeIntrinsicDimension(_IntrinsicDimension.minWidth, height, this.computeMinIntrinsicWidth);
}
protected virtual double computeMinIntrinsicWidth(double height) {
return 0.0;
protected virtual float computeMinIntrinsicWidth(float height) {
return 0.0f;
public double getMaxIntrinsicWidth(double height) {
public float getMaxIntrinsicWidth(float height) {
D.assert(() => {
if (height < 0.0) {
throw new UIWidgetsError(

"getMaxIntrinsicWidth, consider using math.max() or double.clamp() " +
"getMaxIntrinsicWidth, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
);
}

return this._computeIntrinsicDimension(_IntrinsicDimension.maxWidth, height, this.computeMaxIntrinsicWidth);
}
protected virtual double computeMaxIntrinsicWidth(double height) {
return 0.0;
protected virtual float computeMaxIntrinsicWidth(float height) {
return 0.0f;
public double getMinIntrinsicHeight(double width) {
public float getMinIntrinsicHeight(float width) {
D.assert(() => {
if (width < 0.0) {
throw new UIWidgetsError(

"getMinIntrinsicHeight, consider using math.max() or double.clamp() " +
"getMinIntrinsicHeight, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
);
}

this.computeMinIntrinsicHeight);
}
protected virtual double computeMinIntrinsicHeight(double width) {
return 0.0;
protected virtual float computeMinIntrinsicHeight(float width) {
return 0.0f;
public double getMaxIntrinsicHeight(double width) {
public float getMaxIntrinsicHeight(float width) {
D.assert(() => {
if (width < 0.0) {
throw new UIWidgetsError(

"getMaxIntrinsicHeight, consider using math.max() or double.clamp() " +
"getMaxIntrinsicHeight, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
);
}

this.computeMaxIntrinsicHeight);
}
protected virtual double computeMaxIntrinsicHeight(double width) {
return 0.0;
protected virtual float computeMaxIntrinsicHeight(float width) {
return 0.0f;
}
public bool hasSize {

this.size = this.size;
}
Dictionary<TextBaseline, double?> _cachedBaselines;
Dictionary<TextBaseline, float?> _cachedBaselines;
static bool _debugDoingBaseline = false;
static bool _debugSetDoingBaseline(bool value) {

public double? getDistanceToBaseline(TextBaseline baseline, bool onlyReal = false) {
public float? getDistanceToBaseline(TextBaseline baseline, bool onlyReal = false) {
D.assert(!_debugDoingBaseline,
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
D.assert(!this.debugNeedsLayout);

});
D.assert(_debugSetDoingBaseline(true));
double? result = this.getDistanceToActualBaseline(baseline);
float? result = this.getDistanceToActualBaseline(baseline);
D.assert(_debugSetDoingBaseline(false));
if (result == null && !onlyReal) {

return result;
}
public virtual double? getDistanceToActualBaseline(TextBaseline baseline) {
public virtual float? getDistanceToActualBaseline(TextBaseline baseline) {
this._cachedBaselines = this._cachedBaselines ?? new Dictionary<TextBaseline, double?>();
this._cachedBaselines = this._cachedBaselines ?? new Dictionary<TextBaseline, float?>();
protected virtual double? computeDistanceToActualBaseline(TextBaseline baseline) {
protected virtual float? computeDistanceToActualBaseline(TextBaseline baseline) {
D.assert(_debugDoingBaseline,
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");

var failures = new StringBuilder();
int failureCount = 0;
var testIntrinsic = new Func<Func<double, double>, string, double, double>(
var testIntrinsic = new Func<Func<float, float>, string, float, float>(
double result = function(constraint);
float result = function(constraint);
if (result < 0) {
failures.AppendLine(" * " + name + "(" + constraint + ") returned a negative value: " +
result);

if (!result.isFinite()) {
if (result.isInfinite()) {
failures.AppendLine(" * " + name + "(" + constraint +
") returned a non-finite value: " + result);
failureCount += 1;

});
var testIntrinsicsForValues =
new Action<Func<double, double>, Func<double, double>, string, double>(
new Action<Func<float, float>, Func<float, float>, string, float>(
double min = testIntrinsic(getMin, "getMinIntrinsic" + name, constraint);
double max = testIntrinsic(getMax, "getMaxIntrinsic" + name, constraint);
float min = testIntrinsic(getMin, "getMinIntrinsic" + name, constraint);
float max = testIntrinsic(getMax, "getMaxIntrinsic" + name, constraint);
if (min > max) {
failures.AppendLine(
" * getMinIntrinsic" + name + "(" + constraint + ") returned a larger value (" +

});
testIntrinsicsForValues(this.getMinIntrinsicWidth, this.getMaxIntrinsicWidth, "Width",
double.PositiveInfinity);
float.PositiveInfinity);
double.PositiveInfinity);
float.PositiveInfinity);
if (this.constraints.hasBoundedWidth) {
testIntrinsicsForValues(this.getMinIntrinsicWidth, this.getMaxIntrinsicWidth, "Width",

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;

13
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

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) {
double? result = null;
public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
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;

13
Runtime/rendering/box.mixin.njk


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

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) {
double? result = null;
public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
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;
}

24
Runtime/rendering/custom_layout.cs


return constraints.constrain(this._delegate.getSize(constraints));
}
protected override double computeMinIntrinsicWidth(double height) {
double width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
protected override float computeMinIntrinsicWidth(float height) {
float width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
return 0.0;
return 0.0f;
protected override double computeMaxIntrinsicWidth(double height) {
double width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
protected override float computeMaxIntrinsicWidth(float height) {
float width = this._getSize(BoxConstraints.tightForFinite(height: height)).width;
return 0.0;
return 0.0f;
protected override double computeMinIntrinsicHeight(double width) {
double height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
protected override float computeMinIntrinsicHeight(float width) {
float height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
return 0.0;
return 0.0f;
protected override double computeMaxIntrinsicHeight(double width) {
double height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
protected override float computeMaxIntrinsicHeight(float width) {
float height = this._getSize(BoxConstraints.tightForFinite(width: width)).height;
return 0.0;
return 0.0f;
}
protected override void performLayout() {

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

正在加载...
取消
保存