浏览代码

1. refine assert. defer message generation.

2. refine Path.
/main
kg 5 年前
当前提交
5a817602
共有 62 个文件被更改,包括 490 次插入541 次删除
  1. 12
      Runtime/animation/animation_controller.cs
  2. 4
      Runtime/engine/UIWidgetsMessageManager.cs
  3. 8
      Runtime/foundation/debug.cs
  4. 2
      Runtime/foundation/diagnostics.cs
  5. 6
      Runtime/foundation/observer_list.cs
  6. 35
      Runtime/gestures/arena.cs
  7. 4
      Runtime/gestures/recognizer.cs
  8. 2
      Runtime/material/app_bar.cs
  9. 2
      Runtime/material/bottom_navigation_bar.cs
  10. 8
      Runtime/material/chip.cs
  11. 4
      Runtime/material/chip_theme.cs
  12. 4
      Runtime/material/expansion_panel.cs
  13. 2
      Runtime/material/flexible_space_bar.cs
  14. 2
      Runtime/material/ink_decoration.cs
  15. 8
      Runtime/material/input_decorator.cs
  16. 2
      Runtime/material/list_tile.cs
  17. 2
      Runtime/material/reorderable_list.cs
  18. 2
      Runtime/material/slider.cs
  19. 7
      Runtime/material/text_field.cs
  20. 6
      Runtime/painting/box_border.cs
  21. 2
      Runtime/painting/box_decoration.cs
  22. 4
      Runtime/painting/decoration_image.cs
  23. 4
      Runtime/painting/gradient.cs
  24. 16
      Runtime/rendering/box.cs
  25. 2
      Runtime/rendering/debug_overflow_indicator.cs
  26. 5
      Runtime/rendering/image.cs
  27. 4
      Runtime/rendering/layer.cs
  28. 2
      Runtime/rendering/object.cs
  29. 18
      Runtime/rendering/object.mixin.gen.cs
  30. 4
      Runtime/rendering/proxy_box.cs
  31. 2
      Runtime/rendering/viewport.cs
  32. 10
      Runtime/rendering/wrap.cs
  33. 17
      Runtime/scheduler/binding.cs
  34. 13
      Runtime/scheduler/ticker.cs
  35. 4
      Runtime/service/text_input.cs
  36. 51
      Runtime/ui/matrix.cs
  37. 8
      Runtime/ui/painting/painting.cs
  38. 530
      Runtime/ui/painting/path.cs
  39. 1
      Runtime/ui/painting/picture.cs
  40. 4
      Runtime/ui/painting/txt/font_manager.cs
  41. 6
      Runtime/ui/window.cs
  42. 10
      Runtime/widgets/app.cs
  43. 5
      Runtime/widgets/automatic_keep_alive.cs
  44. 3
      Runtime/widgets/binding.cs
  45. 2
      Runtime/widgets/container.cs
  46. 2
      Runtime/widgets/dismissible.cs
  47. 23
      Runtime/widgets/editable_text.cs
  48. 4
      Runtime/widgets/framework.cs
  49. 4
      Runtime/widgets/gesture_detector.cs
  50. 2
      Runtime/widgets/implicit_animations.cs
  51. 4
      Runtime/widgets/localizations.cs
  52. 4
      Runtime/widgets/page_view.cs
  53. 36
      Runtime/widgets/routes.cs
  54. 2
      Runtime/widgets/scroll_activity.cs
  55. 8
      Runtime/widgets/scroll_controller.cs
  56. 2
      Runtime/widgets/scroll_position.cs
  57. 2
      Runtime/widgets/scroll_view.cs
  58. 2
      Runtime/widgets/single_child_scroll_view.cs
  59. 11
      Runtime/widgets/ticker_provider.cs
  60. 6
      Runtime/widgets/visibility.cs
  61. 68
      Samples/UIWidgetSample/MaterialSample.cs
  62. 2
      Samples/UIWidgetsGallery/gallery/demo.cs

12
Runtime/animation/animation_controller.cs


});
D.assert(
this._ticker != null,
"AnimationController.forward() called after AnimationController.dispose()\n" +
() => "AnimationController.forward() called after AnimationController.dispose()\n" +
"AnimationController methods should not be used after calling dispose."
);
this._direction = _AnimationDirection.forward;

});
D.assert(
this._ticker != null,
"AnimationController.reverse() called after AnimationController.dispose()\n" +
() => "AnimationController.reverse() called after AnimationController.dispose()\n" +
"AnimationController methods should not be used after calling dispose."
);
this._direction = _AnimationDirection.reverse;

public TickerFuture animateTo(float target, TimeSpan? duration = null, Curve curve = null) {
D.assert(
this._ticker != null,
"AnimationController.animateTo() called after AnimationController.dispose()\n" +
() => "AnimationController.animateTo() called after AnimationController.dispose()\n" +
"AnimationController methods should not be used after calling dispose."
);
curve = curve ?? Curves.linear;

public TickerFuture animateBack(float target, TimeSpan? duration, Curve curve = null) {
D.assert(
this._ticker != null,
"AnimationController.animateBack() called after AnimationController.dispose()\n" +
() => "AnimationController.animateBack() called after AnimationController.dispose()\n" +
"AnimationController methods should not be used after calling dispose."
);
curve = curve ?? Curves.linear;

public TickerFuture animateWith(Simulation simulation) {
D.assert(
this._ticker != null,
"AnimationController.animateWith() called after AnimationController.dispose()\n" +
() => "AnimationController.animateWith() called after AnimationController.dispose()\n" +
"AnimationController methods should not be used after calling dispose."
);
this.stop();

public void stop(bool canceled = true) {
D.assert(
this._ticker != null,
"AnimationController.stop() called after AnimationController.dispose()\n" +
() => "AnimationController.stop() called after AnimationController.dispose()\n" +
"AnimationController methods should not be used after calling dispose."
);
this._simulation = null;

4
Runtime/engine/UIWidgetsMessageManager.cs


#endif
void OnEnable() {
D.assert(_instance == null, "Only one instance of UIWidgetsMessageManager should exists");
D.assert(_instance == null, () => "Only one instance of UIWidgetsMessageManager should exists");
D.assert(_instance != null, "_instance should not be null");
D.assert(_instance != null, () => "_instance should not be null");
_instance = null;
}

8
Runtime/foundation/debug.cs


}
[Conditional("UIWidgets_DEBUG")]
public static void assert(Func<bool> result, string message = null) {
public static void assert(Func<bool> result, Func<string> message = null) {
throw new AssertionError(message);
throw new AssertionError(message != null ? message() : "");
public static void assert(bool result, string message = null) {
public static void assert(bool result, Func<string> message = null) {
throw new AssertionError(message);
throw new AssertionError(message != null ? message() : "");
}
}

2
Runtime/foundation/diagnostics.cs


bool showSeparator = true
) {
D.assert(name == null || !name.EndsWith(":"),
"Names of diagnostic nodes must not end with colons.");
() => "Names of diagnostic nodes must not end with colons.");
this.name = name;
this._style = style;
this._showName = showName;

6
Runtime/foundation/observer_list.cs


namespace Unity.UIWidgets.foundation {
public class ObserverList<T> : ICollection<T> {
public readonly List<T> _list = new List<T>();
public bool _isDirty = false;
public HashSet<T> _set = null;
readonly List<T> _list = new List<T>();
bool _isDirty = false;
HashSet<T> _set = null;
IEnumerator IEnumerable.GetEnumerator() {
return this.GetEnumerator();

35
Runtime/gestures/arena.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

}
class _GestureArena {
public List<GestureArenaMember> members = new List<GestureArenaMember>();
public readonly List<GestureArenaMember> members = new List<GestureArenaMember>();
public bool isOpen = true;
public bool isHeld = false;
public bool hasPendingSweep = false;

public GestureArenaEntry add(int pointer, GestureArenaMember member) {
_GestureArena state = this._arenas.putIfAbsent(pointer, () => {
D.assert(this._debugLogDiagnostic(pointer, "★ Opening new gesture arena."));
D.assert(this._debugLogDiagnostic(pointer, () => "★ Opening new gesture arena."));
D.assert(this._debugLogDiagnostic(pointer, $"Adding: {member}"));
D.assert(this._debugLogDiagnostic(pointer, () => $"Adding: {member}"));
return new GestureArenaEntry(this, pointer, member);
}

}
state.isOpen = false;
D.assert(this._debugLogDiagnostic(pointer, "Closing", state));
D.assert(this._debugLogDiagnostic(pointer, () => "Closing", state));
this._tryToResolveArena(pointer, state);
}

D.assert(!state.isOpen);
if (state.isHeld) {
state.hasPendingSweep = true;
D.assert(this._debugLogDiagnostic(pointer, "Delaying sweep", state));
D.assert(this._debugLogDiagnostic(pointer, () => "Delaying sweep", state));
D.assert(this._debugLogDiagnostic(pointer, "Sweeping", state));
D.assert(this._debugLogDiagnostic(pointer, () => "Sweeping", state));
pointer, $"Winner: {state.members.First()}"));
pointer, () => $"Winner: {state.members.First()}"));
state.members.First().acceptGesture(pointer);
for (int i = 1; i < state.members.Count; i++) {

}
state.isHeld = true;
D.assert(this._debugLogDiagnostic(pointer, "Holding", state));
D.assert(this._debugLogDiagnostic(pointer, () => "Holding", state));
}
public void release(int pointer) {

}
state.isHeld = false;
D.assert(this._debugLogDiagnostic(pointer, "Releasing", state));
D.assert(this._debugLogDiagnostic(pointer, () => "Releasing", state));
if (state.hasPendingSweep) {
this.sweep(pointer);
}

}
D.assert(this._debugLogDiagnostic(pointer,
$"{(disposition == GestureDisposition.accepted ? "Accepting" : "Rejecting")}: {member}"));
() => $"{(disposition == GestureDisposition.accepted ? "Accepting" : "Rejecting")}: {member}"));
D.assert(state.members.Contains(member));
if (disposition == GestureDisposition.rejected) {

}
else {
D.assert(this._debugLogDiagnostic(pointer,
$"Self-declared winner: {member}"));
() => $"Self-declared winner: {member}"));
this._resolveInFavorOf(pointer, state, member);
}
}

}
else if (state.members.isEmpty()) {
this._arenas.Remove(pointer);
D.assert(this._debugLogDiagnostic(pointer, "Arena empty."));
D.assert(this._debugLogDiagnostic(pointer, () => "Arena empty."));
$"Eager winner: {state.eagerWinner}"));
() => $"Eager winner: {state.eagerWinner}"));
this._resolveInFavorOf(pointer, state, state.eagerWinner);
}
}

D.assert(members.Count == 1);
this._arenas.Remove(pointer);
D.assert(this._debugLogDiagnostic(pointer,
$"Default winner: {state.members.First()}"));
() => $"Default winner: {state.members.First()}"));
state.members.First().acceptGesture(pointer);
}

member.acceptGesture(pointer);
}
bool _debugLogDiagnostic(int pointer, string message, _GestureArena state = null) {
bool _debugLogDiagnostic(int pointer, Func<string> message, _GestureArena state = null) {
int? count = state != null ? state.members.Count : (int?) null;
int? count = state?.members.Count;
message,
message(),
count != null ? $" with {count} member{s}." : "");
}

4
Runtime/gestures/recognizer.cs


float? postAcceptSlopTolerance = Constants.kTouchSlop
) : base(debugOwner: debugOwner, kind: kind) {
D.assert(preAcceptSlopTolerance == null || preAcceptSlopTolerance >= 0,
"The preAcceptSlopTolerance must be positive or null");
() => "The preAcceptSlopTolerance must be positive or null");
"The postAcceptSlopTolerance must be positive or null");
() => "The postAcceptSlopTolerance must be positive or null");
this.deadline = deadline;
this.preAcceptSlopTolerance = preAcceptSlopTolerance;

2
Runtime/material/app_bar.cs


bool pinned = false,
bool snap = false
) : base(key: key) {
D.assert(floating || !snap, "The 'snap' argument only makes sense for floating app bars.");
D.assert(floating || !snap, () => "The 'snap' argument only makes sense for floating app bars.");
this.leading = leading;
this.automaticallyImplyLeading = true;
this.title = title;

2
Runtime/material/bottom_navigation_bar.cs


D.assert(items != null);
D.assert(items.Count >= 2);
D.assert(items.All((BottomNavigationBarItem item) => item.title != null) == true,
"Every item must have a non-null title"
() => "Every item must have a non-null title"
);
D.assert(0 <= currentIndex && currentIndex < items.Count);
this.items = items;

8
Runtime/material/chip.cs


D.assert(label != null);
D.assert(
onPressed != null,
"Rather than disabling an ActionChip by setting onPressed to null, " +
() => "Rather than disabling an ActionChip by setting onPressed to null, " +
"remove it from the interface entirely."
);
D.assert(pressElevation == null || pressElevation >= 0.0f);

}
protected override void moveChildRenderObject(RenderObject child, object slotValue) {
D.assert(false, "not reachable");
D.assert(false, () => "not reachable");
}
}

);
this.size = this.constraints.constrain(paddedSize);
D.assert(this.size.height == this.constraints.constrainHeight(paddedSize.height),
$"Constrained height {this.size.height} doesn't match expected height " +
() => $"Constrained height {this.size.height} doesn't match expected height " +
$"Constrained width {this.size.width} doesn't match expected width " +
() => $"Constrained width {this.size.width} doesn't match expected width " +
$"{this.constraints.constrainWidth(paddedSize.width)}");
}

4
Runtime/material/chip_theme.cs


TextStyle labelStyle = null
) {
D.assert(primaryColor != null || brightness != null,
"One of primaryColor or brightness must be specified");
() => "One of primaryColor or brightness must be specified");
"Only one of primaryColor or brightness may be specified");
() => "Only one of primaryColor or brightness may be specified");
D.assert(secondaryColor != null);
D.assert(labelStyle != null);

4
Runtime/material/expansion_panel.cs


public override void initState() {
base.initState();
if (this.widget._allowOnlyOnePanelOpen) {
D.assert(this._allIdentifierUnique(), "All object identifiers are not unique!");
D.assert(this._allIdentifierUnique(), () => "All object identifiers are not unique!");
foreach (ExpansionPanelRadio child in this.widget.children) {
if (this.widget.initialOpenPanelValue != null &&
child.value == this.widget.initialOpenPanelValue) {

base.didUpdateWidget(oldWidget);
ExpansionPanelList _oldWidget = (ExpansionPanelList) oldWidget;
if (this.widget._allowOnlyOnePanelOpen) {
D.assert(this._allIdentifierUnique(), "All object identifiers are not unique!");
D.assert(this._allIdentifierUnique(), () => "All object identifiers are not unique!");
foreach (ExpansionPanelRadio newChild in this.widget.children) {
if (this.widget.initialOpenPanelValue != null &&
newChild.value == this.widget.initialOpenPanelValue) {

2
Runtime/material/flexible_space_bar.cs


FlexibleSpaceBarSettings settings =
(FlexibleSpaceBarSettings) context.inheritFromWidgetOfExactType(typeof(FlexibleSpaceBarSettings));
D.assert(settings != null,
"A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");
() => "A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");
List<Widget> children = new List<Widget>();
float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;

2
Runtime/material/ink_decoration.cs


D.assert(padding == null || padding.isNonNegative);
D.assert(decoration == null || decoration.debugAssertIsValid());
D.assert(color == null || decoration == null,
"Cannot provide both a color and a decoration\n" +
() => "Cannot provide both a color and a decoration\n" +
"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\".");
decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null);
this.padding = padding;

8
Runtime/material/input_decorator.cs


}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
D.assert(false, "not implemented");
D.assert(false, () => "not implemented");
return 0.0f;
}

}
protected override void moveChildRenderObject(RenderObject child, object slotValue) {
D.assert(false, "not reachable");
D.assert(false, () => "not reachable");
}
}

bool? alignLabelWithHint = null
) {
D.assert(enabled != null);
D.assert(!(prefix != null && prefixText != null), "Declaring both prefix and prefixText is not supported");
D.assert(!(suffix != null && suffixText != null), "Declaring both suffix and suffixText is not supported");
D.assert(!(prefix != null && prefixText != null), () => "Declaring both prefix and prefixText is not supported");
D.assert(!(suffix != null && suffixText != null), () => "Declaring both suffix and suffixText is not supported");
this.isCollapsed = false;
this.icon = icon;
this.labelText = labelText;

2
Runtime/material/list_tile.cs


}
protected override void moveChildRenderObject(RenderObject child, object slotValue) {
D.assert(false, "not reachable");
D.assert(false, () => "not reachable");
}
}

2
Runtime/material/reorderable_list.cs


D.assert(children != null);
D.assert(
children.All((Widget w) => w.key != null),
"All children of this widget must have a key."
() => "All children of this widget must have a key."
);
this.header = header;
this.children = children;

2
Runtime/material/slider.cs


public float value {
get { return this._value; }
set {
D.assert(value != null && value >= 0.0f && value <= 1.0f);
D.assert(value >= 0.0f && value <= 1.0f);
float convertedValue = this.isDiscrete ? this._discretize(value) : value;
if (convertedValue == this._value) {
return;

7
Runtime/material/text_field.cs


return effectiveDecoration.copyWith(counter: counter);
}
if (this.widget.maxLength == null)
if (this.widget.maxLength == null) {
}
if (this.widget.maxLength > 0) {
counterText += $"/{this.widget.maxLength}";

D.assert(
!(this.widget.style != null && this.widget.style.inherit == false &&
(this.widget.style.fontSize == null || this.widget.style.textBaseline == null)),
"inherit false style must supply fontSize and textBaseline"
() => "inherit false style must supply fontSize and textBaseline"
);
ThemeData themeData = Theme.of(context);
TextStyle style = themeData.textTheme.subhead.merge(this.widget.style);

6
Runtime/painting/box_border.cs


switch (shape) {
case BoxShape.circle:
D.assert(borderRadius == null,
"A borderRadius can only be given for rectangular boxes.");
() => "A borderRadius can only be given for rectangular boxes.");
_paintUniformBorderWithCircle(canvas, rect, this.top);
break;
case BoxShape.rectangle:

}
}
D.assert(borderRadius == null, "A borderRadius can only be given for uniform borders.");
D.assert(shape == BoxShape.rectangle, "A border can only be drawn as a circle if it is uniform.");
D.assert(borderRadius == null, () => "A borderRadius can only be given for uniform borders.");
D.assert(shape == BoxShape.rectangle, () => "A border can only be drawn as a circle if it is uniform.");
BorderUtils.paintBorder(canvas, rect,
top: this.top, right: this.right, bottom: this.bottom, left: this.left);

2
Runtime/painting/box_decoration.cs


) {
D.assert(
backgroundBlendMode == null || color != null || gradient != null,
"backgroundBlendMode applies to BoxDecoration\'s background color or " +
() => "backgroundBlendMode applies to BoxDecoration\'s background color or " +
"gradient, but no color or gradient was provided."
);

4
Runtime/painting/decoration_image.cs


fit = fit ?? (centerSlice == null ? BoxFit.scaleDown : BoxFit.fill);
D.assert(centerSlice == null || (fit != BoxFit.none && fit != BoxFit.cover),
$"centerSlice was used with a BoxFit {fit} that is not supported.");
() => $"centerSlice was used with a BoxFit {fit} that is not supported.");
FittedSizes fittedSizes = FittedSizes.applyBoxFit(fit.Value, inputSize / scale, outputSize);
Size sourceSize = fittedSizes.source * scale;
Size destinationSize = fittedSizes.destination;

D.assert(sourceSize == inputSize,
$"centerSlice was used with a BoxFit {fit} that does not guarantee that the image is fully visible.");
() => $"centerSlice was used with a BoxFit {fit} that does not guarantee that the image is fully visible.");
}
if (repeat != ImageRepeat.noRepeat && destinationSize == outputSize) {

4
Runtime/painting/gradient.cs


public static _ColorsAndStops _interpolateColorsAndStops(
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.");
() => "Cannot interpolate between two gradients with a different number of colors.");
D.assert((aStops == null && aColors.Count == 2) || (aStops != null && aStops.Count == aColors.Count));
D.assert((bStops == null && bColors.Count == 2) || (bStops != null && bStops.Count == bColors.Count));
List<Color> interpolatedColors = new List<Color>();

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

16
Runtime/rendering/box.cs


D.assert(
(a.minWidth.isFinite() && b.minWidth.isFinite()) ||
(a.minWidth == float.PositiveInfinity && b.minWidth == float.PositiveInfinity),
"Cannot interpolate between finite constraints and unbounded constraints.");
() => "Cannot interpolate between finite constraints and unbounded constraints.");
"Cannot interpolate between finite constraints and unbounded constraints.");
() => "Cannot interpolate between finite constraints and unbounded constraints.");
"Cannot interpolate between finite constraints and unbounded constraints.");
() => "Cannot interpolate between finite constraints and unbounded constraints.");
"Cannot interpolate between finite constraints and unbounded constraints.");
() => "Cannot interpolate between finite constraints and unbounded constraints.");
return new BoxConstraints(
minWidth: a.minWidth.isFinite()
? MathUtils.lerpFloat(a.minWidth, b.minWidth, t)

public Size size {
get {
D.assert(this.hasSize, "RenderBox was not laid out: " + this);
D.assert(this.hasSize, () => "RenderBox was not laid out: " + this);
D.assert(() => {
if (this._size is _DebugSize) {
_DebugSize _size = (_DebugSize) this._size;

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.");
() => "Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
D.assert(!this.debugNeedsLayout);
D.assert(() => {
RenderObject parent = (RenderObject) this.parent;

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

D.assert(_debugDoingBaseline,
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
() => "Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
return null;
}

2
Runtime/rendering/debug_overflow_indicator.cs


string overflowText = "";
D.assert(overflows.isNotEmpty(),
$"Somehow {renderObject.GetType()} didn't actually overflow like it thought it did.");
() => $"Somehow {renderObject.GetType()} didn't actually overflow like it thought it did.");
switch (overflows.Count) {
case 1:
overflowText = overflows.first();

5
Runtime/rendering/image.cs


ColorFilter _colorFilter;
void _updateColorFilter() {
if (this._color == null)
if (this._color == null) {
else
} else {
}
}
Color _color;

4
Runtime/rendering/layer.cs


}
D.assert(this.link.leader.owner == this.owner,
"Linked LeaderLayer anchor is not in the same layer tree as the FollowerLayer.");
() => "Linked LeaderLayer anchor is not in the same layer tree as the FollowerLayer.");
"LeaderLayer anchor must come before FollowerLayer in paint order, but the reverse was true.");
() => "LeaderLayer anchor must come before FollowerLayer in paint order, but the reverse was true.");
HashSet<Layer> ancestors = new HashSet<Layer>();
Layer ancestor = this.parent;

2
Runtime/rendering/object.cs


public OffsetLayer layer {
get {
D.assert(this.isRepaintBoundary,
"You can only access RenderObject.layer for render objects that are repaint boundaries.");
() => "You can only access RenderObject.layer for render objects that are repaint boundaries.");
D.assert(!this._needsPaint);
return this._layer;

18
Runtime/rendering/object.mixin.gen.cs


}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, "A RenderObject cannot be inserted into itself.");
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, "A RenderObject cannot be inserted after itself.");
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, "A RenderObject cannot be inserted into itself.");
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, "A RenderObject cannot be inserted after itself.");
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, "A RenderObject cannot be inserted into itself.");
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, "A RenderObject cannot be inserted after itself.");
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);

4
Runtime/rendering/proxy_box.cs


canvas.drawRRect(offsetRRect, paint);
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds,
() => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
D.assert(context.canvas == canvas, () => "canvas changed even though needsCompositing was false");
}
}
}

canvas.drawPath(offsetPath, paint);
context.clipPathAndPaint(offsetPath, this.clipBehavior,
offsetBounds, () => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
D.assert(context.canvas == canvas, () => "canvas changed even though needsCompositing was false");
}
}
}

2
Runtime/rendering/viewport.cs


RenderBox pivot = null;
bool onlySlivers = target is RenderSliver;
while (child.parent != this) {
D.assert(child.parent != null, $"target must be a descendant of ${this}");
D.assert(child.parent != null, () => $"target must be a descendant of ${this}");
if (child is RenderBox) {
pivot = (RenderBox) child;
}

10
Runtime/rendering/wrap.cs


}
}
public bool _debugHasNecessaryDirections {
bool _debugHasNecessaryDirections {
get {
if (this.firstChild != null && this.lastChild != this.firstChild) {
// i.e. there"s more than one child

"Horizontal $runtimeType with multiple children has a null textDirection, so the layout order is undefined.");
() => $"Horizontal {this.GetType()} with multiple children has a null textDirection, so the layout order is undefined.");
break;
case Axis.vertical:
break;

switch (this.direction) {
case Axis.horizontal:
D.assert(this.textDirection != null,
"Horizontal $runtimeType with alignment $alignment has a null textDirection, so the alignment cannot be resolved.");
() => $"Horizontal {this.GetType()} with alignment {this.alignment} has a null textDirection, so the alignment cannot be resolved.");
break;
case Axis.vertical:
break;

break;
case Axis.vertical:
D.assert(this.textDirection != null,
"Vertical $runtimeType with runAlignment $runAlignment has a null textDirection, so the alignment cannot be resolved.");
() => $"Vertical {this.GetType()} with runAlignment {this.runAlignment} has a null textDirection, so the alignment cannot be resolved.");
break;
}
}

break;
case Axis.vertical:
D.assert(this.textDirection != null,
"Vertical $runtimeType with crossAxisAlignment $crossAxisAlignment has a null textDirection, so the alignment cannot be resolved.");
() => $"Vertical {this.GetType()} with crossAxisAlignment {this.crossAxisAlignment} has a null textDirection, so the alignment cannot be resolved.");
break;
}
}

17
Runtime/scheduler/binding.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using RSG.Promises;
using Unity.UIWidgets.foundation;

});
this.debugStack = debugCurrentCallbackStack;
} else {
this.debugStack = new StackTrace(2, true);
this.debugStack = "skipped, use StackTraceUtility.ExtractStackTrace() if you need it"; // StackTraceUtility.ExtractStackTrace();
}
return true;

public readonly FrameCallback callback;
public static StackTrace debugCurrentCallbackStack;
public StackTrace debugStack;
internal static string debugCurrentCallbackStack;
internal string debugStack;
}
public enum SchedulerPhase {

public static SchedulerBinding instance {
get {
D.assert(_instance != null,
"Binding.instance is null. " +
() => "Binding.instance is null. " +
"This usually happens when there is a callback from outside of UIWidgets. " +
"Try to use \"using (WindowProvider.of(BuildContext).getScope()) { ... }\" to wrap your code.");
return _instance;

if (value == null) {
D.assert(_instance != null, "Binding.instance is already cleared.");
D.assert(_instance != null, () => "Binding.instance is already cleared.");
D.assert(_instance == null, "Binding.instance is already assigned.");
D.assert(_instance == null, () => "Binding.instance is already assigned.");
_instance = value;
}
}

buffer.Append("ms");
}
void _invokeFrameCallback(FrameCallback callback, TimeSpan timeStamp, StackTrace callbackStack = null) {
void _invokeFrameCallback(FrameCallback callback, TimeSpan timeStamp, string callbackStack = null) {
D.assert(callback != null);
D.assert(_FrameCallbackEntry.debugCurrentCallbackStack == null);
D.assert(() => {

"When the scheduler callback was _registered_ (as opposed to when the " +
"exception was thrown), this was the stack:"
);
UIWidgetsError.defaultStackFilter(callbackStack.ToString().TrimEnd().Split('\n'))
UIWidgetsError.defaultStackFilter(callbackStack.TrimEnd().Split('\n'))
.Each((line) => information.AppendLine(line));
}
));

13
Runtime/scheduler/ticker.cs


using System;
using System.Diagnostics;
using System.Text;
using RSG;
using RSG.Promises;

}
public class Ticker {
public Ticker(TickerCallback onTick, string debugLabel = null) {
public Ticker(TickerCallback onTick, Func<string> debugLabel = null) {
this._debugCreationStack = new Exception().StackTrace;
this._debugCreationStack = "skipped, use StackTraceUtility.ExtractStackTrace() if you need it"; // StackTraceUtility.ExtractStackTrace();
return true;
});
this._onTick = onTick;

D.assert(this._startTime == null);
D.assert(this._animationId == null);
D.assert((originalTicker._future == null) == (originalTicker._startTime == null),
"Cannot absorb Ticker after it has been disposed.");
() => "Cannot absorb Ticker after it has been disposed.");
if (originalTicker._future != null) {
this._future = originalTicker._future;
this._startTime = originalTicker._startTime;

});
}
public readonly string debugLabel;
internal readonly Func<string> debugLabel;
string _debugCreationStack;

var buffer = new StringBuilder();
buffer.Append(this.GetType() + "(");
D.assert(() => {
buffer.Append(this.debugLabel ?? "");
if (this.debugLabel != null) {
buffer.Append(this.debugLabel());
}
return true;
});
buffer.Append(')');

4
Runtime/service/text_input.cs


public static RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state,
Dictionary<string, float?> encoded) {
D.assert(encoded.getOrDefault("X") != null,
"You must provide a value for the horizontal location of the floating cursor.");
() => "You must provide a value for the horizontal location of the floating cursor.");
"You must provide a value for the vertical location of the floating cursor.");
() => "You must provide a value for the vertical location of the floating cursor.");
Offset offset = state == FloatingCursorDragState.Update
? new Offset(encoded["X"] ?? 0.0f, encoded["Y"] ?? 0.0f)
: new Offset(0, 0);

51
Runtime/ui/matrix.cs


}
public Offset mapXY(float x, float y) {
Offset result;
this.getMapXYProc()(this, x, y, out result);
return result;
this.getMapXYProc()(this, x, y, out var x1, out var y1);
return new Offset(x1, y1);
}
public void mapXY(float x, float y, out float x1, out float y1) {
this.getMapXYProc()(this, x, y, out x1, out y1);
}
public bool mapRect(out Rect dst, Rect src) {

}
}
delegate void MapXYProc(Matrix3 mat, float x, float y, out Offset result);
delegate void MapXYProc(Matrix3 mat, float x, float y, out float x1, out float y1);
static readonly MapXYProc[] gMapXYProcs = {
Identity_xy, Trans_xy,

return GetMapXYProc(this.getType());
}
static void Identity_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void Identity_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
result = new Offset(sx, sy);
resX = sx;
resY = sy;
static void Trans_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void Trans_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
result = new Offset(sx + m.fMat[kMTransX], sy + m.fMat[kMTransY]);
resX = sx + m.fMat[kMTransX];
resY = sy + m.fMat[kMTransY];
static void Scale_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void Scale_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
result = new Offset(sx * m.fMat[kMScaleX], sy * m.fMat[kMScaleY]);
resX = sx * m.fMat[kMScaleX];
resY = sy * m.fMat[kMScaleY];
static void ScaleTrans_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void ScaleTrans_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
result = new Offset(sx * m.fMat[kMScaleX] + m.fMat[kMTransX],
sy * m.fMat[kMScaleY] + m.fMat[kMTransY]);
resX = sx * m.fMat[kMScaleX] + m.fMat[kMTransX];
resY = sy * m.fMat[kMScaleY] + m.fMat[kMTransY];
static void Rot_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void Rot_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
result = new Offset(
ScalarUtils.sdot(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]),
ScalarUtils.sdot(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]));
resX = ScalarUtils.sdot(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]);
resY = ScalarUtils.sdot(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]);
static void RotTrans_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void RotTrans_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
result = new Offset(
ScalarUtils.sdot(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]) + m.fMat[kMTransX],
ScalarUtils.sdot(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]) + m.fMat[kMTransY]);
resX = ScalarUtils.sdot(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
resY = ScalarUtils.sdot(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
static void Persp_xy(Matrix3 m, float sx, float sy, out Offset result) {
static void Persp_xy(Matrix3 m, float sx, float sy, out float resX, out float resY) {
D.assert(m.hasPerspective());
float x = ScalarUtils.sdot(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]) +

z = 1 / z;
}
result = new Offset(x * z, y * z);
resX = x * z;
resY = y * z;
}
delegate void MapPtsProc(Matrix3 mat, Offset[] dst, Offset[] src, int count);

8
Runtime/ui/painting/painting.cs


namespace Unity.UIWidgets.ui {
class PaintingUtils {
internal static bool _offsetIsValid(Offset offset) {
D.assert(offset != null, "Offset argument was null.");
D.assert(!offset.dx.isNaN() && !offset.dy.isNaN(), "Offset argument contained a NaN value.");
D.assert(offset != null, () => "Offset argument was null.");
D.assert(!offset.dx.isNaN() && !offset.dy.isNaN(), () => "Offset argument contained a NaN value.");
D.assert(radius != null, "Radius argument was null.");
D.assert(!radius.x.isNaN() && !radius.y.isNaN(), "Radius argument contained a NaN value.");
D.assert(radius != null, () => "Radius argument was null.");
D.assert(!radius.x.isNaN() && !radius.y.isNaN(), () => "Radius argument contained a NaN value.");
return true;
}

530
Runtime/ui/painting/path.cs


using System.Text;
using Unity.UIWidgets.foundation;
using UnityEngine;
using Vector2 = UnityEngine.Vector2;
using Vector3 = UnityEngine.Vector3;
readonly List<float> _commands = new List<float>();
readonly List<float> _commands;
internal PathCache flatten(float scale) {
if (this._cache != null && this._cache.canReuse(scale)) {
return this._cache;
}
this._cache = new PathCache(scale);
var i = 0;
while (i < this._commands.Count) {
var cmd = (PathCommand) this._commands[i];
switch (cmd) {
case PathCommand.moveTo:
this._cache.addPath();
this._cache.addPoint(this._commands[i + 1], this._commands[i + 2], PointFlags.corner);
i += 3;
break;
case PathCommand.lineTo:
this._cache.addPoint(this._commands[i + 1], this._commands[i + 2], PointFlags.corner);
i += 3;
break;
case PathCommand.bezierTo:
this._cache.tessellateBezier(
this._commands[i + 1], this._commands[i + 2],
this._commands[i + 3], this._commands[i + 4],
this._commands[i + 5], this._commands[i + 6], PointFlags.corner);
i += 7;
break;
case PathCommand.close:
this._cache.closePath();
i++;
break;
case PathCommand.winding:
this._cache.pathWinding((PathWinding) this._commands[i + 1]);
i += 2;
break;
default:
D.assert(false, "unknown cmd: " + cmd);
break;
}
}
this._cache.normalize();
return this._cache;
}
public Path() {
public Path(int capacity = 0) {
this._commands = new List<float>(capacity);
this._reset();
}

i += 2;
break;
default:
D.assert(false, "unknown cmd: " + cmd);
D.assert(false, () => "unknown cmd: " + cmd);
break;
}
}

this._cache = null;
}
void _expandBounds(float x, float y) {
this._minX = Mathf.Min(this._minX, x);
this._minY = Mathf.Min(this._minY, y);
this._maxX = Mathf.Max(this._maxX, x);
this._maxY = Mathf.Max(this._maxY, y);
}
public Rect getBounds() {
if (this._minX >= this._maxX || this._minY >= this._maxY) {
return Rect.zero;
internal PathCache flatten(float scale) {
scale = Mathf.Round(scale * 2.0f) / 2.0f; // round to 0.5f
if (this._cache != null && this._cache.canReuse(scale)) {
return this._cache;
return Rect.fromLTRB(this._minX, this._minY, this._maxX, this._maxY);
}
this._cache = new PathCache(scale);
void _appendCommands(float[] commands) {
while (i < commands.Length) {
var cmd = (PathCommand) commands[i];
while (i < this._commands.Count) {
var cmd = (PathCommand) this._commands[i];
this._commandx = commands[i + 1];
this._commandy = commands[i + 2];
this._cache.addPath();
this._cache.addPoint(this._commands[i + 1], this._commands[i + 2], PointFlags.corner);
this._expandBounds(this._commandx, this._commandy);
this._expandBounds(commands[i + 1], commands[i + 2]);
this._commandx = commands[i + 1];
this._commandy = commands[i + 2];
this._cache.addPoint(this._commands[i + 1], this._commands[i + 2], PointFlags.corner);
this._expandBounds(this._commandx, this._commandy);
this._expandBounds(commands[i + 1], commands[i + 2]);
this._expandBounds(commands[i + 3], commands[i + 4]);
this._expandBounds(commands[i + 5], commands[i + 6]);
this._commandx = commands[i + 5];
this._commandy = commands[i + 6];
this._cache.tessellateBezier(
this._commands[i + 1], this._commands[i + 2],
this._commands[i + 3], this._commands[i + 4],
this._commands[i + 5], this._commands[i + 6], PointFlags.corner);
this._cache.closePath();
this._cache.pathWinding((PathWinding) this._commands[i + 1]);
D.assert(false, "unknown cmd: " + cmd);
D.assert(false, () => "unknown cmd: " + cmd);
this._commands.AddRange(commands);
this._cache.normalize();
return this._cache;
}
void _expandBounds(float x, float y) {
if (x < this._minX) {
this._minX = x;
}
if (y < this._minY) {
this._minY = y;
}
if (x > this._maxX) {
this._maxX = x;
}
if (y > this._maxY) {
this._maxY = y;
}
}
public Rect getBounds() {
if (this._minX >= this._maxX || this._minY >= this._maxY) {
return Rect.zero;
}
return Rect.fromLTRB(this._minX, this._minY, this._maxX, this._maxY);
}
void _appendMoveTo(float x, float y) {
this._commands.Add((float) PathCommand.moveTo);
this._commands.Add(x);
this._commands.Add(y);
this._commandx = x;
this._commandy = y;
this._cache = null;
}
void _appendLineTo(float x, float y) {
this._expandBounds(this._commandx, this._commandy);
this._expandBounds(x, y);
this._commands.Add((float) PathCommand.lineTo);
this._commands.Add(x);
this._commands.Add(y);
this._commandx = x;
this._commandy = y;
this._cache = null;
}
void _appendBezierTo(float x1, float y1, float x2, float y2, float x3, float y3) {
this._expandBounds(this._commandx, this._commandy);
this._expandBounds(x1, y1);
this._expandBounds(x2, y2);
this._expandBounds(x3, y3);
this._commands.Add((float) PathCommand.bezierTo);
this._commands.Add(x1);
this._commands.Add(y1);
this._commands.Add(x2);
this._commands.Add(y2);
this._commands.Add(x3);
this._commands.Add(y3);
this._commandx = x3;
this._commandy = y3;
this._cache = null;
}
void _appendClose() {
this._commands.Add((float) PathCommand.close);
this._cache = null;
}
void _appendWinding(float winding) {
this._commands.Add((float) PathCommand.winding);
this._commands.Add(winding);
this._cache = null;
}

this._appendCommands(new[] {
(float) PathCommand.moveTo,
x + x0, y + y0,
});
this._appendMoveTo(x + x0, y + y0);
this._appendCommands(new[] {
(float) PathCommand.moveTo,
x, y,
});
this._appendMoveTo(x, y);
this._appendCommands(new[] {
(float) PathCommand.lineTo,
x + x0, y + y0,
});
this._appendLineTo(x + x0, y + y0);
this._appendCommands(new[] {
(float) PathCommand.lineTo,
x, y,
});
this._appendLineTo(x, y);
this._appendCommands(new[] {
(float) PathCommand.bezierTo,
c1x, c1y, c2x, c2y, x, y,
});
this._appendBezierTo(c1x, c1y, c2x, c2y, x, y);
}
public void relativeCubicTo(float c1x, float c1y, float c2x, float c2y, float x, float y) {

var x0 = this._commandx;
var y0 = this._commandy;
this._appendCommands(new[] {
(float) PathCommand.bezierTo,
(x0 + 2.0f / 3.0f * (cx - x0)), (y0 + 2.0f / 3.0f * (cy - y0)),
(x + 2.0f / 3.0f * (cx - x)), (y + 2.0f / 3.0f * (cy - y)),
x, y,
});
const float twoThird = 2.0f / 3.0f;
this._appendBezierTo(
x0 + twoThird * (cx - x0), y0 + twoThird * (cy - y0),
x + twoThird * (cx - x), y + twoThird * (cy - y),
x, y);
public void relativeQuadraticBezierTo(float cx, float cy, float x, float y) {
var x0 = this._commandx;
var y0 = this._commandy;

startTheta = endTheta;
}
}
this._appendCommands(new[] {
(float) PathCommand.close,
});
this._appendClose();
this._appendCommands(new[] {
(float) PathCommand.winding,
(float) dir
});
this._appendWinding((float) dir);
this._appendCommands(new[] {
(float) PathCommand.moveTo, rect.left, rect.top,
(float) PathCommand.lineTo, rect.left, rect.bottom,
(float) PathCommand.lineTo, rect.right, rect.bottom,
(float) PathCommand.lineTo, rect.right, rect.top,
(float) PathCommand.close
});
this._appendMoveTo(rect.left, rect.top);
this._appendLineTo(rect.left, rect.bottom);
this._appendLineTo(rect.right, rect.bottom);
this._appendLineTo(rect.right, rect.top);
this._appendClose();
}
public void addRRect(RRect rrect) {

float x = rrect.left;
float y = rrect.top;
this._appendCommands(new[] {
(float) PathCommand.moveTo, x, y + ryTL,
(float) PathCommand.lineTo, x, y + h - ryBL,
(float) PathCommand.bezierTo, x, y + h - ryBL * (1 - _KAPPA90),
x + rxBL * (1 - _KAPPA90), y + h, x + rxBL, y + h,
(float) PathCommand.lineTo, x + w - rxBR, y + h,
(float) PathCommand.bezierTo, x + w - rxBR * (1 - _KAPPA90), y + h,
x + w, y + h - ryBR * (1 - _KAPPA90), x + w, y + h - ryBR,
(float) PathCommand.lineTo, x + w, y + ryTR,
(float) PathCommand.bezierTo, x + w, y + ryTR * (1 - _KAPPA90),
x + w - rxTR * (1 - _KAPPA90), y, x + w - rxTR, y,
(float) PathCommand.lineTo, x + rxTL, y,
(float) PathCommand.bezierTo, x + rxTL * (1 - _KAPPA90), y,
x, y + ryTL * (1 - _KAPPA90), x, y + ryTL,
(float) PathCommand.close,
});
this._appendMoveTo(x, y + ryTL);
this._appendLineTo(x, y + h - ryBL);
this._appendBezierTo(x, y + h - ryBL * (1 - _KAPPA90),
x + rxBL * (1 - _KAPPA90), y + h, x + rxBL, y + h);
this._appendLineTo(x + w - rxBR, y + h);
this._appendBezierTo(x + w - rxBR * (1 - _KAPPA90), y + h,
x + w, y + h - ryBR * (1 - _KAPPA90), x + w, y + h - ryBR);
this._appendLineTo(x + w, y + ryTR);
this._appendBezierTo(x + w, y + ryTR * (1 - _KAPPA90),
x + w - rxTR * (1 - _KAPPA90), y, x + w - rxTR, y);
this._appendLineTo(x + rxTL, y);
this._appendBezierTo(x + rxTL * (1 - _KAPPA90), y,
x, y + ryTL * (1 - _KAPPA90), x, y + ryTL);
this._appendClose();
this._appendCommands(new[] {
(float) PathCommand.moveTo, (cx - rx), cy,
(float) PathCommand.bezierTo, (cx - rx), (cy + ry * _KAPPA90),
(cx - rx * _KAPPA90), (cy + ry), cx, (cy + ry),
(float) PathCommand.bezierTo, (cx + rx * _KAPPA90), (cy + ry),
(cx + rx), (cy + ry * _KAPPA90), (cx + rx), cy,
(float) PathCommand.bezierTo, (cx + rx), (cy - ry * _KAPPA90),
(cx + rx * _KAPPA90), (cy - ry), cx, (cy - ry),
(float) PathCommand.bezierTo, (cx - rx * _KAPPA90), (cy - ry),
(cx - rx), (cy - ry * _KAPPA90), (cx - rx), cy,
(float) PathCommand.close,
});
this._appendMoveTo(cx - rx, cy);
this._appendBezierTo(cx - rx, cy + ry * _KAPPA90,
cx - rx * _KAPPA90, cy + ry, cx, cy + ry);
this._appendBezierTo(cx + rx * _KAPPA90, cy + ry,
cx + rx, cy + ry * _KAPPA90, cx + rx, cy);
this._appendBezierTo(cx + rx, cy - ry * _KAPPA90,
cx + rx * _KAPPA90, cy - ry, cx, cy - ry);
this._appendBezierTo(cx - rx * _KAPPA90, cy - ry,
cx - rx, cy - ry * _KAPPA90, cx - rx, cy);
this._appendClose();
}
public void addCircle(float cx, float cy, float r) {

var center = rect.center;
mat.postTranslate(center.dx, center.dy);
var vals = this._getArcCommands(0, 0, 1, startAngle, startAngle + sweepAngle,
sweepAngle >= 0 ? PathWinding.clockwise : PathWinding.counterClockwise, forceMoveTo);
this._transformCommands(vals, mat);
this._appendCommands(vals.ToArray());
this._addArcCommands(0, 0, 1, startAngle, startAngle + sweepAngle,
sweepAngle >= 0 ? PathWinding.clockwise : PathWinding.counterClockwise, forceMoveTo, mat);
}
public void addArc(Rect rect, float startAngle, float sweepAngle) {

public Path transform(Matrix3 mat) {
Path ret = new Path();
var i = 0;
while (i < this._commands.Count) {
var cmd = (PathCommand) this._commands[i];
switch (cmd) {
case PathCommand.moveTo:
var res_move = mat.mapXY(this._commands[i + 1], this._commands[i + 2]);
ret.moveTo(res_move.dx, res_move.dy);
i += 3;
break;
case PathCommand.lineTo:
var res_lineto = mat.mapXY(this._commands[i + 1], this._commands[i + 2]);
ret.lineTo(res_lineto.dx, res_lineto.dy);
i += 3;
break;
case PathCommand.bezierTo:
var res1 = mat.mapXY(this._commands[i + 1], this._commands[i + 2]);
var res2 = mat.mapXY(this._commands[i + 3], this._commands[i + 4]);
var res3 = mat.mapXY(this._commands[i + 5], this._commands[i + 6]);
ret.cubicTo(res1.dx, res1.dy, res2.dx, res2.dy, res3.dx, res3.dy);
i += 7;
break;
case PathCommand.close:
i++;
break;
case PathCommand.winding:
i += 2;
break;
default:
D.assert(false, "unknown cmd: " + cmd);
break;
}
}
return ret;
}
void _transformCommands(List<float> commands, Matrix3 mat) {
if (mat == null) {
return;
}
var i = 0;
while (i < commands.Count) {
var cmd = (PathCommand) commands[i];
switch (cmd) {
case PathCommand.moveTo:
case PathCommand.lineTo:
var res = mat.mapXY(commands[i + 1], commands[i + 2]);
commands[i + 1] = res.dx;
commands[i + 2] = res.dy;
i += 3;
break;
case PathCommand.bezierTo:
var res1 = mat.mapXY(commands[i + 1], commands[i + 2]);
commands[i + 1] = res1.dx;
commands[i + 2] = res1.dy;
var res2 = mat.mapXY(commands[i + 3], commands[i + 4]);
commands[i + 3] = res2.dx;
commands[i + 4] = res2.dy;
var res3 = mat.mapXY(commands[i + 5], commands[i + 6]);
commands[i + 5] = res3.dx;
commands[i + 6] = res3.dy;
i += 7;
break;
case PathCommand.close:
i++;
break;
case PathCommand.winding:
i += 2;
break;
default:
D.assert(false, "unknown cmd: " + cmd);
break;
}
}
}
List<float> _getArcCommands(float cx, float cy, float r, float a0, float a1, PathWinding dir, bool forceMoveTo) {
void _addArcCommands(
float cx, float cy, float r, float a0, float a1,
PathWinding dir, bool forceMoveTo, Matrix3 transform = null) {
// Clamp angles
float da = a1 - a0;
if (dir == PathWinding.clockwise) {

da += Mathf.PI * 2;
}
if (da <= 1e-5) {
return new List<float>();
return;
}
}
} else {

da -= Mathf.PI * 2;
}
if (da >= -1e-5) {
return new List<float>();
return;
// Split arc into max 90 degree segments.
int ndivs = Mathf.Max(1, Mathf.Min((int) (Mathf.Abs(da) / (Mathf.PI * 0.5f) + 0.5f), 5));
float hda = (da / ndivs) / 2.0f;

PathCommand move = (forceMoveTo || this._commands.Count == 0) ? PathCommand.moveTo : PathCommand.lineTo;
float px = 0, py = 0, ptanx = 0, ptany = 0;
List<float> vals = new List<float>();
for (int i = 0; i <= ndivs; i++) {
float a = a0 + da * (i / (float) ndivs);
float dx = Mathf.Cos(a);

float tany = dx * r * kappa;
if (i == 0) {
vals.Add((float) move);
vals.Add(x);
vals.Add(y);
float x1 = x, y1 = y;
if (transform != null) {
transform.mapXY(x1, y1, out x1, out y1);
}
if (move == PathCommand.moveTo) {
this._appendMoveTo(x1, y1);
} else {
this._appendLineTo(x1, y1);
}
vals.Add((float) PathCommand.bezierTo);
vals.Add(px + ptanx);
vals.Add(py + ptany);
vals.Add(x - tanx);
vals.Add(y - tany);
vals.Add(x);
vals.Add(y);
float c1x = px + ptanx;
float c1y = py + ptany;
float c2x = x - tanx;
float c2y = y - tany;
float x1 = x;
float y1 = y;
if (transform != null) {
transform.mapXY(c1x, c1y, out c1x, out c1y);
transform.mapXY(c2x, c2y, out c2x, out c2y);
transform.mapXY(x1, y1, out x1, out y1);
}
this._appendBezierTo(c1x, c1y, c2x, c2y, x1, y1);
}
px = x;
py = y;

return vals;
var vals = this._getArcCommands(cx, cy, r, a0, a1, dir, forceMoveTo);
this._appendCommands(vals.ToArray());
this._addArcCommands(cx, cy, r, a0, a1, dir, forceMoveTo);
}
public void addPolygon(IList<Offset> points, bool close) {

}
var commands = new List<float>();
commands.Add((float) PathCommand.moveTo);
commands.Add(points[0].dx);
commands.Add(points[0].dy);
this._appendMoveTo(points[0].dx, points[0].dy);
commands.Add((float) PathCommand.lineTo);
commands.Add(point.dx);
commands.Add(point.dy);
this._appendLineTo(point.dx, point.dy);
commands.Add((float) PathCommand.close);
this._appendClose();
this._appendCommands(commands.ToArray());
}
public Path shift(Offset offset) {

return path;
}
public Path transform(Matrix3 mat) {
var path = new Path();
path.addPath(this, mat);
return path;
}
D.assert(path != null);
D.assert(offset != null);
if (offset == null) {
this.addPath(path);
return;
}
var transform = Matrix3.makeTrans(offset.dx, offset.dy);
this.addPath(path, transform);
}
var commands = new List<float>();
public void addPath(Path path, Matrix3 transform = null) {
D.assert(path != null);
case PathCommand.moveTo:
case PathCommand.lineTo:
commands.Add(path._commands[i]);
commands.Add(path._commands[i + 1] + offset.dx);
commands.Add(path._commands[i + 2] + offset.dy);
case PathCommand.moveTo: {
float x = path._commands[i + 1];
float y = path._commands[i + 2];
if (transform != null) {
transform.mapXY(x, y, out x, out y);
}
this._appendMoveTo(x, y);
}
case PathCommand.bezierTo:
commands.Add(path._commands[i]);
commands.Add(path._commands[i + 1] + offset.dx);
commands.Add(path._commands[i + 2] + offset.dy);
commands.Add(path._commands[i + 3] + offset.dx);
commands.Add(path._commands[i + 4] + offset.dy);
commands.Add(path._commands[i + 5] + offset.dx);
commands.Add(path._commands[i + 6] + offset.dy);
case PathCommand.lineTo: {
float x = path._commands[i + 1];
float y = path._commands[i + 2];
if (transform != null) {
transform.mapXY(x, y, out x, out y);
}
this._appendLineTo(x, y);
}
i += 3;
break;
case PathCommand.bezierTo: {
float c1x = path._commands[i + 1];
float c1y = path._commands[i + 2];
float c2x = path._commands[i + 3];
float c2y = path._commands[i + 4];
float x1 = path._commands[i + 5];
float y1 = path._commands[i + 6];
if (transform != null) {
transform.mapXY(c1x, c1y, out c1x, out c1y);
transform.mapXY(c2x, c2y, out c2x, out c2y);
transform.mapXY(x1, y1, out x1, out y1);
}
this._appendBezierTo(c1x, c1y, c2x, c2y, x1, y1);
}
commands.Add(path._commands[i]);
this._appendClose();
commands.Add(path._commands[i]);
commands.Add(path._commands[i + 1]);
this._appendWinding(path._commands[i + 1]);
D.assert(false, "unknown cmd: " + cmd);
D.assert(false, () => "unknown cmd: " + cmd);
this._appendCommands(commands.ToArray());
if (bounds == null) {
if (bounds == null || bounds.isEmpty) {
return false;
}

i += 2;
break;
default:
D.assert(false, "unknown cmd: " + cmd);
D.assert(false, () => "unknown cmd: " + cmd);
break;
}
}

return 0;
}
D.assert(r >= 0 && r < 1, $"numer {numer}, denom {denom}, r {r}");
D.assert(r >= 0 && r < 1, () => $"numer {numer}, denom {denom}, r {r}");
if (r == 0) {
// catch underflow if numer <<<< denom
return 0;

1
Runtime/ui/painting/picture.cs


paint.strokeMiterLimit).transform(state.xform);
}
if (paint.maskFilter != null && paint.maskFilter.sigma != 0) {
float sigma = scale * paint.maskFilter.sigma;
float sigma3 = 3 * sigma;

4
Runtime/ui/painting/txt/font_manager.cs


FontRef fontRef = new FontRef(familyName, fontWeight, fontStyle);
D.assert(font != null);
D.assert(font.dynamic, $"adding font which is not dynamic is not allowed {font.name}");
D.assert(font.dynamic, () => $"adding font which is not dynamic is not allowed {font.name}");
D.assert(current == null || current.font == font, $"font with key {fontRef} already exists");
D.assert(current == null || current.font == font, () => $"font with key {fontRef} already exists");
var fontInfo = new FontInfo(font);
this._fonts[fontRef] = fontInfo;
}

6
Runtime/ui/window.cs


public static Window instance {
get {
D.assert(_instance != null,
"Window.instance is null. " +
() => "Window.instance is null. " +
"This usually happens when there is a callback from outside of UIWidgets. " +
"Try to use \"using (WindowProvider.of(BuildContext).getScope()) { ... }\" to wrap your code.");
return _instance;

if (value == null) {
D.assert(_instance != null, "Window.instance is already cleared.");
D.assert(_instance != null, () => "Window.instance is already cleared.");
D.assert(_instance == null, "Window.instance is already assigned.");
D.assert(_instance == null, () => "Window.instance is already assigned.");
_instance = value;
}
}

10
Runtime/widgets/app.cs


D.assert(
home == null ||
!this.routes.ContainsKey(Navigator.defaultRouteName),
"If the home property is specified, the routes table " +
() => "If the home property is specified, the routes table " +
"cannot include an entry for \" / \", since it would be redundant."
);

this.routes.ContainsKey(Navigator.defaultRouteName) ||
onGenerateRoute != null ||
onUnknownRoute != null,
"Either the home property must be specified, " +
() => "Either the home property must be specified, " +
"or the routes table must include an entry for \"/\", " +
"or there must be on onGenerateRoute callback specified, " +
"or there must be an onUnknownRoute callback specified, " +

builder != null ||
onGenerateRoute != null ||
pageRouteBuilder != null,
"If neither builder nor onGenerateRoute are provided, the " +
() => "If neither builder nor onGenerateRoute are provided, the " +
"pageRouteBuilder must be specified so that the default handler " +
"will know what kind of PageRoute transition to build."
);

if (pageContentBuilder != null) {
D.assert(this.widget.pageRouteBuilder != null,
"The default onGenerateRoute handler for WidgetsApp must have a " +
() => "The default onGenerateRoute handler for WidgetsApp must have a " +
"pageRouteBuilder set if the home or routes properties are set.");
var route = this.widget.pageRouteBuilder(
settings,

"The pageRouteBuilder for WidgetsApp must return a valid non-null Route.");
() => "The pageRouteBuilder for WidgetsApp must return a valid non-null Route.");
return route;
}

5
Runtime/widgets/automatic_keep_alive.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.scheduler;

public Ticker createTicker(TickerCallback onTick) {
this._tickers = this._tickers ?? new HashSet<Ticker>();
var debugLabel = "";
Func<string> debugLabel = null;
debugLabel = "created by " + this;
debugLabel = () => "created by " + this;
return true;
});
var result = new _AutomaticWidgetTicker<T>(onTick, this, debugLabel: debugLabel);

3
Runtime/widgets/binding.cs


protected override void handlePlatformBrightnessChanged() {
base.handlePlatformBrightnessChanged();
foreach (WidgetsBindingObserver observer in this._observers)
foreach (WidgetsBindingObserver observer in this._observers) {
}
}
protected virtual void handleLocaleChanged() {

2
Runtime/widgets/container.cs


D.assert(decoration == null || decoration.debugAssertIsValid());
D.assert(constraints == null || constraints.debugAssertIsValid());
D.assert(color == null || decoration == null,
"Cannot provide both a color and a decoration\n" +
() => "Cannot provide both a color and a decoration\n" +
"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"."
);

2
Runtime/widgets/dismissible.cs


internal _AutomaticWidgetTicker(
TickerCallback onTick,
AutomaticKeepAliveClientWithTickerProviderStateMixin<T> creator,
string debugLabel = null) :
Func<string> debugLabel = null) :
base(onTick: onTick, debugLabel: debugLabel) {
this._creator = creator;
}

23
Runtime/widgets/editable_text.cs


}
void _onFloatingCursorResetTick() {
Offset finalPosition = this.renderEditable.getLocalRectForCaret(this._lastTextPosition).centerLeft - this._floatingCursorOffset;
Offset finalPosition = this.renderEditable.getLocalRectForCaret(this._lastTextPosition).centerLeft -
this._floatingCursorOffset;
this.renderEditable.setFloatingCursor(FloatingCursorDragState.End, finalPosition, this._lastTextPosition);
if (this._lastTextPosition.offset != this.renderEditable.selection.baseOffset)
this._handleSelectionChanged(TextSelection.collapsed(offset: this._lastTextPosition.offset), this.renderEditable, SelectionChangedCause.forcePress);
this.renderEditable.setFloatingCursor(FloatingCursorDragState.End, finalPosition,
this._lastTextPosition);
if (this._lastTextPosition.offset != this.renderEditable.selection.baseOffset) {
this._handleSelectionChanged(TextSelection.collapsed(offset: this._lastTextPosition.offset),
this.renderEditable, SelectionChangedCause.forcePress);
}
this._startCaretRect = null;
this._lastTextPosition = null;
this._pointOffsetOrigin = null;

float lerpX = MathUtils.lerpFloat(this._lastBoundedOffset.dx, finalPosition.dx, lerpValue);
float lerpY = MathUtils.lerpFloat(this._lastBoundedOffset.dy, finalPosition.dy, lerpValue);
this.renderEditable.setFloatingCursor(FloatingCursorDragState.Update, new Offset(lerpX, lerpY), this._lastTextPosition, resetLerpValue: lerpValue);
this.renderEditable.setFloatingCursor(FloatingCursorDragState.Update, new Offset(lerpX, lerpY),
this._lastTextPosition, resetLerpValue: lerpValue);
}
}

public void requestKeyboard() {
if (this._hasFocus) {
this._openInputConnection();
}
else {
} else {
for (int i = ancestorScopes.Count - 1; i >= 1; i -= 1)
for (int i = ancestorScopes.Count - 1; i >= 1; i -= 1) {
}
FocusScope.of(this.context).requestFocus(this.widget.focusNode);
}
}

get {
TextDirection? result = this.widget.textDirection ?? Directionality.of(this.context);
D.assert(result != null,
$"{this.GetType().FullName} created without a textDirection and with no ambient Directionality.");
() => $"{this.GetType().FullName} created without a textDirection and with no ambient Directionality.");
return result;
}
}

4
Runtime/widgets/framework.cs


public override void deactivate() {
base.deactivate();
D.assert(!this.renderObject.attached,
"A RenderObject was still attached when attempting to deactivate its " +
() => "A RenderObject was still attached when attempting to deactivate its " +
"RenderObjectElement: " + this.renderObject);
}

"A RenderObject was still attached when attempting to unmount its " +
() => "A RenderObject was still attached when attempting to unmount its " +
"RenderObjectElement: " + this.renderObject);
this.widget.didUnmountRenderObject(this.renderObject);
}

4
Runtime/widgets/gesture_detector.cs


internal override bool _debugAssertTypeMatches(Type type) {
D.assert(type == typeof(T),
"GestureRecognizerFactory of type " + typeof(T) + " was used where type $type was specified.");
() => "GestureRecognizerFactory of type " + typeof(T) + " was used where type $type was specified.");
return true;
}
}

? oldRecognizers[type]
: gestures[type].constructorRaw();
D.assert(this._recognizers[type].GetType() == type,
"GestureRecognizerFactory of type " + type + " created a GestureRecognizer of type " +
() => "GestureRecognizerFactory of type " + type + " created a GestureRecognizer of type " +
this._recognizers[type].GetType() +
". The GestureRecognizerFactory must be specialized with the type of the class that it returns from its constructor method.");
gestures[type].initializerRaw(this._recognizers[type]);

2
Runtime/widgets/implicit_animations.cs


D.assert(decoration == null || decoration.debugAssertIsValid());
D.assert(constraints == null || constraints.debugAssertIsValid());
D.assert(color == null || decoration == null,
"Cannot provide both a color and a decoration\n" +
() => "Cannot provide both a color and a decoration\n" +
"The color argument is just a shorthand for \"decoration: new BoxDecoration(backgroundColor: color)\".");
this.alignment = alignment;
this.padding = padding;

4
Runtime/widgets/localizations.cs


return null;
}
D.assert((bool) (scope != null), "a Localizations ancestor was not found");
D.assert((bool) (scope != null), () => "a Localizations ancestor was not found");
return scope.localizationsState.locale;
}

(_LocalizationsScope) context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope));
D.assert(scope != null, "a Localizations ancestor was not found");
D.assert(scope != null, () => "a Localizations ancestor was not found");
return new List<LocalizationsDelegate>(scope.localizationsState.widget.delegates);
}

4
Runtime/widgets/page_view.cs


public float page {
get {
D.assert(this.positions.isNotEmpty(),
"PageController.page cannot be accessed before a PageView is built with it."
() => "PageController.page cannot be accessed before a PageView is built with it."
"The page property cannot be read when multiple PageViews are attached to " +
() => "The page property cannot be read when multiple PageViews are attached to " +
"the same PageController."
);
_PagePosition position = (_PagePosition) this.position;

36
Runtime/widgets/routes.cs


public virtual AnimationController createAnimationController() {
D.assert(this._transitionCompleter.CurState == PromiseState.Pending,
$"Cannot reuse a {this.GetType()} after disposing it.");
() => $"Cannot reuse a {this.GetType()} after disposing it.");
TimeSpan duration = this.transitionDuration;
D.assert(duration >= TimeSpan.Zero);
return new AnimationController(

public virtual Animation<float> createAnimation() {
D.assert(this._transitionCompleter.CurState == PromiseState.Pending,
$"Cannot reuse a {this.GetType()} after disposing it.");
() => $"Cannot reuse a {this.GetType()} after disposing it.");
D.assert(this._controller != null);
return this._controller.view;
}

readonly ProxyAnimation _secondaryAnimation = new ProxyAnimation(Animations.kAlwaysDismissedAnimation);
protected internal override void install(OverlayEntry insertionPoint) {
D.assert(!this._transitionCompleter.isCompleted, $"Cannot install a {this.GetType()} after disposing it.");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot install a {this.GetType()} after disposing it.");
D.assert(this._controller != null, $"{this.GetType()}.createAnimationController() returned null.");
D.assert(this._controller != null, () => $"{this.GetType()}.createAnimationController() returned null.");
D.assert(this._animation != null, $"{this.GetType()}.createAnimation() returned null.");
D.assert(this._animation != null, () => $"{this.GetType()}.createAnimation() returned null.");
$"{this.GetType()}.didPush called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, $"Cannot reuse a {this.GetType()} after disposing it.");
() => $"{this.GetType()}.didPush called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot reuse a {this.GetType()} after disposing it.");
this._animation.addStatusListener(this._handleStatusChanged);
return this._controller.forward();
}

$"{this.GetType()}.didReplace called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, $"Cannot reuse a {this.GetType()} after disposing it.");
() => $"{this.GetType()}.didReplace called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot reuse a {this.GetType()} after disposing it.");
if (oldRoute is TransitionRoute route) {
this._controller.setValue(route._controller.value);
}

protected internal override bool didPop(object result) {
D.assert(this._controller != null,
$"{this.GetType()}.didPop called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, $"Cannot reuse a {this.GetType()} after disposing it.");
() => $"{this.GetType()}.didPop called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot reuse a {this.GetType()} after disposing it.");
this._result = result;
this._controller.reverse();
return base.didPop(result);

D.assert(this._controller != null,
$"{this.GetType()}.didPopNext called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, $"Cannot reuse a {this.GetType()} after disposing it.");
() => $"{this.GetType()}.didPopNext called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot reuse a {this.GetType()} after disposing it.");
this._updateSecondaryAnimation(nextRoute);
base.didPopNext(nextRoute);
}

$"{this.GetType()}.didChangeNext called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, $"Cannot reuse a {this.GetType()} after disposing it.");
() => $"{this.GetType()}.didChangeNext called before calling install() or after calling dispose().");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot reuse a {this.GetType()} after disposing it.");
this._updateSecondaryAnimation(nextRoute);
base.didChangeNext(nextRoute);
}

}
protected internal override void dispose() {
D.assert(!this._transitionCompleter.isCompleted, $"Cannot dispose a {this.GetType()} twice.");
D.assert(!this._transitionCompleter.isCompleted, () => $"Cannot dispose a {this.GetType()} twice.");
this._controller?.dispose();
this._transitionCompleter.Resolve(this._result);
base.dispose();

public void addScopedWillPopCallback(WillPopCallback callback) {
D.assert(this._scopeKey.currentState != null,
"Tried to add a willPop callback to a route that is not currently in the tree.");
() => "Tried to add a willPop callback to a route that is not currently in the tree.");
"Tried to remove a willPop callback from a route that is not currently in the tree.");
() => "Tried to remove a willPop callback from a route that is not currently in the tree.");
this._willPopCallbacks.Remove(callback);
}

2
Runtime/widgets/scroll_activity.cs


D.assert(details != null);
D.assert(
motionStartDistanceThreshold == null || motionStartDistanceThreshold > 0.0,
"motionStartDistanceThreshold must be a positive number or null"
() => "motionStartDistanceThreshold must be a positive number or null"
);
this._del = del;

8
Runtime/widgets/scroll_controller.cs


public ScrollPosition position {
get {
D.assert(this._positions.isNotEmpty(), "ScrollController not attached to any scroll views.");
D.assert(this._positions.Count == 1, "ScrollController attached to multiple scroll views.");
D.assert(this._positions.isNotEmpty(), () => "ScrollController not attached to any scroll views.");
D.assert(this._positions.Count == 1, () => "ScrollController attached to multiple scroll views.");
return this._positions.Single();
}
}

TimeSpan duration,
Curve curve
) {
D.assert(this._positions.isNotEmpty(), "ScrollController not attached to any scroll views.");
D.assert(this._positions.isNotEmpty(), () => "ScrollController not attached to any scroll views.");
List<IPromise> animations = Enumerable.Repeat((IPromise) null, this._positions.Count).ToList();
for (int i = 0; i < this._positions.Count; i += 1) {
animations[i] = this._positions[i].animateTo(to, duration: duration, curve: curve);

}
public void jumpTo(float value) {
D.assert(this._positions.isNotEmpty(), "ScrollController not attached to any scroll views.");
D.assert(this._positions.isNotEmpty(), () => "ScrollController not attached to any scroll views.");
foreach (ScrollPosition position in new List<ScrollPosition>(this._positions)) {
position.jumpTo(value);
}

2
Runtime/widgets/scroll_position.cs


public override void correctBy(float correction) {
D.assert(
this._pixels != null,
"An initial pixels value must exist by caling correctPixels on the ScrollPosition"
() => "An initial pixels value must exist by caling correctPixels on the ScrollPosition"
);
this._pixels += correction;

2
Runtime/widgets/scroll_view.cs


DragStartBehavior dragStartBehavior = DragStartBehavior.down
) : base(key: key) {
D.assert(!(controller != null && primary == true),
"Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
() => "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
"You cannot both set primary to true and pass an explicit controller.");
D.assert(!shrinkWrap || center == null);
D.assert(anchor >= 0.0f && anchor <= 1.0f);

2
Runtime/widgets/single_child_scroll_view.cs


DragStartBehavior dragStartBehavior = DragStartBehavior.down
) : base(key: key) {
D.assert(!(controller != null && primary == true),
"Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
() => "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
"You cannot both set primary to true and pass an explicit controller.");
this.scrollDirection = scrollDirection;
this.reverse = reverse;

11
Runtime/widgets/ticker_provider.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.scheduler;

);
});
var debugLabel = "";
Func<string> debugLabel = null;
debugLabel = "created by " + this;
debugLabel = () => "created by " + this;
return true;
});
this._ticker = new Ticker(onTick, debugLabel: debugLabel);

public Ticker createTicker(TickerCallback onTick) {
this._tickers = this._tickers ?? new HashSet<Ticker>();
var debugLabel = "";
Func<string> debugLabel = null;
debugLabel = "created by " + this;
debugLabel = () => "created by " + this;
return true;
});
var result = new _WidgetTicker<T>(onTick, this, debugLabel: debugLabel);

internal _WidgetTicker(
TickerCallback onTick,
TickerProviderStateMixin<T> creator,
string debugLabel = null) :
Func<string> debugLabel = null) :
base(onTick: onTick, debugLabel: debugLabel) {
this._creator = creator;
}

6
Runtime/widgets/visibility.cs


) : base(key: key) {
D.assert(child != null);
D.assert(maintainState == true || maintainAnimation == false,
"Cannot maintain animations if the state is not also maintained.");
() => "Cannot maintain animations if the state is not also maintained.");
"Cannot maintain size if animations are not maintained.");
() => "Cannot maintain size if animations are not maintained.");
"Cannot maintain interactivity if size is not maintained.");
() => "Cannot maintain interactivity if size is not maintained.");
this.replacement = replacement ?? SizedBox.shrink();
this.child = child;
this.visible = visible;

68
Samples/UIWidgetSample/MaterialSample.cs


public class BottomAppBarWidget : StatelessWidget {
public BottomAppBarWidget(Key key = null) : base(key) {
}
public override Widget build(BuildContext context) {

mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget> {
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.menu), onPressed: () => { }),
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.account_balance), onPressed: () => { })
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.account_balance),
onPressed: () => { })
})));
}
}

}
}
public class MaterialButtonWidget : StatefulWidget {
public class MaterialButtonWidget : StatefulWidget {
public MaterialButtonWidget(Key key = null) : base(key) {
}

void onChanged(float value) {
this.setState(() => { this._value = value; });
}
children : new List<Widget> {
children: new List<Widget> {
)
)
internal class MaterialNavigationBarWidget : StatefulWidget
{
public MaterialNavigationBarWidget(Key key = null) : base(key)
{
class MaterialNavigationBarWidget : StatefulWidget {
public MaterialNavigationBarWidget(Key key = null) : base(key) {
public override State createState()
{
public override State createState() {
internal class MaterialNavigationBarWidgetState : SingleTickerProviderStateMixin<MaterialNavigationBarWidget> {
class MaterialNavigationBarWidgetState : SingleTickerProviderStateMixin<MaterialNavigationBarWidget> {
public MaterialNavigationBarWidgetState()
{
public MaterialNavigationBarWidgetState() {
public override Widget build(BuildContext context)
{
public override Widget build(BuildContext context) {
return new Scaffold(
bottomNavigationBar: new Container(
height: 100,

type: BottomNavigationBarType.shifting,
// type: BottomNavigationBarType.fix,
items: new List<BottomNavigationBarItem>
{
items: new List<BottomNavigationBarItem> {
new BottomNavigationBarItem(
icon: new Icon(icon: Unity.UIWidgets.material.Icons.work, size: 30),
title: new Text("Work"),

);
}
}
internal class MaterialReorderableListViewWidget : StatefulWidget
{
public MaterialReorderableListViewWidget(Key key = null) : base(key)
{
class MaterialReorderableListViewWidget : StatefulWidget {
public MaterialReorderableListViewWidget(Key key = null) : base(key) {
public override State createState()
{
public override State createState() {
internal class MaterialReorderableListViewWidgetState : State<MaterialReorderableListViewWidget>
{
private List<string> items = new List<string> {"First", "Second", "Third"};
class MaterialReorderableListViewWidgetState : State<MaterialReorderableListViewWidget> {
List<string> items = new List<string> {"First", "Second", "Third"};
public override Widget build(BuildContext context)
{
public override Widget build(BuildContext context) {
children: new List<Widget>
{
children: new List<Widget> {
new Scaffold(
body: new Scrollbar(
child: new ReorderableListView(

)
);
}).ToList(),
onReorder: (int oldIndex, int newIndex) =>
{
this.setState(() =>
{
if (newIndex > oldIndex) newIndex -= 1;
onReorder: (int oldIndex, int newIndex) => {
this.setState(() => {
if (newIndex > oldIndex) {
newIndex -= 1;
}
string item = this.items[oldIndex];
this.items.RemoveAt(oldIndex);
this.items.Insert(newIndex, item);

2
Samples/UIWidgetsGallery/gallery/demo.cs


public MaterialDemoDocumentationButton(string routeName, Key key = null) : base(key: key) {
this.documentationUrl = DemoUtils.kDemoDocumentationUrl[routeName];
D.assert(DemoUtils.kDemoDocumentationUrl[routeName] != null,
"A documentation URL was not specified for demo route $routeName in kAllGalleryDemos"
() => $"A documentation URL was not specified for demo route {routeName} in kAllGalleryDemos"
);
}

正在加载...
取消
保存