浏览代码

Merge pull request #55 from Unity-Technologies/siyaoH/1.17/painting

Siyao h/1.17/painting
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
4bb1845b
共有 124 个文件被更改,包括 5257 次插入3390 次删除
  1. 88
      com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
  2. 5
      com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
  3. 13
      com.unity.uiwidgets/Runtime/cupertino/app.cs
  4. 10
      com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs
  5. 16
      com.unity.uiwidgets/Runtime/cupertino/button.cs
  6. 30
      com.unity.uiwidgets/Runtime/cupertino/colors.cs
  7. 141
      com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
  8. 10
      com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs
  9. 12
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs
  10. 3
      com.unity.uiwidgets/Runtime/developer/extension.cs
  11. 30
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  12. 2
      com.unity.uiwidgets/Runtime/painting/inline_span.cs
  13. 2
      com.unity.uiwidgets/Runtime/painting/text_style.cs
  14. 5
      com.unity.uiwidgets/Runtime/rendering/binding.cs
  15. 377
      com.unity.uiwidgets/Runtime/rendering/box.cs
  16. 15
      com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs
  17. 28
      com.unity.uiwidgets/Runtime/rendering/box.mixin.njk
  18. 86
      com.unity.uiwidgets/Runtime/rendering/custom_layout.cs
  19. 35
      com.unity.uiwidgets/Runtime/rendering/custom_paint.cs
  20. 6
      com.unity.uiwidgets/Runtime/rendering/editable.cs
  21. 11
      com.unity.uiwidgets/Runtime/rendering/error.cs
  22. 14
      com.unity.uiwidgets/Runtime/rendering/flex.cs
  23. 8
      com.unity.uiwidgets/Runtime/rendering/image.cs
  24. 171
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  25. 6
      com.unity.uiwidgets/Runtime/rendering/list_body.cs
  26. 48
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  27. 6
      com.unity.uiwidgets/Runtime/rendering/lottie.cs
  28. 15
      com.unity.uiwidgets/Runtime/rendering/object.cs
  29. 155
      com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
  30. 211
      com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
  31. 6
      com.unity.uiwidgets/Runtime/rendering/paragraph.cs
  32. 6
      com.unity.uiwidgets/Runtime/rendering/performance_overlay.cs
  33. 124
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  34. 6
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs
  35. 41
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk
  36. 14
      com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
  37. 6
      com.unity.uiwidgets/Runtime/rendering/rotated_box.cs
  38. 30
      com.unity.uiwidgets/Runtime/rendering/shifted_box.cs
  39. 182
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  40. 126
      com.unity.uiwidgets/Runtime/rendering/sliver_fill.cs
  41. 2
      com.unity.uiwidgets/Runtime/rendering/sliver_grid.cs
  42. 16
      com.unity.uiwidgets/Runtime/rendering/sliver_list.cs
  43. 99
      com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs
  44. 409
      com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs
  45. 90
      com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs
  46. 35
      com.unity.uiwidgets/Runtime/rendering/stack.cs
  47. 6
      com.unity.uiwidgets/Runtime/rendering/table.cs
  48. 2
      com.unity.uiwidgets/Runtime/rendering/view.cs
  49. 16
      com.unity.uiwidgets/Runtime/rendering/viewport.cs
  50. 6
      com.unity.uiwidgets/Runtime/rendering/wrap.cs
  51. 42
      com.unity.uiwidgets/Runtime/ui2/compositing.cs
  52. 4
      com.unity.uiwidgets/Runtime/widgets/actions.cs
  53. 4
      com.unity.uiwidgets/Runtime/widgets/app.cs
  54. 16
      com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs
  55. 92
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  56. 50
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  57. 57
      com.unity.uiwidgets/Runtime/widgets/container.cs
  58. 53
      com.unity.uiwidgets/Runtime/widgets/debug.cs
  59. 14
      com.unity.uiwidgets/Runtime/widgets/dismissible.cs
  60. 16
      com.unity.uiwidgets/Runtime/widgets/drag_target.cs
  61. 446
      com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs
  62. 647
      com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
  63. 671
      com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs
  64. 9
      com.unity.uiwidgets/Runtime/widgets/form.cs
  65. 622
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  66. 47
      com.unity.uiwidgets/Runtime/widgets/gesture_detector.cs
  67. 129
      com.unity.uiwidgets/Runtime/widgets/heroes.cs
  68. 7
      com.unity.uiwidgets/Runtime/widgets/icon.cs
  69. 33
      com.unity.uiwidgets/Runtime/widgets/icon_data.cs
  70. 18
      com.unity.uiwidgets/Runtime/widgets/icon_theme.cs
  71. 7
      com.unity.uiwidgets/Runtime/widgets/icon_theme_data.cs
  72. 318
      com.unity.uiwidgets/Runtime/widgets/image.cs
  73. 101
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  74. 125
      com.unity.uiwidgets/Runtime/widgets/layout_builder.cs
  75. 33
      com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
  76. 21
      com.unity.uiwidgets/Runtime/widgets/localizations.cs
  77. 34
      com.unity.uiwidgets/Runtime/widgets/media_query.cs
  78. 98
      com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs
  79. 253
      com.unity.uiwidgets/Runtime/widgets/navigator.cs
  80. 51
      com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs
  81. 385
      com.unity.uiwidgets/Runtime/widgets/overlay.cs
  82. 6
      com.unity.uiwidgets/Runtime/widgets/overscroll_indicator.cs
  83. 2
      com.unity.uiwidgets/Runtime/widgets/page_storage.cs
  84. 65
      com.unity.uiwidgets/Runtime/widgets/page_view.cs
  85. 36
      com.unity.uiwidgets/Runtime/widgets/pages.cs
  86. 5
      com.unity.uiwidgets/Runtime/widgets/primary_scroll_controller.cs
  87. 4
      com.unity.uiwidgets/Runtime/widgets/route_notification_messages.cs
  88. 177
      com.unity.uiwidgets/Runtime/widgets/routes.cs
  89. 10
      com.unity.uiwidgets/Runtime/widgets/safe_area.cs
  90. 7
      com.unity.uiwidgets/Runtime/widgets/scroll_configuration.cs
  91. 9
      com.unity.uiwidgets/Runtime/widgets/scroll_metrics.cs
  92. 6
      com.unity.uiwidgets/Runtime/widgets/scroll_notification.mixin.njk
  93. 29
      com.unity.uiwidgets/Runtime/widgets/scroll_physics.cs
  94. 40
      com.unity.uiwidgets/Runtime/widgets/scroll_position.cs
  95. 91
      com.unity.uiwidgets/Runtime/widgets/scroll_view.cs
  96. 182
      com.unity.uiwidgets/Runtime/widgets/scrollable.cs
  97. 289
      com.unity.uiwidgets/Runtime/widgets/scrollbar.cs
  98. 6
      com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
  99. 6
      com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs
  100. 493
      com.unity.uiwidgets/Runtime/widgets/sliver.cs

88
com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs


}
return new Container(
color: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context),//CupertinoActionSheetUtils._kBackgroundColor,
color: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context),
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,

contentSection: new Builder(builder: _buildContent),
actionsSection: _buildActions()
)
/*new Container(
decoration: CupertinoActionSheetUtils._kAlertBlurOverlayDecoration,
child: new _CupertinoAlertRenderWidget(
contentSection: _buildContent(),
actionsSection: _buildActions()
)
)*/
)
)
),

actionSheetWidth = MediaQuery.of(context).size.height -
(CupertinoActionSheetUtils._kEdgeHorizontalPadding * 2);
}
/// tbc semantics
/*return new SafeArea(
child: new Semantics(
namesRoute: true,
scopesRoute: true,
explicitChildNodes: true,
label: "Alert",
child: new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevated,
child: new Container(
width: actionSheetWidth,
margin: EdgeInsets.symmetric(
horizontal: CupertinoActionSheetUtils._kEdgeHorizontalPadding,
vertical: CupertinoActionSheetUtils._kEdgeVerticalPadding
),
child: new Column(
children: children,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch
)
)
)
)
);*/
child: new Container(
width: actionSheetWidth,
margin: EdgeInsets.symmetric(
horizontal: CupertinoActionSheetUtils._kEdgeHorizontalPadding,
vertical: CupertinoActionSheetUtils._kEdgeVerticalPadding
),
child: new Column(
children: children,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch
)
child: new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevatedlayer,
child: new Container(
width: actionSheetWidth,
margin: EdgeInsets.symmetric(
horizontal: CupertinoActionSheetUtils._kEdgeHorizontalPadding,
vertical: CupertinoActionSheetUtils._kEdgeVerticalPadding
),
child: new Column(
children: children,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch
))
}
}

color: isDestructiveAction
? CupertinoDynamicColor.resolve(CupertinoColors.systemRed, context)
: CupertinoTheme.of(context).primaryColor);
//CupertinoActionSheetUtils._kActionSheetActionStyle;
if (isDefaultAction) {
style = style.copyWith(fontWeight: FontWeight.w600);
}

constraints: new BoxConstraints(
minHeight: CupertinoActionSheetUtils._kButtonHeight
),
////tbc semantics
child: new Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(

}
public override void updateRenderObject(BuildContext context,RenderObject renderObject ) {
//RenderObject renderObject
renderObject = (_RenderCupertinoAlert) renderObject;
base.updateRenderObject(context, renderObject);
((_RenderCupertinoAlert) renderObject).dividerColor = CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context);

return value;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
float contentHeight = contentSection.getMinIntrinsicHeight(width);
float actionsHeight = actionsSection.getMinIntrinsicHeight(width);
bool hasDivider = contentHeight > 0.0f && actionsHeight > 0.0f;

}
protected override void performLayout() {
BoxConstraints constraints = this.constraints;
bool hasDivider = contentSection.getMaxIntrinsicHeight(constraints.maxWidth) > 0.0f
&& actionsSection.getMaxIntrinsicHeight(constraints.maxWidth) > 0.0f;
float dividerThickness = hasDivider ? _dividerThickness : 0.0f;

hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - contentSectionParentData.offset);
return contentSection.hitTest(resultIn, position: transformed);
}
) || result.addWithPaintOffset(
}) || result.addWithPaintOffset(
offset: actionsSectionParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {

class _ActionButtonParentDataWidget : ParentDataWidget<_ActionButtonParentData> {
public _ActionButtonParentDataWidget(
Widget child,
Key key = null,
Key key = null
Widget child = null
) : base(key: key, child: child) {
this.isPressed = isPressed;
}

if (parentData.isPressed != isPressed) {
parentData.isPressed = isPressed;
AbstractNodeMixinDiagnosticableTree targetParent = renderObject.parent;
// AbstractNode targetParent = renderObject.parent;
// tbc
if (targetParent is RenderObject) {
((RenderObject) targetParent).markNeedsPaint();
}

public new Type debugTypicalAncestorWidgetClass {
public override Type debugTypicalAncestorWidgetClass {
get {
return typeof(_CupertinoAlertActionsRenderWidget);
}

}
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (childCount == 0) {
return 0.0f;
}

5
com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs


}
class _CupertinoActivityIndicatorPainter : AbstractCustomPainter
{//CustomPainter {
//AbstractCustomPainter {
{
float radius =0f
float radius = 0f
) : base(repaint: position) {
tickFundamentalRRect = RRect.fromLTRBXY(

13
com.unity.uiwidgets/Runtime/cupertino/app.cs


Dictionary<string, WidgetBuilder> routes = null,
string initialRoute = null,
RouteFactory onGenerateRoute = null,
InitialRouteListFactory onGenerateInitialRoutes = null,
RouteFactory onUnknownRoute = null,
List<NavigatorObserver> navigatorObservers = null,
TransitionBuilder builder = null,

bool checkerboardOffscreenLayers = false,
bool showSemanticsDebugger = false,
bool debugShowCheckedModeBanner = true,
// tbc????
supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")};
this.navigatorKey = navigatorKey;
this.home = home;

this.onGenerateRoute = onGenerateRoute;
this.onGenerateInitialRoutes = onGenerateInitialRoutes;
this.onUnknownRoute = onUnknownRoute;
this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.builder = builder;

this.localeResolutionCallback = localeResolutionCallback;
this.supportedLocales = supportedLocales;
this.showPerformanceOverlay = showPerformanceOverlay;
this.showSemanticsDebugger = showSemanticsDebugger;
this.debugShowCheckedModeBanner = debugShowCheckedModeBanner;
this.shortcuts = shortcuts;
this.actions = actions;
}

public readonly bool checkerboardRasterCacheImages;
public readonly bool checkerboardOffscreenLayers;
public readonly bool showSemanticsDebugger;
public readonly bool debugShowWidgetInspector;
//TBC ????
public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
public readonly Dictionary<LocalKey, ActionFactory> actions;

);
},
shortcuts: widget.shortcuts,
);
);
}
)
)

10
com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs


this.border = border ?? new Border(
top: new BorderSide(
color: BottomAppBarUtils._kDefaultTabBarBorderColor,
width: 0.0f, // One physical pixel.
width: 0.0f,
style: BorderStyle.solid
)
);

Color inactive = CupertinoDynamicColor.resolve(inactiveColor, context);
Widget result = new DecoratedBox(
decoration: new BoxDecoration(
border: resolvedBorder,//border,
color: backgroundColor //?? CupertinoTheme.of(context).barBackgroundColor
border: resolvedBorder,
color: backgroundColor
),
child: new SizedBox(
height: BottomAppBarUtils._kTabBarHeight + bottomPadding,

),
child: new DefaultTextStyle( // Default with the inactive state.
style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(color: inactive),
//CupertinoTheme.of(context).textTheme.tabLabelTextStyle
child: new Padding(
padding: EdgeInsets.only(bottom: bottomPadding),
child: new Row(

_wrapActiveItem(
context,
new Expanded(
//// ??? semantics tbc ???
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap == null ? null : (GestureTapCallback) (() => { onTap(tabIndex); }),

if (!active) {
return item;
}
//Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor;
Color activeColor = CupertinoDynamicColor.resolve(
this.activeColor ?? CupertinoTheme.of(context).primaryColor,
context

16
com.unity.uiwidgets/Runtime/cupertino/button.cs


BorderRadius borderRadius = null,
VoidCallback onPressed = null
) : base(key: key) {
D.assert((pressedOpacity >= 0.0 && pressedOpacity <= 1.0) || pressedOpacity == null );
//D.assert(disabledColor != null);
_filled = false;
D.assert((pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
_filled = false;
this.child = child;
this.onPressed = onPressed;
this.padding = padding;

VoidCallback onPressed = null
) {
disabledColor = disabledColor ?? CupertinoColors.quaternarySystemFill;
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
D.assert(disabledColor != null);
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
var btn = new CupertinoButton(
key: key,
color: null,

_animate();
}
});
/*ticker.then(() => {
if (mounted && wasHeldDown != _buttonHeldDown) {
_animate();
}
});*/
}
public override Widget build(BuildContext context) {

widget.onPressed();
}
},
////tbc semantics
child: new ConstrainedBox(
constraints: widget.minSize == null
? new BoxConstraints() :

30
com.unity.uiwidgets/Runtime/cupertino/colors.cs


);
}
public class CupertinoDynamicColor : Color { //, Diagnosticable {
public class CupertinoDynamicColor : DiagnosticableMixinColor {
public CupertinoDynamicColor(
string debugLabel = null,
Color effectiveColor = null,

Color highContrastElevatedColor = null,
Color darkHighContrastElevatedColor = null,
Element debugResolveContext = null
): base(0)
): base(0)
{
D.assert(color != null,()=>"color8 == null");
D.assert(darkColor != null,()=>"color7 == null");

D.assert(darkElevatedColor != null,()=>"color3 == null");
D.assert(highContrastElevatedColor != null,()=>"color2 == null");
D.assert(darkHighContrastElevatedColor != null,()=>"color1 == null");
//D.assert(effectiveColor != null);
_effectiveColor = effectiveColor ?? color;
this.color = color;

this.darkHighContrastElevatedColor = darkHighContrastElevatedColor;
_debugResolveContext = debugResolveContext;
_debugLabel = debugLabel;
base.value = _effectiveColor.value;
//base(_effectiveColor.value);
}

}
public readonly Color _effectiveColor;
public uint value {
public new uint value {
get {
return _effectiveColor.value;
}

return toString();
}
public string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
/*string toString(string name, Color color) {
public override string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
string toStringColor(string name, Color color) {
}*/
}
List<string> xs = new List<string>();
xs.Add(toStringColor("color",color));
if (_isPlatformBrightnessDependent)

}
public string toStringColor(string name, Color color) {
string marker = color == _effectiveColor ? "*" : "";
return marker + name + " = " + color.ToString() + marker;
}
public new void debugFillProperties(DiagnosticPropertiesBuilder properties) {
//base.debugFillProperties(properties);
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_debugLabel != null)
properties.add(new MessageProperty("debugLabel", _debugLabel));
properties.add(createCupertinoColorProperty("color", color));

}
public static DiagnosticsProperty<Color> createCupertinoColorProperty(
string name = null,
Color value = null,
string name ,
Color value ,
bool showName = true,
object defaultValue = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,

141
com.unity.uiwidgets/Runtime/cupertino/context_menu.cs


public class _CupertinoContextMenuState : TickerProviderStateMixin<CupertinoContextMenu> {
public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey<State<StatefulWidget>>();
//GlobalKey();//GlobalKey();
static readonly TimeSpan kLongPressTimeout = new TimeSpan(0, 0, 0, 0, 500);
public readonly GlobalKey _childGlobalKey = GlobalKey<State<StatefulWidget>>.key();
static readonly TimeSpan kLongPressTimeout = TimeSpan.FromMilliseconds(500);//new TimeSpan(0, 0, 0, 0, 500);
public bool _childHidden = false;
public AnimationController _openController;
public Rect _decoyChildEndRect;

),
contextMenuLocation: _contextMenuLocation,
previousChildRect: _decoyChildEndRect,
builder: (BuildContext context, Animation< float> animation)=>{
builder: (BuildContext _context, Animation<float> animation)=>{
return widget.previewBuilder(context, animation, widget.child);
return widget.previewBuilder(_context, animation, widget.child);
}
);
Navigator.of(context, rootNavigator: true).push(_route);

public void _onDecoyAnimationStatusChange(AnimationStatus animationStatus) {
switch (animationStatus) {
case AnimationStatus.dismissed:
if (_route == null) {
setState(()=> {
_childHidden = false;
});
}
_lastOverlayEntry?.remove();
_lastOverlayEntry = null;
break;
case AnimationStatus.completed:
setState(()=>{
_childHidden = true;
});
_openContextMenu();
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timestamp) =>{
_lastOverlayEntry?.remove();
_lastOverlayEntry = null;
_openController.reset();
});
break;
default:
return;
}
public void _onDecoyAnimationStatusChange(AnimationStatus animationStatus) {
switch (animationStatus) {
case AnimationStatus.dismissed:
if (_route == null) {
setState(()=> {
_childHidden = false;
});
}
_lastOverlayEntry?.remove();
_lastOverlayEntry = null;
break;
case AnimationStatus.completed:
setState(()=>{
_childHidden = true;
});
_openContextMenu();
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timestamp) =>{
_lastOverlayEntry?.remove();
_lastOverlayEntry = null;
_openController.reset();
});
break;
default:
return;
}
}

public static readonly Color _lightModeMaskColor = new Color(0xFF888888);
public static readonly Color _masklessColor = new Color(0xFFFFFFFF);
public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey<State<StatefulWidget>>();
public readonly GlobalKey _childGlobalKey = GlobalKey<State<StatefulWidget>>.key();
public override void initState() {
base.initState();
_mask = new _OnOffAnimation<Color>(
controller: widget.controller,
onValue: _lightModeMaskColor,
offValue: _masklessColor,
intervalOn: 0.0f,
intervalOff: 0.5f
);
Rect midRect = widget.beginRect.deflate(
widget.beginRect.width * (CupertinoContextMenuUtils._kOpenScale - 1.0f) / 2f
);
List<TweenSequenceItem<Rect>> tweenSequenceItems = new List<TweenSequenceItem<Rect>>();
tweenSequenceItems.Add(
new TweenSequenceItem<Rect>(
tween: new RectTween(
begin: widget.beginRect,
end: midRect
public override void initState() {
base.initState();
_mask = new _OnOffAnimation<Color>(
controller: widget.controller,
onValue: _lightModeMaskColor,
offValue: _masklessColor,
intervalOn: 0.0f,
intervalOff: 0.5f
);
Rect midRect = widget.beginRect.deflate(
widget.beginRect.width * (CupertinoContextMenuUtils._kOpenScale - 1.0f) / 2f
);
List<TweenSequenceItem<Rect>> tweenSequenceItems = new List<TweenSequenceItem<Rect>>();
tweenSequenceItems.Add(
new TweenSequenceItem<Rect>(
tween: new RectTween(
begin: widget.beginRect,
end: midRect
).chain(new CurveTween(curve: Curves.easeInOutCubic)),
weight: 1.0f
));

if (widget.controller.value < 0.5f) {
return;
}
//HapticFeedback.selectionClick();????
//HapticFeedback.selectionClick();????
/// tbc ???
_rect.removeListener(_rectListener);
}

}
public Widget _buildAnimation(BuildContext context, Widget child) {
Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
List<Color> colors = new List<Color>();
colors.Add(color);
colors.Add(color);
return Positioned.fromRect(
rect: _rect.value,
child: //kIsweb?
new Container(key: _childGlobalKey, child: widget.child)
/*: new ShaderMask(
key: _childGlobalKey,
shaderCallback: (Rect bounds) => {
return new LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: colors
).createShader(bounds);
},
child: widget.child
)*/
);
public Widget _buildAnimation(BuildContext context, Widget child) {
Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
List<Color> colors = new List<Color>();
colors.Add(color);
colors.Add(color);
return Positioned.fromRect(
rect: _rect.value,
child: foundation_.kIsWeb
? (Widget) new Container(key: _childGlobalKey, child: widget.child)
: new ShaderMask(
key: _childGlobalKey,
shaderCallback: (Rect bounds) => {
return new LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: colors).createShader(bounds);
},
child: widget.child
)
);
}
public override Widget build(BuildContext context) {
List<Widget> widgets = new List<Widget>();

10
com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs


IconData trailingIcon = null
) : base(key: key) {
D.assert(child != null);
D.assert(isDefaultAction != null);
D.assert(isDestructiveAction != null);
this.child = child;
this.isDefaultAction = isDefaultAction;
this.isDestructiveAction = isDestructiveAction;

color: CupertinoColors.black,
textBaseline: TextBaseline.alphabetic
);
public GlobalKey _globalKey = new LabeledGlobalKey<State<StatefulWidget>>();
//GlobalKey();
public GlobalKey _globalKey = GlobalKey<State<StatefulWidget>>.key();
bool _isPressed = false;
void onTapDown(TapDownDetails details) {

onTapDown: onTapDown,
onTapUp: onTapUp,
onTapCancel: onTapCancel,
onTap: //widget.onPressed,
widget.onPressed == null
onTap: widget.onPressed == null
? (GestureTapCallback) null
: () => {
if (widget.onPressed != null) {

behavior: HitTestBehavior.opaque,
child: /////semantics tbc ???
child:
new ConstrainedBox(
constraints: new BoxConstraints(
minHeight: _kButtonHeight

12
com.unity.uiwidgets/Runtime/cupertino/dialog.cs


return value;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
float contentHeight = contentSection.getMinIntrinsicHeight(width);
float actionsHeight = actionsSection.getMinIntrinsicHeight(width);
bool hasDivider = contentHeight > 0.0f && actionsHeight > 0.0f;

}
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
float minHeight;
if (childCount == 0) {
minHeight = 0.0f;

3
com.unity.uiwidgets/Runtime/developer/extension.cs


using System.Collections;
using System.Collections.Generic;
public static partial class developer_ {
public static class developer_ {
public static void postEvent(string eventKind, Hashtable eventData) {
}
}

30
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs


}
}
class DiagnosticableTreeNode : DiagnosticableNode<DiagnosticableTree> {
class DiagnosticableTreeNode : DiagnosticableNode<DiagnosticableTreeMixin> {
DiagnosticableTree value,
DiagnosticableTreeMixin value,
DiagnosticsTreeStyle style
) : base(
name: name,

}
public override List<DiagnosticsNode> getChildren() {
if (value != null) {

public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) {
}
}
public abstract class DiagnosticableTree : Diagnosticable {
public interface DiagnosticableTreeMixin : IDiagnosticable{
string toString(DiagnosticLevel minLevel = DiagnosticLevel.info);
string toStringShallow(
string joiner = ", ",
DiagnosticLevel minLevel = DiagnosticLevel.debug
);
string toStringDeep(
string prefixLineOne = "",
string prefixOtherLines = null,
DiagnosticLevel minLevel = DiagnosticLevel.debug);
string toStringShort();
DiagnosticsNode toDiagnosticsNode(string name = null, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse);
List<DiagnosticsNode> debugDescribeChildren();
void debugFillProperties(DiagnosticPropertiesBuilder properties);
}
public abstract class DiagnosticableTree : Diagnosticable,DiagnosticableTreeMixin {
protected DiagnosticableTree() {
}

2
com.unity.uiwidgets/Runtime/painting/inline_span.cs


public override string ToString() =>
$"{foundation_.objectRuntimeType(this, "InlineSpanSemanticsInformation")}" +
$"{text: $text, semanticsLabel: $semanticsLabel, recognizer: $recognizer}";
"text: " + text + " , semanticsLabel: "+ semanticsLabel + " , recognizer: " + recognizer;
public bool Equals(InlineSpanSemanticsInformation other) {
if (ReferenceEquals(null, other)) {

2
com.unity.uiwidgets/Runtime/painting/text_style.cs


return new TextStyle(
inherit: inherit ?? this.inherit,
color: this.foreground == null && foreground == null ? color ?? this.color : null,
backgroundColor: this.background == null && background == null ? color ?? this.color : null,
backgroundColor: this.background == null && background == null ? color ?? this.backgroundColor : null,
fontFamily: fontFamily ?? this.fontFamily,
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
fontSize: fontSize ?? this.fontSize,

5
com.unity.uiwidgets/Runtime/rendering/binding.cs


instance = this;
_pipelineOwner = new PipelineOwner(
onNeedVisualUpdate: ensureVisualUpdate
// onSemanticsOwnerCreated: _handleSemanticsOwnerCreated,
// onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed,
// ..onSemanticsEnabledChanged = _handleSemanticsEnabledChanged
// ..onSemanticsAction = _handleSemanticsAction;
// _handleSemanticsEnabledChanged();
D.assert(renderView != null);
addPersistentFrameCallback(_handlePersistentFrameCallback);
initMouseTracker();

377
com.unity.uiwidgets/Runtime/rendering/box.cs


float maxWidth = float.PositiveInfinity,
float minHeight = 0.0f,
float maxHeight = float.PositiveInfinity) {
D.assert(minWidth != null);
D.assert(maxWidth != null);
D.assert(minHeight != null);
D.assert (maxHeight != null);
this.minWidth = minWidth;
this.maxWidth = maxWidth;
this.minHeight = minHeight;

public float getMinIntrinsicWidth(float height) {
D.assert(() => {
if (height < 0.0) {
throw new UIWidgetsError(
"The height argument to getMinIntrinsicWidth was negative.\n" +
"The argument to getMinIntrinsicWidth must not be negative. " +
"If you perform computations on another height before passing it to " +
"getMinIntrinsicWidth, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary("The height argument to getMinIntrinsicWidth was negative."),
new ErrorDescription("The argument to getMinIntrinsicWidth must not be negative or null."),
new ErrorHint(
"If you perform computations on another height before passing it to " +
"getMinIntrinsicWidth, consider using math.max() or double.clamp() " +
"to force the value into the valid range."
)
}
);
}

return _computeIntrinsicDimension(_IntrinsicDimension.minWidth, height, computeMinIntrinsicWidth);
}
protected virtual float computeMinIntrinsicWidth(float height) {
protected internal virtual float computeMinIntrinsicWidth(float height) {
return 0.0f;
}

throw new UIWidgetsError(
"The height argument to getMaxIntrinsicWidth was negative.\n" +
"The argument to getMaxIntrinsicWidth must not be negative. " +
"If you perform computations on another height before passing it to " +
"getMaxIntrinsicWidth, consider using Mathf.Max() or float.clamp() " +
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("The height argument to getMaxIntrinsicWidth was negative."),
new ErrorDescription("The argument to getMaxIntrinsicWidth must not be negative or null."),
new ErrorHint(
"If you perform computations on another height before passing it to " +
"getMaxIntrinsicWidth, consider using math.max() or double.clamp() " +
);
)
});
return true;
});

protected virtual float computeMaxIntrinsicWidth(float height) {
protected internal virtual float computeMaxIntrinsicWidth(float height) {
return 0.0f;
}

throw new UIWidgetsError(
"The width argument to getMinIntrinsicHeight was negative.\n" +
"The argument to getMinIntrinsicHeight must not be negative. " +
"If you perform computations on another width before passing it to " +
"getMinIntrinsicHeight, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
);
throw new UIWidgetsError( new List<DiagnosticsNode>(){
new ErrorSummary("The width argument to getMinIntrinsicHeight was negative."),
new ErrorDescription("The argument to getMinIntrinsicHeight must not be negative or null."),
new ErrorHint(
"If you perform computations on another width before passing it to " +
"getMinIntrinsicHeight, consider using math.max() or double.clamp() " +
"to force the value into the valid range."
)
});
}
return true;

computeMinIntrinsicHeight);
}
protected virtual float computeMinIntrinsicHeight(float width) {
protected internal virtual float computeMinIntrinsicHeight(float width) {
return 0.0f;
}

throw new UIWidgetsError(
"The width argument to getMaxIntrinsicHeight was negative.\n" +
"The argument to getMaxIntrinsicHeight must not be negative. " +
"If you perform computations on another width before passing it to " +
"getMaxIntrinsicHeight, consider using Mathf.Max() or float.clamp() " +
"to force the value into the valid range."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("The width argument to getMaxIntrinsicHeight was negative."),
new ErrorDescription("The argument to getMaxIntrinsicHeight must not be negative or null."),
new ErrorHint(
"If you perform computations on another width before passing it to " +
"getMaxIntrinsicHeight, consider using math.max() or double.clamp() " +
"to force the value into the valid range."
)
});
}
return true;

get {
D.assert(hasSize, () => "RenderBox was not laid out: " + this);
D.assert(() => {
if (this._size is _DebugSize) {
_DebugSize _size = (_DebugSize) this._size;
D.assert(_size._owner == this);
Size _size = this._size;
if (_size is _DebugSize) {
D.assert(((_DebugSize)_size)._owner == this);
(debugActiveLayout == parent && _size._canBeUsedByParent));
(debugActiveLayout == parent && ((_DebugSize)_size)._canBeUsedByParent));
}
D.assert(_size == this._size);

}
D.assert(!debugDoingThisResize);
string contract = "", violation = "", hint = "";
List<DiagnosticsNode> information = new List<DiagnosticsNode>{
new ErrorSummary("RenderBox size setter called incorrectly.")
};
violation = "It appears that the size setter was called from performLayout().";
hint = "";
information.Add(new ErrorDescription("It appears that the size setter was called from performLayout()."));
violation =
"The size setter was called from outside layout (neither performResize() nor performLayout() were being run for this object).";
information.Add(new ErrorDescription(
"The size setter was called from outside layout (neither performResize() nor performLayout() were being run for this object)."
));
hint =
"Only the object itself can set its size. It is a contract violation for other objects to set it.";
information.Add(new ErrorDescription("Only the object itself can set its size. It is a contract violation for other objects to set it."));
contract =
"Because this RenderBox has sizedByParent set to true, it must set its size in performResize().";
information.Add(new ErrorDescription("Because this RenderBox has sizedByParent set to true, it must set its size in performResize()."));
contract =
"Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().";
information.Add(new ErrorDescription("Because this RenderBox has sizedByParent set to false, it must set its size in performLayout()."));
throw new UIWidgetsError(
"RenderBox size setter called incorrectly.\n" +
violation + "\n" +
hint + "\n" +
contract + "\n" +
"The RenderBox in question is:\n" +
" " + this
);
throw new UIWidgetsError(information);
});
D.assert(() => {
value = debugAdoptSize(value);

var value = (_DebugSize) valueRaw;
if (value._owner != this) {
if (value._owner.parent != this) {
throw new UIWidgetsError(
"The size property was assigned a size inappropriately.\n" +
"The following render object:\n" +
" " + this + "\n" +
"...was assigned a size obtained from:\n" +
" " + value._owner + "\n" +
"However, this second render object is not, or is no longer, a " +
"child of the first, and it is therefore a violation of the " +
"RenderBox layout protocol to use that size in the layout of the " +
"first render object.\n" +
"If the size was obtained at a time where it was valid to read " +
"the size (because the second render object above was a child " +
"of the first at the time), then it should be adopted using " +
"debugAdoptSize at that time.\n" +
"If the size comes from a grandchild or a render object from an " +
"entirely different part of the render tree, then there is no " +
"way to be notified when the size changes and therefore attempts " +
"to read that size are almost certainly a source of bugs. A different " +
"approach should be used."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("The size property was assigned a size inappropriately."),
describeForError("The following render object"),
value._owner.describeForError("...was assigned a size obtained from"),
new ErrorDescription(
"However, this second render object is not, or is no longer, a " +
"child of the first, and it is therefore a violation of the " +
"RenderBox layout protocol to use that size in the layout of the " +
"first render object."
),
new ErrorHint(
"If the size was obtained at a time where it was valid to read " +
"the size (because the second render object above was a child " +
"of the first at the time), then it should be adopted using " +
"debugAdoptSize at that time."
),
new ErrorHint(
"If the size comes from a grandchild or a render object from an " +
"entirely different part of the render tree, then there is no " +
"way to be notified when the size changes and therefore attempts " +
"to read that size are almost certainly a source of bugs. A different " +
"approach should be used."
)
});
throw new UIWidgetsError(
"A child\"s size was used without setting parentUsesSize.\n" +
"The following render object:\n" +
" " + this + "\n" +
"...was assigned a size obtained from its child:\n" +
" " + value._owner + "\n" +
"However, when the child was laid out, the parentUsesSize argument " +
"was not set or set to false. Subsequently this transpired to be " +
"inaccurate: the size was nonetheless used by the parent.\n" +
"It is important to tell the framework if the size will be used or not " +
"as several important performance optimizations can be made if the " +
"size will not be used by the parent."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("A child's size was used without setting parentUsesSize."),
describeForError("The following render object"),
value._owner.describeForError("...was assigned a size obtained from its child"),
new ErrorDescription(
"However, when the child was laid out, the parentUsesSize argument " +
"was not set or set to false. Subsequently this transpired to be " +
"inaccurate: the size was nonetheless used by the parent.\n" +
"It is important to tell the framework if the size will be used or not " +
"as several important performance optimizations can be made if the " +
"size will not be used by the parent."
)
});
}
}
}

D.assert(() => {
if (!hasSize) {
D.assert(!debugNeedsLayout);
string contract = "";
DiagnosticsNode contract;
contract =
"Because this RenderBox has sizedByParent set to true, it must set its size in performResize().\n";
contract = new ErrorDescription("Because this RenderBox has sizedByParent set to true, it must set its size in performResize().");
contract =
"Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().\n";
contract = new ErrorDescription("Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().");
throw new UIWidgetsError(
"RenderBox did not set its size during layout.\n" +
contract +
"It appears that this did not happen; layout completed, but the size property is still null.\n" +
"The RenderBox in question is:\n" +
" " + this);
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary("RenderBox did not set its size during layout."),
contract,
new ErrorDescription(
"It appears that this did not happen; layout completed, but the size property is still null."),
new DiagnosticsProperty<RenderBox>("The RenderBox in question is", this,
style: DiagnosticsTreeStyle.errorProperty),
});
var information = new StringBuilder();
List<DiagnosticsNode> information = new List<DiagnosticsNode>{
new ErrorSummary("${runtimeType} object was given an infinite size during layout."),
new ErrorDescription(
"This probably means that it is a render object that tries to be " +
"as big as possible, but it was put inside another render object " +
"that allows its children to pick their own size."
)
};
information.Add(node.describeForError("The nearest ancestor providing an unbounded width constraint is"));
information.AppendLine("The nearest ancestor providing an unbounded width constraint is:");
information.Append(" ");
information.AppendLine(node.toStringShallow(joiner: "\n "));
}
if (!constraints.hasBoundedHeight) {

information.Add(node.describeForError("The nearest ancestor providing an unbounded height constraint is"));
information.AppendLine("The nearest ancestor providing an unbounded height constraint is:");
information.Append(" ");
information.AppendLine(node.toStringShallow(joiner: "\n "));
throw new UIWidgetsError(
GetType() + " object was given an infinite size during layout.\n" +
"This probably means that it is a render object that tries to be " +
"as big as possible, but it was put inside another render object " +
"that allows its children to pick their own size.\n" +
information +
"The constraints that applied to the " + GetType() + " were:\n" +
" " + constraints + "\n" +
"The exact size it was given was:\n" +
" " + _size
);
information.Add(new DiagnosticsProperty<BoxConstraints>("The constraints that applied to the ${runtimeType} were", constraints, style: DiagnosticsTreeStyle.errorProperty));
information.Add(new DiagnosticsProperty<Size>("The exact size it was given was", _size, style: DiagnosticsTreeStyle.errorProperty));
information.Add(new ErrorHint("See https://flutter.dev/docs/development/ui/layout/box-constraints for more information."));
throw new UIWidgetsError(information);
throw new UIWidgetsError(
GetType() + " does not meet its constraints.\n" +
"Constraints: " + constraints + "\n" +
"Size: " + _size + "\n" +
"If you are not writing your own RenderBox subclass, then this is not " +
"your fault."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("${runtimeType} does not meet its constraints."),
new DiagnosticsProperty<BoxConstraints>("Constraints", constraints, style: DiagnosticsTreeStyle.errorProperty),
new DiagnosticsProperty<Size>("Size", _size, style: DiagnosticsTreeStyle.errorProperty),
new ErrorHint(
"If you are not writing your own RenderBox subclass, then this is not " +
"your fault. Contact support: https://github.com/flutter/flutter/issues/new?template=BUG.md"
)
});
var failures = new StringBuilder();
int failureCount = 0;
List<DiagnosticsNode> failures = new List<DiagnosticsNode>();
failures.AppendLine(" * " + name + "(" + constraint + ") returned a negative value: " +
result);
failureCount += 1;
failures.Add(new ErrorDescription($" * {name}({constraint}) returned a negative value: {result}"));
failures.AppendLine(" * " + name + "(" + constraint +
") returned a non-finite value: " + result);
failureCount += 1;
failures.Add(new ErrorDescription($" * {name}({constraint}) returned a non-finite value: {result}"));
}
return result;

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 (" +
min +
") than getMaxIntrinsic" + name + "(" + constraint + ") (" + max + ")");
failureCount += 1;
failures.Add(new ErrorDescription($" * getMinIntrinsic{name}({constraint}) returned a larger value ({min}) than getMaxIntrinsic{name}({constraint}) ({max})"));
}
});

}
debugCheckingIntrinsics = false;
if (failures.Length > 0) {
D.assert(failureCount > 0);
throw new UIWidgetsError(
"The intrinsic dimension methods of the " + GetType() +
" class returned values that violate the intrinsic protocol contract.\n" +
"The following failures was detected:\n" +
failures +
if (failures.Count > 0) {
failures.Add(new ErrorSummary("The intrinsic dimension methods of the $runtimeType class returned values that violate the intrinsic protocol contract."));
failures.Add(new ErrorDescription("The following failure(s) was detected:"));
failures.Add(new ErrorHint(
"your fault."
);
"your fault. Contact support: https://github.com/flutter/flutter/issues/new?template=BUG.md"
));
throw new UIWidgetsError(failures);
}
}

protected override void performLayout() {
D.assert(() => {
if (!sizedByParent) {
throw new UIWidgetsError(
GetType() + " did not implement performLayout().\n" +
"RenderBox subclasses need to either override performLayout() to " +
"set a size and lay out any children, or, set sizedByParent to true " +
"so that performResize() sizes the render object."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("$runtimeType did not implement performLayout()."),
new ErrorHint(
"RenderBox subclasses need to either override performLayout() to " +
"set a size and lay out any children, or, set sizedByParent to true " +
"so that performResize() sizes the render object."
)
});
}
return true;

D.assert(() => {
if (!hasSize) {
if (debugNeedsLayout) {
throw new UIWidgetsError(
"Cannot hit test a render box that has never been laid out.\n" +
"The hitTest() method was called on this RenderBox:\n" +
" " + this + "\n" +
"Unfortunately, this object\"s geometry is not known at this time, " +
"probably because it has never been laid out. " +
"This means it cannot be accurately hit-tested. If you are trying " +
"to perform a hit test during the layout phase itself, make sure " +
"you only hit test nodes that have completed layout (e.g. the node\"s " +
"children, after their layout() method has been called)."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Cannot hit test a render box that has never been laid out."),
describeForError("The hitTest() method was called on this RenderBox"),
new ErrorDescription(
"Unfortunately, this object's geometry is not known at this time, " +
"probably because it has never been laid out. " +
"This means it cannot be accurately hit-tested."
),
new ErrorHint(
"If you are trying " +
"to perform a hit test during the layout phase itself, make sure " +
"you only hit test nodes that have completed layout (e.g. the node's " +
"children, after their layout() method has been called)."
)
});
throw new UIWidgetsError(
"Cannot hit test a render box with no size.\n" +
"The hitTest() method was called on this RenderBox:\n" +
" " + this + "\n" +
"Although this node is not marked as needing layout, " +
"its size is not set. A RenderBox object must have an " +
"explicit size before it can be hit-tested. Make sure " +
"that the RenderBox in question sets its size during layout."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Cannot hit test a render box with no size."),
describeForError("The hitTest() method was called on this RenderBox"),
new ErrorDescription(
"Although this node is not marked as needing layout, " +
"its size is not set."
),
new ErrorHint(
"A RenderBox object must have an " +
"explicit size before it can be hit-tested. Make sure " +
"that the RenderBox in question sets its size during layout."
)
});
}
return true;

D.assert(child.parent == this);
D.assert(() => {
if (!(child.parentData is BoxParentData)) {
throw new UIWidgetsError(
GetType() + " does not implement applyPaintTransform.\n" +
"The following " + GetType() + " object:\n" +
" " + toStringShallow() + "\n" +
"...did not use a BoxParentData class for the parentData field of the following child:\n" +
" " + child.toStringShallow() + "\n" +
"The " + GetType() + " class inherits from RenderBox. " +
"The default applyPaintTransform implementation provided by RenderBox assumes that the " +
"children all use BoxParentData objects for their parentData field. " +
"Since " + GetType() +
" does not in fact use that ParentData class for its children, it must " +
"provide an implementation of applyPaintTransform that supports the specific ParentData " +
"subclass used by its children (which apparently is " + child.parentData.GetType() + ")."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary($"{GetType()} does not implement applyPaintTransform."),
describeForError($"The following {GetType()} object"),
child.describeForError("...did not use a BoxParentData class for the parentData field of the following child"),
new ErrorDescription($"The {GetType()} class inherits from RenderBox."),
new ErrorHint(
"The default applyPaintTransform implementation provided by RenderBox assumes that the " +
"children all use BoxParentData objects for their parentData field. " +
$"Since {GetType()} does not in fact use that ParentData class for its children, it must " +
"provide an implementation of applyPaintTransform that supports the specific ParentData " +
$"subclass used by its children (which apparently is {child.parentData.GetType()})."
),
});
}
return true;

15
com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.rendering {

}
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin4
ChildType child = lastChild;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;

hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
if (isHit)
if (isHit)
}
}
return false;
}

28
com.unity.uiwidgets/Runtime/rendering/box.mixin.njk


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

where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public float? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? result = child.getDistanceToActualBaseline(baseline);

public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
float? result = null;
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? candidate = child.getDistanceToActualBaseline(baseline);

}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);

public bool defaultHitTestChildren(HitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
while (child != null)
{
ParentDataType childParentData = (ParentDataType) child.parentData;
if (child.hitTest(result, position: position - childParentData.offset)) {
return true;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
);
if (isHit)
return true;
}
return false;
}

86
com.unity.uiwidgets/Runtime/rendering/custom_layout.cs


}
public abstract class MultiChildLayoutDelegate {
protected MultiChildLayoutDelegate(Listenable relayout = null) {
_relayout = relayout;
}
public readonly Listenable _relayout;
Dictionary<object, RenderBox> _idToChild;
HashSet<RenderBox> _debugChildrenNeedingLayout;

D.assert(constraints.debugAssertIsValid(isAppliedConstraint: true));
}
catch (AssertionError exception) {
throw new UIWidgetsError(
$"The {this} custom multichild layout delegate provided invalid box constraints for the child with id \"{childId}\".\n" +
$"{exception}n" +
"The minimum width and height must be greater than or equal to zero.\n" +
"The maximum width must be greater than or equal to the minimum width.\n" +
"The maximum height must be greater than or equal to the minimum height.");
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary(
$"The $this custom multichild layout delegate provided invalid box constraints for the child with id {childId}."),
new DiagnosticsProperty<AssertionError>("Exception", exception, showName: false),
new ErrorDescription(
"The minimum width and height must be greater than or equal to zero.\n" +
"The maximum width must be greater than or equal to the minimum width.\n" +
"The maximum height must be greater than or equal to the minimum height."
)
});
}
return true;

childParentData.offset = offset;
}
string _debugDescribeChild(RenderBox child) {
DiagnosticsNode _debugDescribeChild(RenderBox child) {
return $"{childParentData.id}: {child}";
return new DiagnosticsProperty<RenderBox>($"{childParentData.id}", child);
}

MultiChildLayoutParentData childParentData = (MultiChildLayoutParentData) child.parentData;
D.assert(() => {
if (childParentData.id == null) {
throw new UIWidgetsError(
"The following child has no ID:\n" +
$" {child}\n" +
"Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data."),
child.describeForError("The following child has no ID")
});
}
return true;

performLayout(size);
D.assert(() => {
List<DiagnosticsNode> renderBoxes = new List<DiagnosticsNode>();
foreach (var renderBox in _debugChildrenNeedingLayout) {
renderBoxes.Add(_debugDescribeChild(renderBox));
}
if (_debugChildrenNeedingLayout.Count > 1) {
throw new UIWidgetsError(
$"The $this custom multichild layout delegate forgot to lay out the following children:\n" +
$" {string.Join("\n ", _debugChildrenNeedingLayout.Select(_debugDescribeChild))}\n" +
"Each child must be laid out exactly once."
);
}
else {
throw new UIWidgetsError(
$"The $this custom multichild layout delegate forgot to lay out the following child:\n" +
$" {_debugDescribeChild(_debugChildrenNeedingLayout.First())}\n" +
"Each child must be laid out exactly once."
);
}
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Each child must be laid out exactly once."),
new DiagnosticsBlock(
name: "The $this custom multichild layout delegate forgot " +
"to lay out the following child(ren)",
properties: renderBoxes,
style: DiagnosticsTreeStyle.whitespace
)
});
}
return true;

if (_delegate == value) {
return;
}
if (value.GetType() != _delegate.GetType() || value.shouldRelayout(_delegate)) {
MultiChildLayoutDelegate oldDelegate = _delegate;
if (value.GetType() != oldDelegate.GetType() || value.shouldRelayout(oldDelegate)) {
if (attached) {
oldDelegate?._relayout?.removeListener(markNeedsLayout);
value?._relayout?.addListener(markNeedsLayout);
}
/*public override void attach(PipelineOwner owner) {
base.attach(owner);
_delegate?._relayout?.addListener(markNeedsLayout);
}
public override void detach() {
_delegate?._relayout?.removeListener(markNeedsLayout);
base.detach();
}*/
Size _getSize(BoxConstraints constraints) {
D.assert(constraints.debugAssertIsValid());

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

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

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

defaultPaint(context, offset);
}
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return defaultHitTestChildren(result, position: position);
}
}

35
com.unity.uiwidgets/Runtime/rendering/custom_paint.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;

base.detach();
}
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (_foregroundPainter != null && ((_foregroundPainter.hitTest(position)) ?? false)) {
return true;
}

D.assert(() => {
int debugNewCanvasSaveCount = canvas.getSaveCount();
if (debugNewCanvasSaveCount > debugPreviousCanvasSaveCount) {
throw new UIWidgetsError(
$"{debugNewCanvasSaveCount - debugPreviousCanvasSaveCount} more " +
$"time{((debugNewCanvasSaveCount - debugPreviousCanvasSaveCount == 1) ? "" : "s")} " +
"than it called canvas.restore().\n" +
"This leaves the canvas in an inconsistent state and will probably result in a broken display.\n" +
"You must pair each call to save()/saveLayer() with a later matching call to restore()."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary(
$"The {painter} custom painter called canvas.save() or canvas.saveLayer() at least " +
$"{debugNewCanvasSaveCount - debugPreviousCanvasSaveCount} more " +
"times than it called canvas.restore()."
),
new ErrorDescription("This leaves the canvas in an inconsistent state and will probably result in a broken display."),
new ErrorHint("You must pair each call to save()/saveLayer() with a later matching call to restore().")
});
throw new UIWidgetsError(
$"The {painter} custom painter called canvas.restore() " +
$"{debugPreviousCanvasSaveCount - debugNewCanvasSaveCount} more " +
$"time{(debugPreviousCanvasSaveCount - debugNewCanvasSaveCount == 1 ? "" : "s")} " +
"than it called canvas.save() or canvas.saveLayer().\n" +
"This leaves the canvas in an inconsistent state and will result in a broken display.\n" +
"You should only call restore() if you first called save() or saveLayer()."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary($"The {painter} custom painter called canvas.restore() " +
$"{debugPreviousCanvasSaveCount - debugNewCanvasSaveCount} more " +
"times than it called canvas.save() or canvas.saveLayer()."
),
new ErrorDescription("This leaves the canvas in an inconsistent state and will result in a broken display."),
new ErrorHint("You should only call restore() if you first called save() or saveLayer().")
});
}
return debugNewCanvasSaveCount == debugPreviousCanvasSaveCount;

6
com.unity.uiwidgets/Runtime/rendering/editable.cs


return rect.shift(_getPixelPerfectCursorOffset(rect));
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
_layoutText(float.PositiveInfinity);
return _textPainter.maxIntrinsicWidth + cursorWidth;
}

return Mathf.Max(preferredLineHeight, _textPainter.height);
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return _preferredHeight(width);
}

11
com.unity.uiwidgets/Runtime/rendering/error.cs


}
public class RenderErrorBox : RenderBox {
const string _kLine = "\n\n────────────────────\n\n";
protected override bool sizedByParent
{

ParagraphBuilder builder = new ParagraphBuilder(paragraphStyle);
builder.pushStyle(textStyle);
builder.addText(
$"{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}{message}{_kLine}"
);
builder.addText(message);
_paragraph = builder.build();
}

protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
return rendering_._kMaxWidth;
}

/*protected override bool sizedByParent {
get => true;
}*/
protected override bool hitTestSelf(Offset position) => true;

14
com.unity.uiwidgets/Runtime/rendering/flex.cs


public TextBaseline _textBaseline;
public float _overflow;
bool _hasOverflow {
get {
return _overflow > foundation_.precisionErrorTolerance;
}
}
public override void setupParentData(RenderObject child) {
if (!(child.parentData is FlexParentData)) {

}
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
return _getIntrinsicSize(
sizingDirection: Axis.horizontal,
extent: height,

protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
return _getIntrinsicSize(
sizingDirection: Axis.horizontal,
extent: height,

protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return _getIntrinsicSize(
sizingDirection: Axis.vertical,
extent: width,

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

8
com.unity.uiwidgets/Runtime/rendering/image.cs


));
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
D.assert(height >= 0.0);
if (_width == null && _height == null) {
return 0.0f;

}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
D.assert(width >= 0.0);
if (_width == null && _height == null) {
return 0.0f;

properties.add(new FloatProperty("width", width, defaultValue: foundation_.kNullDefaultValue));
properties.add(new FloatProperty("height", height, defaultValue: foundation_.kNullDefaultValue));
properties.add(new FloatProperty("scale", scale, defaultValue: 1.0f));
properties.add(new DiagnosticsProperty<Color>("color", color,
properties.add(new ColorProperty("color", color,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new EnumProperty<BlendMode>("colorBlendMode", colorBlendMode,
defaultValue: foundation_.kNullDefaultValue));

171
com.unity.uiwidgets/Runtime/rendering/layer.cs


using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
using Shader = Unity.UIWidgets.ui.Shader;
namespace Unity.UIWidgets.rendering {
public class AnnotationEntry<T> {

}
}
internal bool _subtreeNeedsAddToScene;
protected EngineLayer engineLayer {
get { return _engineLayer; }
set {

}
}
}
EngineLayer _engineLayer;
protected EngineLayer _engineLayer;
internal virtual void updateSubtreeNeedsAddToScene() {
_needsAddToScene = _needsAddToScene || alwaysNeedsAddToScene;

findAnnotations<S>(result, localPosition, onlyFirst: true);
return result.entries.Count() == 0 ? default : result.entries.First().annotation;
}
/*
@Deprecated(
'Use findAllAnnotations(...).annotations instead. '
'This feature was deprecated after v1.10.14.'
)
Iterable<S> findAll<S>(Offset localPosition) {
final AnnotationResult<S> result = findAllAnnotations(localPosition);
return result.entries.map((AnnotationEntry<S> entry) => entry.annotation);
}*/
AnnotationResult<S> findAllAnnotations<S>(Offset localPosition) {
AnnotationResult<S> result = new AnnotationResult<S>();
findAnnotations<S>(result, localPosition, onlyFirst: false);

}
public class PictureLayer : Layer {
public PictureLayer(Rect canvasBounds) {

return children;
}
}
public class ShaderMaskLayer : ContainerLayer {
public ShaderMaskLayer(
Shader shader = null,
Rect maskRect = null,
BlendMode blendMode = BlendMode.clear
) {
_shader = shader;
_maskRect = maskRect;
_blendMode = blendMode;
}
public Shader shader {
get {
return _shader;
}
set{
if (value != _shader) {
_shader = value;
markNeedsAddToScene();
}
}
}
Shader _shader;
public Rect maskRect {
get { return _maskRect; }
set {
if (value != _maskRect) {
_maskRect = value;
markNeedsAddToScene();
}
}
}
Rect _maskRect;
public BlendMode blendMode {
get { return _blendMode; }
set {
if (value != _blendMode) {
_blendMode = value;
markNeedsAddToScene();
}
}
}
BlendMode _blendMode;
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
D.assert(shader != null);
D.assert(maskRect != null);
D.assert(blendMode != null);
D.assert(layerOffset != null);
Rect shiftedMaskRect = layerOffset == Offset.zero ? maskRect : maskRect.shift(layerOffset);
engineLayer = builder.pushShaderMask(
shader,
shiftedMaskRect,
blendMode,
oldLayer: _engineLayer as ui.ShaderMaskEngineLayer
);
addChildrenToScene(builder, layerOffset);
builder.pop();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Shader>("shader", shader));
properties.add(new DiagnosticsProperty<Rect>("maskRect", maskRect));
properties.add(new DiagnosticsProperty<BlendMode>("blendMode", blendMode));
}
}
public class OffsetLayer : ContainerLayer {
public OffsetLayer(Offset offset = null) {

properties.add(new DiagnosticsProperty<Clip>("clipBehavior", clipBehavior));
}
}
public class ColorFilterLayer : ContainerLayer {
public ColorFilterLayer(ColorFilter colorFilter = null) {
_colorFilter = colorFilter;
}
public ColorFilter colorFilter {
get {
return _colorFilter;
}
set {
D.assert(value != null);
if (value != _colorFilter) {
_colorFilter = value;
markNeedsAddToScene();
}
}
}
ColorFilter _colorFilter;
//[!!!]builder.pushColorFilter?
/*public override void addToScene(ui.SceneBuilder builder, Offset layerOffset = null ) {
D.assert(colorFilter != null);
engineLayer = builder.pushColorFilter(
colorFilter,
oldLayer: _engineLayer as ui.ColorFilterEngineLayer
);
addChildrenToScene(builder, layerOffset);
builder.pop();
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ColorFilter>("colorFilter", colorFilter));
}
}
public class ImageFilterLayer : ContainerLayer {
public ImageFilterLayer(
ui.ImageFilter imageFilter
) {
_imageFilter = imageFilter;
}
public ui.ImageFilter imageFilter {
get {
return _imageFilter;
}
set {
D.assert(value != null);
if (value != _imageFilter) {
_imageFilter = value;
markNeedsAddToScene();
}
}
}
ui.ImageFilter _imageFilter;
//[!!!] builder.pushImageFilter?
/*public override void addToScene(ui.SceneBuilder builder, Offset layerOffset = null) {
D.assert(imageFilter != null);
engineLayer = builder.pushImageFilter(
imageFilter,
oldLayer: _engineLayer as ui.ImageFilterEngineLayer
);
addChildrenToScene(builder, layerOffset);
builder.pop();
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ui.ImageFilter>("imageFilter", imageFilter));
}
}
public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix4 transform = null, Offset offset = null) : base(offset) {
_transform = transform ?? Matrix4.identity();

6
com.unity.uiwidgets/Runtime/rendering/list_body.cs


}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
switch (mainAxis) {
case Axis.horizontal:
return _getIntrinsicMainAxis((RenderBox child) => child.getMinIntrinsicWidth(height));

}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
switch (mainAxis) {
case Axis.horizontal:
return _getIntrinsicMainAxis((RenderBox child) => child.getMaxIntrinsicWidth(height));

}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
switch (mainAxis) {
case Axis.horizontal:
return _getIntrinsicMainAxis((RenderBox child) => child.getMinIntrinsicHeight(width));

48
com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs


float offAxisFraction = 0.0f,
bool useMagnifier = false,
float magnification = 1.0f,
float overAndUnderCenterOpacity = 1.0f,
float squeeze = 1.0f,
bool clipToSize = true,
bool renderChildrenOutsideViewport = false,
List<RenderBox> children = null

D.assert(perspective > 0);
D.assert(perspective <= 0.01f, () => perspectiveTooHighMessage);
D.assert(magnification > 0);
D.assert(overAndUnderCenterOpacity != null);
D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
D.assert(squeeze != null);
D.assert(squeeze > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,
() => clipToSizeAndRenderChildrenOutsideViewportConflict

_offAxisFraction = offAxisFraction;
_useMagnifier = useMagnifier;
_magnification = magnification;
_overAndUnderCenterOpacity = overAndUnderCenterOpacity;
_squeeze = squeeze;
_clipToSize = clipToSize;
_renderChildrenOutsideViewport = renderChildrenOutsideViewport;
addAll(children);

float _magnification = 1.0f;
public float overAndUnderCenterOpacity {
get {
return _overAndUnderCenterOpacity;
}
set {
D.assert(value != null);
D.assert(value >= 0 && value <= 1);
if (value == _overAndUnderCenterOpacity)
return;
_overAndUnderCenterOpacity = value;
markNeedsPaint();
}
}
float _overAndUnderCenterOpacity = 1.0f;
public float itemExtent {
get { return _itemExtent; }
set {

}
float _itemExtent;
public float squeeze {
get {
return _squeeze;
}
set {
D.assert(value != null);
D.assert(value > 0);
if (value == _squeeze)
return;
_squeeze = value;
markNeedsLayout();
}
}
float _squeeze;
public bool clipToSize {
get { return _clipToSize; }

return extent;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (childManager.childCount == null) {
return 0.0f;
}

6
com.unity.uiwidgets/Runtime/rendering/lottie.cs


return constraints.smallest;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
D.assert(height >= 0.0);
if (_width == null && _height == null) {
return 0.0f;

}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
D.assert(width >= 0.0);
if (_width == null && _height == null) {
return 0.0f;

15
com.unity.uiwidgets/Runtime/rendering/object.cs


return
$"{GetType()}#{GetHashCode()}(layer: {_containerLayer}, canvas bounds: {estimatedBounds}";
}
public ColorFilterLayer pushColorFilter(Offset offset, ColorFilter colorFilter, PaintingContextCallback painter, ColorFilterLayer oldLayer = null) {
D.assert(colorFilter != null);
ColorFilterLayer layer = oldLayer ?? new ColorFilterLayer();
layer.colorFilter = colorFilter;
pushLayer(layer, painter, offset);
return layer;
}
}
public abstract class Constraints {

D.assert(!isRepaintBoundary || (_layer == null || _layer is OffsetLayer));
return _layer;
}
set {
D.assert(!isRepaintBoundary);
_layer = value;
}
}
public void setLayer(ContainerLayer newLayer) {

);
}
}
protected DiagnosticsNode describeForError(String name, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow) {
public DiagnosticsNode describeForError(String name, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow) {
return toDiagnosticsNode(name: name, style: style);
}
}

155
com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
public virtual bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public virtual bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

public abstract class RenderObjectWithChildMixinRenderSliver<ChildType> : RenderSliver, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public bool debugValidateChild(RenderObject child) {
public virtual bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

public ChildType nextSibling { get; set; }
public void detach() {
public override void detach() {
base.detach();
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
() => "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, ()=>"A RenderObject cannot be inserted into itself.");
D.assert(after != this,()=>
"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 != _firstChild);
D.assert(child != _lastChild);

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
() => "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, ()=>"A RenderObject cannot be inserted into itself.");
D.assert(after != this,()=>
"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 != _firstChild);
D.assert(child != _lastChild);

get { return _childCount; }
}
public override bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

}
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 != _firstChild);
D.assert(child != _lastChild);

}
}
public abstract class RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, ChildType> : RenderObjectWithChildMixinRenderObject<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
where ConstraintType : Constraints
where ChildType : RenderObject {
public LayoutCallback<ConstraintType> _callback { get; set; }
public void updateCallback(LayoutCallback<ConstraintType> value) {
if (value == _callback)
return;
_callback = value;
markNeedsLayout();
}
public void layoutAndBuildChild() {
D.assert(_callback != null);
invokeLayoutCallback(_callback);
}
}
public class RenderConstrainedLayoutBuilderMixinRenderBox<ConstraintType, ChildType> : RenderObjectWithChildMixinRenderBox<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
where ConstraintType : BoxConstraints
where ChildType : RenderBox {
public LayoutCallback<ConstraintType> _callback { get; set; }
public void updateCallback(LayoutCallback<ConstraintType> value) {
if (value == _callback)
return;
_callback = value;
markNeedsLayout();
}
public void layoutAndBuildChild() {
D.assert(_callback != null);
invokeLayoutCallback(_callback);
}
}
public abstract class RenderConstrainedLayoutBuilderMixinRenderSliver<ConstraintType, ChildType> : RenderObjectWithChildMixinRenderSliver<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
where ConstraintType : SliverConstraints
where ChildType : RenderSliver {
public LayoutCallback<ConstraintType> _callback { get; set; }
public void updateCallback(LayoutCallback<ConstraintType> value) {
if (value == _callback)
return;
_callback = value;
markNeedsLayout();
}
public void layoutAndBuildChild() {
D.assert(_callback != null);
invokeLayoutCallback(_callback);
}
}
}

211
com.unity.uiwidgets/Runtime/rendering/object.mixin.njk


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
public bool debugValidateChild(RenderObject child) {
public virtual bool debugValidateChild(RenderObject child) {
"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"A " + GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +

"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"The " + GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +

internal ChildType _child;
public ChildType child {
get { return this._child; }
get { return _child; }
if (this._child != null) {
this.dropChild(this._child);
if (_child != null) {
dropChild(_child);
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
_child = value;
if (_child != null) {
adoptChild(_child);
get { return this.child; }
set { this.child = (ChildType) value; }
get { return child; }
set { child = (ChildType) value; }
if (this._child != null) {
this._child.attach(owner);
if (_child != null) {
_child.attach(owner);
if (this._child != null) {
this._child.detach();
if (_child != null) {
_child.detach();
if (this._child != null) {
this.redepthChild(this._child);
if (_child != null) {
redepthChild(_child);
if (this._child != null) {
visitor(this._child);
if (_child != null) {
visitor(_child);
return this.child != null
? new List<DiagnosticsNode>{this.child.toDiagnosticsNode(name: "child")}
return child != null
? new List<DiagnosticsNode>{child.toDiagnosticsNode(name: "child")}
: new List<DiagnosticsNode>();
}
}

public override void detach() {
base.detach();
D.assert(this.previousSibling == null);
D.assert(this.nextSibling == null);
D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

int _childCount = 0;
public int childCount {
get { return this._childCount; }
get { return _childCount; }
}
public bool debugValidateChild(RenderObject child) {

"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"A " + GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +

"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"The " + GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +

D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
this._childCount++;
D.assert(this._childCount > 0);
_childCount++;
D.assert(_childCount > 0);
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {
var firstChildParentData = (ParentDataType) this._firstChild.parentData;
childParentData.nextSibling = _firstChild;
if (_firstChild != null) {
var firstChildParentData = (ParentDataType) _firstChild.parentData;
this._firstChild = child;
this._lastChild = this._lastChild ?? child;
_firstChild = child;
_lastChild = _lastChild ?? child;
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(after, equals: this._lastChild));
D.assert(_firstChild != null);
D.assert(_lastChild != null);
D.assert(_debugUltimatePreviousSiblingOf(after, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(after, equals: _lastChild));
D.assert(after == this._lastChild);
D.assert(after == _lastChild);
this._lastChild = child;
_lastChild = child;
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;

}
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.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
()=>"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 != _firstChild);
D.assert(child != _lastChild);
adoptChild(child);
_insertIntoChildList(child, after);
this.insert(child, this._lastChild);
insert(child, _lastChild);
children.ForEach(this.add);
children.ForEach(add);
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
D.assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
D.assert(_childCount >= 0);
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
D.assert(_firstChild == child);
_firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;

D.assert(this._lastChild == child);
this._lastChild = childParentData.previousSibling;
D.assert(_lastChild == child);
_lastChild = childParentData.previousSibling;
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;

childParentData.nextSibling = null;
this._childCount--;
_childCount--;
this._removeFromChildList(child);
this.dropChild(child);
_removeFromChildList(child);
dropChild(child);
ChildType child = this._firstChild;
ChildType child = _firstChild;
this.dropChild(child);
dropChild(child);
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;
_firstChild = null;
_lastChild = null;
_childCount = 0;
}
public void move(ChildType child, ChildType after = null) {

return;
}
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();
_removeFromChildList(child);
_insertIntoChildList(child, after);
markNeedsLayout();
ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
child.attach(owner);
var childParentData = (ParentDataType) child.parentData;

public override void detach() {
base.detach();
ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
child.detach();
var childParentData = (ParentDataType) child.parentData;

public override void redepthChildren() {
ChildType child = this._firstChild;
ChildType child = _firstChild;
this.redepthChild(child);
redepthChild(child);
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}

ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
visitor(child);
var childParentData = (ParentDataType) child.parentData;

public ChildType firstChild {
get { return this._firstChild; }
get { return _firstChild; }
get { return this._lastChild; }
get { return _lastChild; }
}
public ChildType childBefore(ChildType child) {

public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
if (firstChild != null) {
ChildType child = firstChild;
if (child == this.lastChild) {
if (child == lastChild) {
break;
}

}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
insert((ChildType) child, (ChildType) after);
this.remove((ChildType) child);
remove((ChildType) child);
this.move((ChildType) child, (ChildType) after);
move((ChildType) child, (ChildType) after);
get { return this.firstChild; }
get { return firstChild; }
get { return this.lastChild; }
get { return lastChild; }
return this.childBefore((ChildType) child);
return childBefore((ChildType) child);
return this.childAfter((ChildType) child);
return childAfter((ChildType) child);
}
}
{% endmacro %}

{{ ContainerRenderObjectMixin('RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack') }}
{% macro RenderConstrainedLayoutBuilderMixin(abstract, with, constraint) %}
public {{abstract}} class RenderConstrainedLayoutBuilderMixin{{with}}<ConstraintType, ChildType> : RenderObjectWithChildMixin{{with}}<ChildType>,
RenderConstrainedLayoutBuilder<ConstraintType, ChildType>
where ConstraintType : {{constraint}}
where ChildType : {{with}} {
public LayoutCallback<ConstraintType> _callback { get; set; }
public void updateCallback(LayoutCallback<ConstraintType> value) {
if (value == _callback)
return;
_callback = value;
markNeedsLayout();
}
public void layoutAndBuildChild() {
D.assert(_callback != null);
invokeLayoutCallback(_callback);
}
}
{% endmacro %}
{{ RenderConstrainedLayoutBuilderMixin('abstract', 'RenderObject', 'Constraints') }}
{{ RenderConstrainedLayoutBuilderMixin('', 'RenderBox', 'BoxConstraints') }}
{{ RenderConstrainedLayoutBuilderMixin('abstract', 'RenderSliver', 'SliverConstraints') }}
}

6
com.unity.uiwidgets/Runtime/rendering/paragraph.cs


get { return _textPainter.size; }
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
_layoutText();
return _textPainter.maxIntrinsicWidth;
}

return _textPainter.height;
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return _computeIntrinsicHeight(width);
}

6
com.unity.uiwidgets/Runtime/rendering/performance_overlay.cs


get { return true; }
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
return 0.0f;
}

}
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return _intrinsicHeight;
}

124
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


opaque,
translucent,
}
public delegate Shader ShaderCallback(Rect bounds);
class RenderShaderMask : RenderProxyBox {
public RenderShaderMask(
RenderBox child = null,
ShaderCallback shaderCallback = null,
BlendMode blendMode = BlendMode.modulate
) : base(child) {
D.assert(shaderCallback != null);
D.assert(blendMode != null);
_shaderCallback = shaderCallback;
_blendMode = blendMode;
}
public new ShaderMaskLayer layer {
get {
return base.layer as ShaderMaskLayer;
}
set { }
}
public ShaderCallback shaderCallback {
get {
return _shaderCallback;
}
set {
D.assert(value != null);
if (_shaderCallback == value)
return;
_shaderCallback = value;
markNeedsPaint();
}
}
ShaderCallback _shaderCallback;
public BlendMode blendMode {
get { return _blendMode;}
set {
D.assert(value != null);
if (_blendMode == value)
return;
_blendMode = value;
markNeedsPaint();
}
}
BlendMode _blendMode;
protected override bool alwaysNeedsCompositing {
get { return child != null;}
}
public override void paint(PaintingContext context, Offset offset) {
if (child != null) {
D.assert(needsCompositing);
layer = layer ?? new ShaderMaskLayer();
layer.shader = _shaderCallback(Offset.zero & size);
layer.maskRect = offset & size;
layer.blendMode = _blendMode;
context.pushLayer(layer, base.paint, offset);
} else {
layer = null;
}
}
}
public interface RenderAnimatedOpacityMixin<T> : RenderObjectWithChildMixin<T> where T : RenderObject {
int _alpha { get; set; }
bool alwaysNeedsCompositing {
get;
}
bool _currentlyNeedsCompositing { get; set; }
Animation<float> opacity {
get;
set;
}
Animation<float> _opacity { get; set; }
bool alwaysIncludeSemantics {
get;
set;
}
bool _alwaysIncludeSemantics { get; set; }
void attach(PipelineOwner owner);
void detach();
void _updateOpacity();
void paint(PaintingContext context, Offset offset);
void visitChildrenForSemantics(RenderObjectVisitor visitor);
void debugFillProperties(DiagnosticPropertiesBuilder properties);
}
public abstract class RenderProxyBoxWithHitTestBehavior : RenderProxyBox {
protected RenderProxyBoxWithHitTestBehavior(
HitTestBehavior behavior = HitTestBehavior.deferToChild,

BoxConstraints _additionalConstraints;
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (_additionalConstraints.hasBoundedWidth && _additionalConstraints.hasTightWidth) {
return _additionalConstraints.minWidth;
}

return width;
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (_additionalConstraints.hasBoundedWidth && _additionalConstraints.hasTightWidth) {
return _additionalConstraints.minWidth;
}

return width;
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (_additionalConstraints.hasBoundedHeight && _additionalConstraints.hasTightHeight) {
return _additionalConstraints.minHeight;
}

float _aspectRatio;
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (height.isFinite()) {
return height * _aspectRatio;
}

return 0.0f;
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (height.isFinite()) {
return height * _aspectRatio;
}

return 0.0f;
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (width.isFinite()) {
return width / _aspectRatio;
}

return (input / step.Value).ceil() * step.Value;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child == null) {
return 0.0f;
}

}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (child == null) {
return 0.0f;
}

) : base(child) {
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (child == null) {
return 0.0f;
}

return child.getMinIntrinsicWidth(height);
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child == null) {
return 0.0f;
}

return child.getMaxIntrinsicWidth(height);
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return computeMaxIntrinsicHeight(width);
}

bool _offstage;
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (offstage) {
return 0.0f;
}

protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (offstage) {
return 0.0f;
}

protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (offstage) {
return 0.0f;
}

6
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs


}
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (child != null) {
return child.getMinIntrinsicWidth(height);
}

protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child != null) {
return child.getMaxIntrinsicWidth(height);
}

protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (child != null) {
return child.getMinIntrinsicHeight(width);
}

41
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk


}
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
protected override float computeMaxIntrinsicHeight(float width) {
protected internal override float computeMaxIntrinsicHeight(float width) {
}
}
if (this.child != null) {
return this.child.getDistanceToActualBaseline(baseline);
if (child != null) {
return child.getDistanceToActualBaseline(baseline);
}
return base.computeDistanceToActualBaseline(baseline);

if (this.child != null) {
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.child.size;
if (child != null) {
child.layout(constraints, parentUsesSize: true);
size = child.size;
this.performResize();
performResize();
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (this.child != null) {
return this.child.hitTest(result, position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (child != null) {
return child.hitTest(result, position);
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
if (this.child != null) {
context.paintChild(this.child, offset);
if (child != null) {
context.paintChild(child, offset);
}
}
}

14
com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs


mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition);
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
child = (RenderSliver)child;
D.assert(child != null);
D.assert(child == this.child);

RenderObject RenderObjectWithChildMixin.child {
get { return child; }
set { child = (RenderSliver) value; }
}
}
public class RenderSliverAnimatedOpacity :RenderAnimatedOpacityMixinRenderSliver<RenderSliver>{
public RenderSliverAnimatedOpacity(
Animation<float> opacity ,
RenderSliver sliver = null,
bool alwaysIncludeSemantics = false
) {
D.assert(opacity != null);
this.opacity = opacity;
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
child = sliver;
}
}
public class RenderSliverOpacity : RenderProxySliver {

6
com.unity.uiwidgets/Runtime/rendering/rotated_box.cs


get { return quarterTurns % 2 == 1; }
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (child == null) {
return 0.0f;
}

: child.getMinIntrinsicWidth(height);
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child == null) {
return 0.0f;
}

: child.getMaxIntrinsicWidth(height);
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (child == null) {
return 0.0f;
}

30
com.unity.uiwidgets/Runtime/rendering/shifted_box.cs


this.child = child;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (child != null) {
return child.getMinIntrinsicWidth(height);
}

protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child != null) {
return child.getMaxIntrinsicWidth(height);
}

protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (child != null) {
return child.getMinIntrinsicHeight(width);
}

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

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

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

public Size _requestedSize;
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return _requestedSize.height;
}

);
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
float result;
if (child == null) {
result = base.computeMinIntrinsicWidth(height);

return result / (_widthFactor ?? 1.0f);
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
float result;
if (child == null) {
result = base.computeMaxIntrinsicWidth(height);

return result / (_widthFactor ?? 1.0f);
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
float result;
if (child == null) {
result = base.computeMinIntrinsicHeight(width);

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

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

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

182
com.unity.uiwidgets/Runtime/rendering/sliver.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {

hasErrors = true;
errorMessage.AppendLine($" {message}");
});
void verifyFloat(float property, string name, bool mustBePositive = false, bool mustBeNegative = false) {
verify(property != null, $"The \"{name}\" is null.");
if (property.isNaN()) {
string additional = ".";
if (mustBePositive) {
additional = ", expected greater than or equal to zero.";
} else if (mustBeNegative) {
additional = ", expected less than or equal to zero.";
}
verify(false, $"The \"{name}\" is NaN" + $"{additional}");
} else if (mustBePositive) {
verify(property >= 0.0, $"The \"{name}\" is negative.");
} else if (mustBeNegative) {
verify(property <= 0.0, $"The \"{name}\" is positive.");
}
}
verify(axis != null, "The \"axis\" is null.");
verify(growthDirection != null, "The \"growthDirection\" is null.");
verifyFloat(scrollOffset, "scrollOffset");
verifyFloat(overlap, "overlap");
verifyFloat(crossAxisExtent, "crossAxisExtent");
verifyFloat(scrollOffset, "scrollOffset", mustBePositive: true);
verify(crossAxisDirection != null, "The \"crossAxisDirection\" is null.");
verify(AxisUtils.axisDirectionToAxis(axisDirection) != AxisUtils.axisDirectionToAxis(crossAxisDirection), "The \"axisDirection\" and the \"crossAxisDirection\" are along the same axis.");
verifyFloat(viewportMainAxisExtent, "viewportMainAxisExtent", mustBePositive: true);
verifyFloat(remainingPaintExtent, "remainingPaintExtent", mustBePositive: true);
verifyFloat(remainingCacheExtent, "remainingCacheExtent", mustBePositive: true);
verifyFloat(cacheOrigin, "cacheOrigin", mustBeNegative: true);
verifyFloat(precedingScrollExtent, "precedingScrollExtent", mustBePositive: true);
verify(isNormalized, "The constraints are not normalized."); // should be redundant with earlier checks
verify(scrollOffset >= 0.0f, "The \"scrollOffset\" is negative.");
verify(crossAxisExtent >= 0.0f, "The \"crossAxisExtent\" is negative.");
verify(
AxisUtils.axisDirectionToAxis(axisDirection) !=
AxisUtils.axisDirectionToAxis(crossAxisDirection),
"The \"axisDirection\" and the \"crossAxisDirection\" are along the same axis.");
verify(viewportMainAxisExtent >= 0.0f, "The \"viewportMainAxisExtent\" is negative.");
verify(remainingPaintExtent >= 0.0f, "The \"remainingPaintExtent\" is negative.");
verify(remainingCacheExtent >= 0.0f, "The \"remainingCacheExtent\" is negative.");
verify(cacheOrigin <= 0.0f, "The \"cacheOrigin\" is positive.");
verify(isNormalized, "The constraints are not normalized.");
if (hasErrors) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary($"{GetType()} is not valid: {errorMessage}"));

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

}
public class SliverLogicalParentData : ParentData {
public float layoutOffset = 0.0f;
public float? layoutOffset;
return "layoutOffset=" + layoutOffset.ToString("F1");
return layoutOffset == null ? "layoutOffset = None" : $"layoutOffset = {layoutOffset:F1}";
}
}

public override Rect paintBounds {
get {
D.assert(constraints.axis != null);
switch (constraints.axis) {
case Axis.horizontal:
return Rect.fromLTWH(

);
}
D.assert(false);
// D.assert(false);
return null;
}
}

return (to.clamp(a, b) - from.clamp(a, b)).clamp(0.0f, constraints.remainingCacheExtent);
}
public virtual float childMainAxisPosition(RenderObject child) {
public virtual float? childMainAxisPosition(RenderObject child) {
return 0.0f;
return null;
public virtual float childCrossAxisPosition(RenderObject child) {
return 0.0f;
public virtual float? childCrossAxisPosition(RenderObject child) {
return null;
public virtual float childScrollOffset(RenderObject child) {
public virtual float? childScrollOffset(RenderObject child) {
return 0.0f;
return null;
}
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {

return new Size(-geometry.paintExtent, constraints.crossAxisExtent);
}
D.assert(false);
//D.assert(false);
protected Size getAbsoluteSize() {
public Size getAbsoluteSize() {
D.assert(geometry != null);
D.assert(!debugNeedsLayout);
switch (constraints.axisDirection) {

else {
dy2 = -dy2;
}
var path = new Path();
path.moveTo(p0.dx,p0.dy);
path.lineTo(p1.dx, p1.dy);
path.moveTo(p1.dx - dx1, p1.dy - dy1);
path.lineTo(p1.dx, p1.dy);
path.lineTo(p1.dx - dx2, p1.dy - dy2);
canvas.drawPath(
path,
paint
);
// canvas.drawPath(
// new Path()
// ..moveTo(p0.dx, p0.dy)
// ..lineTo(p1.dx, p1.dy)
// ..moveTo(p1.dx - dx1, p1.dy - dy1)
// ..lineTo(p1.dx, p1.dy)
// ..lineTo(p1.dx - dx2, p1.dy - dy2),
// paint
// );
return true;
});
}

if (D.debugPaintSizeEnabled) {
float strokeWidth = Mathf.Min(4.0f, geometry.paintExtent / 30.0f);
Paint paint = new Paint();
// ..color = const Color(0xFF33CC33)
// ..strokeWidth = strokeWidth
// ..style = PaintingStyle.stroke
// ..maskFilter = new MaskFilter.blur(BlurStyle.solid, strokeWidth);
paint.color = new Color(0xFF33CC33);
paint.strokeWidth = strokeWidth;
paint.style = PaintingStyle.stroke;
paint.maskFilter = MaskFilter.blur(BlurStyle.solid, strokeWidth);
// canvas.drawCircle(
// offset.translate(padding, padding),
// padding * 0.5,
// paint,
// );
canvas.drawCircle(
offset.translate(padding, padding),
padding * 0.5f,
paint
);
// canvas.drawLine(
// offset,
// offset.translate(constraints.crossAxisExtent, 0.0f),
// paint,
// );
canvas.drawLine(
offset,
offset.translate(constraints.crossAxisExtent, 0.0f),
paint
);
_debugDrawArrow(
canvas,
paint,

);
break;
case Axis.horizontal:
// canvas.drawLine(
// offset,
// offset.translate(0.0f, constraints.crossAxisExtent),
// paint,
// );
canvas.drawLine(
offset,
offset.translate(0.0f, constraints.crossAxisExtent),
paint
);
_debugDrawArrow(
canvas,
paint,

});
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
entry = (SliverHitTestEntry) entry;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<SliverGeometry>("geometry", geometry));

return rightWayUp;
}
public static bool hitTestBoxChild(this RenderSliver it, BoxHitTestResult result, RenderBox child,
float mainAxisPosition = 0.0f, float crossAxisPosition = 0.0f) {
public static bool hitTestBoxChild(
this RenderSliver it,
BoxHitTestResult result,
RenderBox child,
float mainAxisPosition = 0.0f,
float crossAxisPosition = 0.0f) {
float delta = it.childMainAxisPosition(child);
float crossAxisDelta = it.childCrossAxisPosition(child);
float absolutePosition = mainAxisPosition - delta;
float absoluteCrossAxisPosition = crossAxisPosition - crossAxisDelta;
float? delta = it.childMainAxisPosition(child);
float? crossAxisDelta = it.childCrossAxisPosition(child);
float? absolutePosition = mainAxisPosition - delta;
float? absoluteCrossAxisPosition = crossAxisPosition - crossAxisDelta;
Offset paintOffset = null;
Offset transformedPosition = null;
D.assert(it.constraints.axis != null);

absolutePosition = child.size.width - absolutePosition;
delta = it.geometry.paintExtent - child.size.width - delta;
}
paintOffset = new Offset(delta, crossAxisDelta);
transformedPosition = new Offset(absolutePosition, absoluteCrossAxisPosition);
paintOffset = new Offset(delta ?? 0.0f, crossAxisDelta ?? 0.0f);
transformedPosition = new Offset(absolutePosition ?? 0.0f, absoluteCrossAxisPosition ?? 0.0f);
absolutePosition = child.size.height - absolutePosition;
delta = it.geometry.paintExtent - child.size.height - delta;
absolutePosition = child.size.height - absolutePosition;
delta = it.geometry.paintExtent - child.size.height - delta;
paintOffset = new Offset(crossAxisDelta, delta);
transformedPosition = new Offset(absoluteCrossAxisPosition, absolutePosition);
paintOffset = new Offset(crossAxisDelta ?? 0.0f, delta ?? 0.0f);
transformedPosition = new Offset(absoluteCrossAxisPosition ?? 0.0f, absolutePosition ?? 0.0f);
break;
}
D.assert(paintOffset != null);

public static void applyPaintTransformForBoxChild(this RenderSliver it, RenderBox child,
Matrix4 transform) {
bool rightWayUp = _getRightWayUp(it.constraints);
float delta = it.childMainAxisPosition(child);
float crossAxisDelta = it.childCrossAxisPosition(child);
float? delta = it.childMainAxisPosition(child);
float? crossAxisDelta = it.childCrossAxisPosition(child);
switch (it.constraints.axis) {
case Axis.horizontal:
if (!rightWayUp) {

transform.translate(delta, crossAxisDelta);
transform.translate(delta, crossAxisDelta ?? 0.0f);
break;
case Axis.vertical:
if (!rightWayUp) {

transform.translate(crossAxisDelta, delta);
transform.translate(crossAxisDelta ?? 0.0f, delta ?? 0.0f);
break;
}
}

return false;
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
return -constraints.scrollOffset;
}

126
com.unity.uiwidgets/Runtime/rendering/sliver_fill.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
class RenderSliverFillRemainingWithScrollable : RenderSliverSingleBoxAdapter {
public RenderSliverFillRemainingWithScrollable(RenderBox child = null) : base(child: child) {
}
protected override void performLayout() {
SliverConstraints constraints = this.constraints;
float extent = constraints.remainingPaintExtent - Mathf.Min(constraints.overlap, 0.0f);
if (child != null)
child.layout(constraints.asBoxConstraints(
minExtent: extent,
maxExtent: extent
));
float paintedChildSize = calculatePaintOffset(constraints, from: 0.0f, to: extent);
D.assert(paintedChildSize.isFinite());
D.assert(paintedChildSize >= 0.0);
geometry = new SliverGeometry(
scrollExtent: constraints.viewportMainAxisExtent,
paintExtent: paintedChildSize,
maxPaintExtent: paintedChildSize,
hasVisualOverflow: extent > constraints.remainingPaintExtent || constraints.scrollOffset > 0.0
);
if (child != null)
setChildParentData(child, constraints, geometry);
}
}
public class RenderSliverFillRemaining : RenderSliverSingleBoxAdapter {
public RenderSliverFillRemaining( RenderBox child = null) : base(child: child) { }
protected override void performLayout() {
SliverConstraints constraints = this.constraints;
float extent = constraints.viewportMainAxisExtent - constraints.precedingScrollExtent;
if (child != null) {
float childExtent = 0f;
switch (constraints.axis) {
case Axis.horizontal:
childExtent = child.getMaxIntrinsicWidth(constraints.crossAxisExtent);
break;
case Axis.vertical:
childExtent = child.getMaxIntrinsicHeight(constraints.crossAxisExtent);
break;
}
extent = Mathf.Max(extent, childExtent);
child.layout(constraints.asBoxConstraints(
minExtent: extent,
maxExtent: extent
));
}
D.assert(extent.isFinite(),()=>
"The calculated extent for the child of SliverFillRemaining is not finite. "+
"This can happen if the child is a scrollable, in which case, the " +
"hasScrollBody property of SliverFillRemaining should not be set to " +
"false."
);
float paintedChildSize = calculatePaintOffset(constraints, from: 0.0f, to: extent);
D.assert(paintedChildSize.isFinite());
D.assert(paintedChildSize >= 0.0);
geometry = new SliverGeometry(
scrollExtent: extent,
paintExtent: paintedChildSize,
maxPaintExtent: paintedChildSize,
hasVisualOverflow: extent > constraints.remainingPaintExtent || constraints.scrollOffset > 0.0
);
if (child != null)
setChildParentData(child, constraints, geometry);
}
}
public class RenderSliverFillViewport : RenderSliverFixedExtentBoxAdaptor {
public RenderSliverFillViewport(
RenderSliverBoxChildManager childManager = null,

) + padding + padding;
}
}
public class RenderSliverFillRemaining : RenderSliverSingleBoxAdapter {
public RenderSliverFillRemaining(
RenderBox child = null
) : base(child: child) {
public class RenderSliverFillRemainingAndOverscroll : RenderSliverSingleBoxAdapter {
public RenderSliverFillRemainingAndOverscroll(RenderBox child = null) : base(child: child) {
protected override void performLayout() {
float extent = constraints.remainingPaintExtent - Mathf.Min(constraints.overlap, 0.0f);
if (child != null) {
child.layout(constraints.asBoxConstraints(minExtent: extent, maxExtent: extent),
parentUsesSize: true);
protected override void performLayout() {
SliverConstraints constraints = this.constraints;
float extent = constraints.viewportMainAxisExtent - constraints.precedingScrollExtent;
float maxExtent = constraints.remainingPaintExtent - Mathf.Min(constraints.overlap, 0.0f);
if (child != null) {
float childExtent = 0f;
switch (constraints.axis) {
case Axis.horizontal:
childExtent = child.getMaxIntrinsicWidth(constraints.crossAxisExtent);
break;
case Axis.vertical:
childExtent = child.getMaxIntrinsicHeight(constraints.crossAxisExtent);
break;
}
extent = Mathf.Max(extent, childExtent);
maxExtent = Mathf.Max(extent, maxExtent);
child.layout(constraints.asBoxConstraints(minExtent: extent, maxExtent: maxExtent));
D.assert(extent.isFinite(),()=>
"The calculated extent for the child of SliverFillRemaining is not finite. " +
"This can happen if the child is a scrollable, in which case, the " +
"hasScrollBody property of SliverFillRemaining should not be set to " +
"false."
);
D.assert(paintedChildSize >= 0.0);
D.assert(paintedChildSize >= 0.0f);
scrollExtent: constraints.viewportMainAxisExtent,
paintExtent: paintedChildSize,
maxPaintExtent: paintedChildSize,
hasVisualOverflow: extent > constraints.remainingPaintExtent ||
constraints.scrollOffset > 0.0
scrollExtent: extent,
paintExtent: Mathf.Min(maxExtent, constraints.remainingPaintExtent),
maxPaintExtent: maxExtent ,
hasVisualOverflow: extent > constraints.remainingPaintExtent || constraints.scrollOffset > 0.0
if (child != null) {
if (child != null)
}
}

2
com.unity.uiwidgets/Runtime/rendering/sliver_grid.cs


SliverGridDelegate _gridDelegate;
public override float childCrossAxisPosition(RenderObject child) {
public override float? childCrossAxisPosition(RenderObject child) {
SliverGridParentData childParentData = (SliverGridParentData) child.parentData;
return childParentData.crossAxisOffset;
}

16
com.unity.uiwidgets/Runtime/rendering/sliver_list.cs


RenderBox leadingChildWithLayout = null, trailingChildWithLayout = null;
RenderBox earliestUsefulChild = firstChild;
for (float earliestScrollOffset = childScrollOffset(earliestUsefulChild);
for (float earliestScrollOffset = childScrollOffset(earliestUsefulChild) ?? 0.0f;
earliestScrollOffset = childScrollOffset(earliestUsefulChild)) {
earliestScrollOffset = childScrollOffset(earliestUsefulChild)?? 0.0f) {
earliestUsefulChild = insertAndLayoutLeadingChild(childConstraints, parentUsesSize: true);
if (earliestUsefulChild == null) {

bool inLayoutRange = true;
RenderBox child = earliestUsefulChild;
int index = indexOf(child);
float endScrollOffset = childScrollOffset(child) + paintExtentOf(child);
float endScrollOffset = childScrollOffset(child) + paintExtentOf(child) ?? 0.0f;
Func<bool> advance = () => {
D.assert(child != null);

var childParentData = (SliverMultiBoxAdaptorParentData) child.parentData;
childParentData.layoutOffset = endScrollOffset;
D.assert(childParentData.index == index);
endScrollOffset = childScrollOffset(child) + paintExtentOf(child);
endScrollOffset = childScrollOffset(child) + paintExtentOf(child) ?? 0.0f ;
return true;
};

collectGarbage(leadingGarbage - 1, 0);
D.assert(firstChild == lastChild);
float extent = childScrollOffset(lastChild) + paintExtentOf(lastChild);
float extent = childScrollOffset(lastChild) + paintExtentOf(lastChild) ?? 0.0f;
geometry = new SliverGeometry(
scrollExtent: extent,
paintExtent: 0.0f,

constraints,
firstIndex: indexOf(firstChild),
lastIndex: indexOf(lastChild),
leadingScrollOffset: childScrollOffset(firstChild),
leadingScrollOffset: childScrollOffset(firstChild) ?? 0.0f,
trailingScrollOffset: endScrollOffset
);

float paintExtent = calculatePaintOffset(
constraints,
from: childScrollOffset(firstChild),
from: childScrollOffset(firstChild) ?? 0.0f,
from: childScrollOffset(firstChild),
from: childScrollOffset(firstChild) ?? 0.0f,
to: endScrollOffset
);
float targetEndScrollOffsetForPaint =

99
com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs


) {
D.assert(childManager != null);
_childManager = childManager;
D.assert(()=> {
_debugDanglingKeepAlives = new List<RenderBox>();
return true;
});
}
public override void setupParentData(RenderObject child) {

protected RenderSliverBoxChildManager childManager {
get { return _childManager; }
}
List<RenderBox> _debugDanglingKeepAlives;
public bool debugChildIntegrityEnabled {
get { return _debugChildIntegrityEnabled;}
}
public void setDebugChildIntegrityEnabled(bool enabled) {
D.assert(enabled != null);
D.assert(() => {
_debugChildIntegrityEnabled = enabled;
return _debugVerifyChildOrder() &&
(!_debugChildIntegrityEnabled || _debugDanglingKeepAlives.isEmpty());
});
}
bool _debugChildIntegrityEnabled = true;
protected override void adoptChild(AbstractNodeMixinDiagnosticableTree childNode) {
base.adoptChild(childNode);
var child = (RenderBox) childNode;

return childManager.debugAssertChildListLocked();
}
bool _debugVerifyChildOrder(){
if (_debugChildIntegrityEnabled) {
RenderBox child = firstChild;
int index;
while (child != null) {
index = indexOf(child);
child = childAfter(child);
D.assert(child == null || indexOf(child) > index);
}
}
return true;
}
D.assert(() => {
int index = indexOf(firstChild);
RenderBox childAfter = this.childAfter(firstChild);
while (childAfter != null) {
D.assert(indexOf(childAfter) > index);
index = indexOf(childAfter);
childAfter = this.childAfter(childAfter);
D.assert(_debugVerifyChildOrder());
}
public new void move(RenderBox child, RenderBox after = null) {
SliverMultiBoxAdaptorParentData childParentData = child.parentData as SliverMultiBoxAdaptorParentData;
if (!childParentData.keptAlive) {
base.move(child, after: after);
childManager.didAdoptChild(child);
markNeedsLayout();
} else {
if (_keepAliveBucket[childParentData.index] == child) {
_keepAliveBucket.Remove(childParentData.index);
return true;
});
D.assert(()=> {
_debugDanglingKeepAlives.Remove(child);
return true;
});
childManager.didAdoptChild(child);
D.assert(()=> {
if (_keepAliveBucket.ContainsKey(childParentData.index))
_debugDanglingKeepAlives.Add(_keepAliveBucket[childParentData.index]);
return true;
});
_keepAliveBucket[childParentData.index] = child;
}
public override void remove(RenderBox child) {
SliverMultiBoxAdaptorParentData childParentData = (SliverMultiBoxAdaptorParentData) child.parentData;
if (!childParentData._keptAlive) {

D.assert(()=> {
_debugDanglingKeepAlives.Remove(child);
return true;
});
public override void removeAll() {
base.removeAll();

protected bool addInitialChild(int index = 0, float layoutOffset = 0.0f) {
D.assert(_debugAssertChildListLocked());
D.assert(firstChild == null);
protected RenderBox insertAndLayoutLeadingChild(BoxConstraints childConstraints, bool parentUsesSize = false) {
protected RenderBox insertAndLayoutLeadingChild(
BoxConstraints childConstraints,
bool parentUsesSize = false) {
int index = indexOf(firstChild) - 1;
_createOrObtainChild(index, after: null);
if (indexOf(firstChild) == index) {

childManager.setDidUnderflow(true);
return null;
}

public int indexOf(RenderBox child) {
D.assert(child != null);
SliverMultiBoxAdaptorParentData childParentData = (SliverMultiBoxAdaptorParentData) child.parentData;
D.assert(childParentData.index != null);
return childParentData.index;
}

return 0.0f;
}
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f,
protected override bool hitTestChildren(
SliverHitTestResult result,
float mainAxisPosition = 0.0f,
float crossAxisPosition = 0.0f) {
RenderBox child = lastChild;
BoxHitTestResult boxResult = new BoxHitTestResult(result);

return false;
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
public override float childScrollOffset(RenderObject child) {
public override float? childScrollOffset(RenderObject child) {
return childParentData.layoutOffset;
return (float)childParentData.layoutOffset;
}
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {

RenderBox child = firstChild;
while (child != null) {
float mainAxisDelta = childMainAxisPosition(child);
float crossAxisDelta = childCrossAxisPosition(child);
float mainAxisDelta = childMainAxisPosition(child) ?? 0.0f;
float crossAxisDelta = childCrossAxisPosition(child) ?? 0.0f;
Offset childOffset = new Offset(
originOffset.dx + mainAxisUnit.dx * mainAxisDelta + crossAxisUnit.dx * crossAxisDelta,
originOffset.dy + mainAxisUnit.dy * mainAxisDelta + crossAxisUnit.dy * crossAxisDelta

if (_keepAliveBucket.isNotEmpty()) {
List<int> indices = _keepAliveBucket.Keys.ToList();
indices.Sort();
foreach (int index in indices) {
children.Add(_keepAliveBucket[index].toDiagnosticsNode(
name: "child with index " + index + " (kept alive but not laid out)",

409
com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs


using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class RenderSliverPadding : RenderObjectWithChildMixinRenderSliver<RenderSliver> {
public RenderSliverPadding(
EdgeInsets padding = null,
RenderSliver child = null
) {
D.assert(padding != null);
D.assert(padding.isNonNegative);
_padding = padding;
this.child = child;
}
public EdgeInsets padding {
get { return _padding; }
set {
D.assert(value != null);
D.assert(value.isNonNegative);
if (_padding == value) {
return;
}
public abstract class RenderSliverEdgeInsetsPadding : RenderObjectWithChildMixinRenderSliver<RenderSliver> {
_padding = value;
markNeedsLayout();
}
}
EdgeInsets resolvedPadding { get; }
EdgeInsets _padding;
public float beforePadding {
float? beforePadding {
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(
constraints.axisDirection, constraints.growthDirection)) {
D.assert(constraints.axisDirection != null);
D.assert(constraints.growthDirection != null);
D.assert(resolvedPadding != null);
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) {
return _padding.bottom;
return resolvedPadding.bottom;
return _padding.left;
return resolvedPadding.left;
return _padding.top;
return resolvedPadding.top;
return _padding.right;
return resolvedPadding.right;
return 0.0f;
return null;
}
public float afterPadding {
get {
}
float? afterPadding {
get {
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(
constraints.axisDirection, constraints.growthDirection)) {
D.assert(constraints.axisDirection != null);
D.assert(constraints.growthDirection != null);
D.assert(resolvedPadding != null);
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) {
return _padding.top;
return resolvedPadding.top;
return _padding.right;
return resolvedPadding.right;
return _padding.bottom;
return resolvedPadding.bottom;
return _padding.left;
return resolvedPadding.left;
return 0.0f;
return null;
public float mainAxisPadding {
get {
float? mainAxisPadding {
get {
return _padding.along(constraints.axis);
D.assert(constraints.axis != null);
D.assert(resolvedPadding != null);
return resolvedPadding.along(constraints.axis);
public float crossAxisPadding {
get {
float? crossAxisPadding {
get {
D.assert(constraints.axis != null);
D.assert(resolvedPadding != null);
return _padding.vertical;
return resolvedPadding.vertical;
return _padding.horizontal;
return resolvedPadding.horizontal;
D.assert(false);
return 0.0f;
return null;
if (!(child.parentData is SliverPhysicalParentData)) {
if (!(child.parentData is SliverPhysicalParentData))
}
protected override void performLayout() {
float beforePadding = this.beforePadding;
float afterPadding = this.afterPadding;
float mainAxisPadding = this.mainAxisPadding;
float crossAxisPadding = this.crossAxisPadding;
if (child == null) {
protected override void performLayout() {
SliverConstraints constraints = this.constraints;
D.assert(resolvedPadding != null);
float? beforePadding = this.beforePadding;
float? afterPadding = this.afterPadding;
float? mainAxisPadding = this.mainAxisPadding;
float? crossAxisPadding = this.crossAxisPadding;
if (child == null) {
scrollExtent: mainAxisPadding,
paintExtent: Mathf.Min(mainAxisPadding, constraints.remainingPaintExtent),
maxPaintExtent: mainAxisPadding
);
return;
}
scrollExtent: mainAxisPadding ?? 0.0f,
paintExtent: Mathf.Min(mainAxisPadding ?? 0.0f, constraints.remainingPaintExtent),
maxPaintExtent: mainAxisPadding ?? 0.0f
);
return;
}
scrollOffset: Mathf.Max(0.0f, constraints.scrollOffset - beforePadding),
cacheOrigin: Mathf.Min(0.0f, constraints.cacheOrigin + beforePadding),
overlap: 0.0f,
remainingPaintExtent: constraints.remainingPaintExtent -
calculatePaintOffset(constraints, from: 0.0f, to: beforePadding),
remainingCacheExtent: constraints.remainingCacheExtent -
calculateCacheOffset(constraints, from: 0.0f, to: beforePadding),
crossAxisExtent: Mathf.Max(0.0f, constraints.crossAxisExtent - crossAxisPadding)
),
scrollOffset: Mathf.Max(0.0f, constraints.scrollOffset - beforePadding ?? 0.0f),
cacheOrigin: Mathf.Min(0.0f, constraints.cacheOrigin + beforePadding ?? 0.0f),
overlap: 0.0f,
remainingPaintExtent: constraints.remainingPaintExtent - calculatePaintOffset(constraints, from: 0.0f, to: beforePadding ?? 0.0f),
remainingCacheExtent: constraints.remainingCacheExtent - calculateCacheOffset(constraints, from: 0.0f, to: beforePadding ?? 0.0f),
crossAxisExtent: Mathf.Max(0.0f, constraints.crossAxisExtent - crossAxisPadding ?? 0.0f),
precedingScrollExtent: beforePadding ?? 0.0f + constraints.precedingScrollExtent
),
);
SliverGeometry childLayoutGeometry = child.geometry;
if (childLayoutGeometry.scrollOffsetCorrection != null) {
);
SliverGeometry childLayoutGeometry = child.geometry;
if (childLayoutGeometry.scrollOffsetCorrection != null) {
);
return;
}
);
return;
}
constraints,
from: 0.0f,
to: beforePadding
);
constraints,
from: 0.0f,
to: beforePadding ?? 0.0f
);
constraints,
from: beforePadding + childLayoutGeometry.scrollExtent,
to: mainAxisPadding + childLayoutGeometry.scrollExtent
);
float mainAxisPaddingPaintExtent = beforePaddingPaintExtent + afterPaddingPaintExtent;
constraints,
from: beforePadding ?? 0.0f + childLayoutGeometry.scrollExtent,
to: mainAxisPadding ?? 0.0f + childLayoutGeometry.scrollExtent
);
float mainAxisPaddingPaintExtent = beforePaddingPaintExtent + afterPaddingPaintExtent;
constraints,
from: 0.0f,
to: beforePadding
);
constraints,
from: 0.0f,
to: beforePadding ?? 0.0f
);
constraints,
from: beforePadding + childLayoutGeometry.scrollExtent,
to: mainAxisPadding + childLayoutGeometry.scrollExtent
);
float mainAxisPaddingCacheExtent = afterPaddingCacheExtent + beforePaddingCacheExtent;
constraints,
from: beforePadding ?? 0.0f + childLayoutGeometry.scrollExtent,
to: mainAxisPadding ?? 0.0f + childLayoutGeometry.scrollExtent
);
float mainAxisPaddingCacheExtent = afterPaddingCacheExtent + beforePaddingCacheExtent;
beforePaddingPaintExtent + Mathf.Max(childLayoutGeometry.paintExtent,
childLayoutGeometry.layoutExtent + afterPaddingPaintExtent),
beforePaddingPaintExtent + Mathf.Max(childLayoutGeometry.paintExtent, childLayoutGeometry.layoutExtent + afterPaddingPaintExtent),
);
);
scrollExtent: mainAxisPadding + childLayoutGeometry.scrollExtent,
paintExtent: paintExtent,
layoutExtent: Mathf.Min(mainAxisPaddingPaintExtent + childLayoutGeometry.layoutExtent,
paintExtent),
cacheExtent: Mathf.Min(mainAxisPaddingCacheExtent + childLayoutGeometry.cacheExtent,
constraints.remainingCacheExtent),
maxPaintExtent: mainAxisPadding + childLayoutGeometry.maxPaintExtent,
scrollExtent: mainAxisPadding ?? 0.0f+ childLayoutGeometry.scrollExtent,
paintExtent: paintExtent,
layoutExtent: Mathf.Min(mainAxisPaddingPaintExtent + childLayoutGeometry.layoutExtent, paintExtent),
cacheExtent: Mathf.Min(mainAxisPaddingCacheExtent + childLayoutGeometry.cacheExtent, constraints.remainingCacheExtent),
maxPaintExtent: mainAxisPadding ?? 0.0f + childLayoutGeometry.maxPaintExtent,
mainAxisPaddingPaintExtent + childLayoutGeometry.paintExtent,
mainAxisPaddingPaintExtent + childLayoutGeometry.paintExtent,
),
),
);
var childParentData = (SliverPhysicalParentData) child.parentData;
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(constraints.axisDirection,
constraints.growthDirection)) {
case AxisDirection.up:
childParentData.paintOffset = new Offset(_padding.left,
calculatePaintOffset(constraints,
from: _padding.bottom + childLayoutGeometry.scrollExtent,
to: _padding.bottom + childLayoutGeometry.scrollExtent + _padding.top));
break;
);
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
D.assert(constraints.axisDirection != null);
D.assert(constraints.growthDirection != null);
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) {
case AxisDirection.up:
childParentData.paintOffset = new Offset(resolvedPadding.left, calculatePaintOffset(constraints, from: resolvedPadding.bottom + childLayoutGeometry.scrollExtent, to: resolvedPadding.bottom + childLayoutGeometry.scrollExtent + resolvedPadding.top));
break;
childParentData.paintOffset =
new Offset(calculatePaintOffset(constraints, from: 0.0f, to: _padding.left),
_padding.top);
break;
childParentData.paintOffset = new Offset(calculatePaintOffset(constraints, from: 0.0f, to: resolvedPadding.left), resolvedPadding.top);
break;
childParentData.paintOffset = new Offset(_padding.left,
calculatePaintOffset(constraints, from: 0.0f, to: _padding.top));
break;
childParentData.paintOffset = new Offset(resolvedPadding.left, calculatePaintOffset(constraints, from: 0.0f, to: resolvedPadding.top));
break;
childParentData.paintOffset = new Offset(
calculatePaintOffset(constraints,
from: _padding.right + childLayoutGeometry.scrollExtent,
to: _padding.right + childLayoutGeometry.scrollExtent + _padding.left),
_padding.top);
childParentData.paintOffset = new Offset(calculatePaintOffset(constraints, from: resolvedPadding.right + childLayoutGeometry.scrollExtent, to: resolvedPadding.right + childLayoutGeometry.scrollExtent + resolvedPadding.left), resolvedPadding.top);
D.assert(childParentData.paintOffset != null);
D.assert(beforePadding == this.beforePadding);
D.assert(afterPadding == this.afterPadding);

protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f,
float crossAxisPosition = 0.0f) {
if (child != null && child.geometry.hitTestExtent > 0.0) {
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f, float crossAxisPosition = 0.0f) {
if (child != null && child.geometry.hitTestExtent > 0.0) {
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
mainAxisOffset: childMainAxisPosition(child),
crossAxisOffset: childCrossAxisPosition(child),
mainAxisOffset: childMainAxisPosition(child) ?? 0.0f,
crossAxisOffset: (float)childCrossAxisPosition(child),
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
child = (RenderSliver) child;
return calculatePaintOffset(constraints, from: 0.0f, to: beforePadding);
return calculatePaintOffset(constraints, from: 0.0f, to: beforePadding ?? 0.0f);
public override float childCrossAxisPosition(RenderObject child) {
public override float? childCrossAxisPosition(RenderObject child) {
child = (RenderSliver) child;
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(
constraints.axisDirection, constraints.growthDirection)) {
case AxisDirection.up:
case AxisDirection.down:
return _padding.left;
case AxisDirection.left:
case AxisDirection.right:
return _padding.top;
D.assert(constraints.axisDirection != null);
D.assert(constraints.growthDirection != null);
D.assert(resolvedPadding != null);
switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) {
case AxisDirection.up:
case AxisDirection.down:
return resolvedPadding.left;
case AxisDirection.left:
case AxisDirection.right:
return resolvedPadding.top;
return 0.0f;
return null;
public override float childScrollOffset(RenderObject child) {
public override float? childScrollOffset(RenderObject child) {
}
}
var childParentData = (SliverPhysicalParentData) child.parentData;
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
var childParentData = (SliverPhysicalParentData) child.parentData;
context.paintChild(child, offset + childParentData.paintOffset);
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
context.paintChild(child, offset + childParentData.paintOffset);
base.debugPaint(context, offset);
D.assert(() => {
if (D.debugPaintSizeEnabled) {
Size parentSize = getAbsoluteSizeRelativeToOrigin();
base.debugPaint(context, offset);
D.assert(()=> {
if (D.debugPaintSizeEnabled) {
Size parentSize = getAbsoluteSize();
Size childSize = null;
Size childSize;
childSize = child.getAbsoluteSizeRelativeToOrigin();
var childParentData = (SliverPhysicalParentData) child.parentData;
innerRect = (offset + childParentData.paintOffset) & childSize;
childSize = child.getAbsoluteSize();
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
innerRect = (offset + childParentData.paintOffset) & childSize;
}
public class RenderSliverPadding : RenderSliverEdgeInsetsPadding {
public RenderSliverPadding(
EdgeInsets padding = null,
TextDirection? textDirection = null,
RenderSliver child = null
) {
D.assert(padding != null);
D.assert(padding.isNonNegative);
_padding = padding;
_textDirection = textDirection ?? TextDirection.ltr;
this.child = child;
}
EdgeInsets resolvedPadding {
get { return _resolvedPadding;}
}
EdgeInsets _resolvedPadding;
void _resolve() {
if (resolvedPadding != null)
return;
_resolvedPadding = padding.resolve(textDirection);
D.assert(resolvedPadding.isNonNegative);
}
void _markNeedsResolution() {
_resolvedPadding = null;
markNeedsLayout();
}
public EdgeInsets padding {
get { return _padding; }
set {
D.assert(value != null);
D.assert(value.isNonNegative);
if (_padding == value) {
return;
}
_padding = value;
markNeedsLayout();
}
}
EdgeInsets _padding;
public TextDirection textDirection {
get { return _textDirection;}
set {
if (_textDirection == value)
return;
_textDirection = value;
//_markNeedsResolution();
}
}
TextDirection _textDirection;
protected override void performLayout() {
_resolve();
base.performLayout();
}
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding));
properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding));
properties.add(new EnumProperty<TextDirection>("textDirection", textDirection, defaultValue: null));
}
}

90
com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs


using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
using UnityEngine;
using AsyncCallback = Unity.UIWidgets.foundation.AsyncCallback;
public class OverScrollHeaderStretchConfiguration {
/// Creates an object that specifies how a stretched header may activate an
/// [AsyncCallback].
OverScrollHeaderStretchConfiguration(
float stretchTriggerOffset = 100.0f,
AsyncCallback onStretchTrigger = null
) {
D.assert(stretchTriggerOffset != null);
this.stretchTriggerOffset = stretchTriggerOffset;
this.onStretchTrigger = onStretchTrigger;
}
public readonly float stretchTriggerOffset;
public readonly AsyncCallback onStretchTrigger;
}
public RenderSliverPersistentHeader(RenderBox child = null) {
public RenderSliverPersistentHeader(
RenderBox child = null,
OverScrollHeaderStretchConfiguration stretchConfiguration = null
) {
this.stretchConfiguration = stretchConfiguration;
}
public virtual float? maxExtent { get; }

bool _needsUpdateChild = true;
float _lastShrinkOffset = 0.0f;
bool _lastOverlapsContent = false;
public OverScrollHeaderStretchConfiguration stretchConfiguration;
protected virtual void updateChild(float shrinkOffset, bool overlapsContent) {
protected void updateChild(float shrinkOffset, bool overlapsContent) {
}
public override void markNeedsLayout() {

);
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
return base.childMainAxisPosition(this.child);
}

constraints.growthDirection)) {
case AxisDirection.up:
offset += new Offset(0.0f,
geometry.paintExtent - childMainAxisPosition(child) - childExtent);
geometry.paintExtent - childMainAxisPosition(child)?? 0.0f - childExtent);
offset += new Offset(0.0f, childMainAxisPosition(child));
offset += new Offset(0.0f, childMainAxisPosition(child) ?? 0.0f);
geometry.paintExtent - childMainAxisPosition(child) - childExtent,
geometry.paintExtent - childMainAxisPosition(child) ?? 0.0f - childExtent,
offset += new Offset(childMainAxisPosition(child), 0.0f);
offset += new Offset(childMainAxisPosition(child) ?? 0.0f, 0.0f);
break;
}

public abstract class RenderSliverScrollingPersistentHeader : RenderSliverPersistentHeader {
public RenderSliverScrollingPersistentHeader(
RenderBox child = null
) : base(child: child) {
RenderBox child = null,
OverScrollHeaderStretchConfiguration stretchConfiguration = null
) : base(child: child,
stretchConfiguration: stretchConfiguration) {
protected float updateGeometry() {
float? stretchOffset = 0.0f;
if (stretchConfiguration != null && _childPosition == 0.0) {
stretchOffset += constraints.overlap.abs();
}
float? maxExtent = this.maxExtent;
float? paintExtent = maxExtent - constraints.scrollOffset;
geometry = new SliverGeometry(
scrollExtent: maxExtent ?? 0.0f,
paintOrigin: Mathf.Min(constraints.overlap, 0.0f),
paintExtent: paintExtent?.clamp(0.0f, constraints.remainingPaintExtent) ?? 0.0f,
maxPaintExtent: maxExtent + stretchOffset ?? 0.0f,
hasVisualOverflow: true// Conservatively say we do have overflow to avoid complexity.
);
return stretchOffset > 0 ? 0.0f :Mathf.Min(0.0f, paintExtent?? 0.0f - childExtent );
}
protected override void performLayout() {
float? maxExtent = this.maxExtent;
layoutChild(constraints.scrollOffset, maxExtent ?? 0.0f);

_childPosition = Mathf.Min(0.0f, paintExtent ?? 0.0f - childExtent);
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
D.assert(child == this.child);
return _childPosition;
}

public RenderSliverPinnedPersistentHeader(
RenderBox child = null
) : base(child: child) {
RenderBox child = null,
OverScrollHeaderStretchConfiguration stretchConfiguration = null
) : base(child: child,
stretchConfiguration: stretchConfiguration) {
}
protected override void performLayout() {

);
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
return 0.0f;
}
}

public abstract class RenderSliverFloatingPersistentHeader : RenderSliverPersistentHeader {
public RenderSliverFloatingPersistentHeader(
RenderBox child = null,
FloatingHeaderSnapConfiguration snapConfiguration = null
) : base(child: child) {
FloatingHeaderSnapConfiguration snapConfiguration = null,
OverScrollHeaderStretchConfiguration stretchConfiguration = null
) : base(
child: child,
stretchConfiguration: stretchConfiguration) {
_snapConfiguration = snapConfiguration;
}

_lastActualScrollOffset = constraints.scrollOffset;
}
public override float childMainAxisPosition(RenderObject child) {
public override float? childMainAxisPosition(RenderObject child) {
D.assert(child == this.child);
return _childPosition;
}

public abstract class RenderSliverFloatingPinnedPersistentHeader : RenderSliverFloatingPersistentHeader {
public RenderSliverFloatingPinnedPersistentHeader(
RenderBox child = null,
FloatingHeaderSnapConfiguration snapConfiguration = null
) : base(child: child, snapConfiguration: snapConfiguration) {
FloatingHeaderSnapConfiguration snapConfiguration = null,
OverScrollHeaderStretchConfiguration stretchConfiguration = null
) : base(child: child,
snapConfiguration: snapConfiguration,
stretchConfiguration: stretchConfiguration) {
}
protected override float updateGeometry() {

float? clampedPaintExtent =
paintExtent?.clamp(minAllowedExtent ?? 0.0f, constraints.remainingPaintExtent);
float? layoutExtent = maxExtent - constraints.scrollOffset;
float? stretchOffset = stretchConfiguration != null ?
constraints.overlap.abs() :
0.0f;
maxPaintExtent: maxExtent ?? 0.0f,
maxPaintExtent: maxExtent + stretchOffset ?? 0.0f,
maxScrollObstructionExtent: maxExtent ?? 0.0f,
hasVisualOverflow: true
);

35
com.unity.uiwidgets/Runtime/rendering/stack.cs


public RenderStack(
StackFit? fit,
Overflow? overflow,
TextDirection textDirection,
this.textDirection = textDirection;
_alignment = alignment ?? Alignment.topLeft;
_fit = fit ?? StackFit.loose;
_overflow = overflow ?? Overflow.clip;

child.parentData = new StackParentData();
}
}
Alignment _resolvedAlignment;
void _markNeedResolution() {
_resolvedAlignment = null;
markNeedsLayout();
}
public TextDirection textDirection {
get {
return _textDirection;
}
set {
if (_textDirection == value)
return;
_textDirection = value;
_markNeedResolution();
}
}
TextDirection _textDirection;
Alignment _alignment;
public Alignment alignment {

return extent;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return _getIntrinsicDimension((RenderBox child) => child.getMinIntrinsicHeight(width));
}

public RenderIndexedStack(
List<RenderBox> children = null,
Alignment alignment = null,
TextDirection textDirection = default,
) : base(fit: null, overflow: null, children: children, alignment: alignment ?? Alignment.topLeft) {
) : base(fit: null, overflow: null, textDirection: textDirection, children: children, alignment: alignment ?? Alignment.topLeft) {
_index = index;
}

6
com.unity.uiwidgets/Runtime/rendering/table.cs


}
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
D.assert(_children.Count == rows * columns);
float totalMinWidth = 0.0f;
for (int x = 0; x < columns; x++) {

return totalMinWidth;
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
D.assert(_children.Count == rows * columns);
float totalMaxWidth = 0.0f;
for (int x = 0; x < columns; x++) {

return totalMaxWidth;
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
D.assert(_children.Count == rows * columns);
List<float> widths = _computeColumnWidths(BoxConstraints.tightForFinite(width: width));
float rowTop = 0.0f;

2
com.unity.uiwidgets/Runtime/rendering/view.cs


}
public override string ToString() {
return $"${size} at ${devicePixelRatio}x";
return $"{size} at {devicePixelRatio}x";
}
}

16
com.unity.uiwidgets/Runtime/rendering/viewport.cs


return true;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
D.assert(debugThrowIfNotCheckingIntrinsics());
return 0.0f;
}

if (child.parent is RenderSliver) {
RenderSliver parent = (RenderSliver) child.parent;
leadingScrollOffset += parent.childScrollOffset(child);
leadingScrollOffset += parent.childScrollOffset(child) ?? 0.0f;
}
else {
onlySlivers = false;

protected override Offset paintOffsetOf(RenderSliver child) {
var childParentData = (SliverLogicalParentData) child.parentData;
return computeAbsolutePaintOffset(child, childParentData.layoutOffset, GrowthDirection.forward);
return computeAbsolutePaintOffset(child, childParentData.layoutOffset ?? 0.0f, GrowthDirection.forward);
}
protected override float scrollOffsetOf(RenderSliver child, float scrollOffsetWithinChild) {

child.constraints.axisDirection, child.constraints.growthDirection)) {
case AxisDirection.down:
case AxisDirection.right:
return parentMainAxisPosition - childParentData.layoutOffset;
return parentMainAxisPosition - childParentData.layoutOffset ?? 0.0f;
return (size.height - parentMainAxisPosition) - childParentData.layoutOffset;
return (size.height - parentMainAxisPosition) - childParentData.layoutOffset ?? 0.0f;
return (size.width - parentMainAxisPosition) - childParentData.layoutOffset;
return (size.width - parentMainAxisPosition) - childParentData.layoutOffset ?? 0.0f;
}
D.assert(false);

6
com.unity.uiwidgets/Runtime/rendering/wrap.cs


return width;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
switch (direction) {
case Axis.horizontal:
float width = 0.0f;

throw new Exception("Unknown axis: " + direction);
}
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
switch (direction) {
case Axis.horizontal:
float width = 0.0f;

throw new Exception("Unknown axis: " + direction);
}
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
switch (direction) {
case Axis.horizontal:
return _computeIntrinsicHeightForWidth(width);

42
com.unity.uiwidgets/Runtime/ui2/compositing.cs


});
return true;
}
public unsafe TransformEngineLayer pushTransform(
float[] matrix4,
TransformEngineLayer oldLayer = null

D.assert(_debugPushLayer(layer));
return layer;
}
public ShaderMaskEngineLayer pushShaderMask(
Shader shader,
Rect maskRect,
BlendMode blendMode,
ShaderMaskEngineLayer oldLayer = null
) {
D.assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, "pushShaderMask"));
ShaderMaskEngineLayer layer = new ShaderMaskEngineLayer(SceneBuilder_pushShaderMask(
_ptr,
shader._ptr,
maskRect.left,
maskRect.right,
maskRect.top,
maskRect.bottom,
(int)blendMode
));
D.assert(_debugPushLayer(layer));
return layer;
}
public PhysicalShapeEngineLayer pushPhysicalShape(
Path path,

Clip clipBehavior = Clip.none,
PhysicalShapeEngineLayer oldLayer = null) {
D.assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, "PhysicalShapeEngineLayer"));
PhysicalShapeEngineLayer layer = new PhysicalShapeEngineLayer(SceneBuilder_pushPhysicalShape(_ptr, path._ptr, elevation, (int)color.value, (int)(shadowColor?.value ?? 0xFF000000), (int)clipBehavior));
PhysicalShapeEngineLayer layer = new PhysicalShapeEngineLayer(
SceneBuilder_pushPhysicalShape(_ptr,
path._ptr,
elevation,
(int)color.value,
(int)(shadowColor?.value ?? 0xFF000000),
(int)clipBehavior));
D.assert(_debugPushLayer(layer));
return layer;
}

[DllImport(NativeBindings.dllName)]
static extern void SceneBuilder_addPerformanceOverlay(int enabledOptions, float left, float right, float top,
float bottom);
[DllImport(NativeBindings.dllName)]
static extern IntPtr SceneBuilder_pushShaderMask(
IntPtr ptr,
IntPtr shader,
float maskRectLeft,
float maskRectRight,
float maskRectTop,
float maskRectBottom,
int blendMod);
[DllImport(NativeBindings.dllName)]
static extern IntPtr SceneBuilder_pushPhysicalShape(IntPtr ptr, IntPtr path, float evelation, int color,
int shadowColor, int clipBehavior);

4
com.unity.uiwidgets/Runtime/widgets/actions.cs


public override bool updateShouldNotify(InheritedWidget oldWidget) {
oldWidget = (Actions) oldWidget;
var dispatcherBool = ((Actions) oldWidget).dispatcher != dispatcher;
bool actionBool = false;
if (((Actions) oldWidget).actions == actions)
actionBool = true;
bool actionBool = ((Actions) oldWidget).actions == actions;
foreach (var actionsKey in ((Actions) oldWidget).actions.Keys) {
if (!actions.ContainsKey(actionsKey) ||
actions[actionsKey] != ((Actions) oldWidget).actions[actionsKey]) {

4
com.unity.uiwidgets/Runtime/widgets/app.cs


"pageRouteBuilder must be specified so that the default handler " +
"will know what kind of PageRoute transition to build."
);
}
}
// [!!!]too many errors here
/*public static readonly Dictionary<LogicalKeySet, Intent> _defaultShortcuts = new Dictionary<LogicalKeySet, Intent>(){
// Activation
{new LogicalKeySet(LogicalKeyboardKey.enter), new Intent(ActivateAction.key)},

16
com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs


return false;
}
/*ParentDataElement _getChildElement() {
D.assert(mounted);
Element element = (Element) context;
Element childElement = null;
element.visitChildren((Element child) => { childElement = child; });
D.assert(childElement == null || childElement is ParentDataElement);
return (ParentDataElement) childElement;
}*/
ParentDataElement<KeepAliveParentDataMixin> _getChildElement() {
D.assert(mounted);
Element element = (Element) context;

D.assert(childElement == null || childElement is ParentDataElement<KeepAliveParentDataMixin>);
return (ParentDataElement<KeepAliveParentDataMixin>) childElement;
}
//void _updateParentDataOfChild(ParentDataElement childElement) {
// childElement.applyWidgetOutOfTurn((ParentDataWidget<KeepAliveParentDataMixin>) build(context));
// }
void _updateParentDataOfChild(ParentDataElement<KeepAliveParentDataMixin> childElement) {
childElement.applyWidgetOutOfTurn((ParentDataWidget<KeepAliveParentDataMixin>) build(context));
}

92
com.unity.uiwidgets/Runtime/widgets/basic.cs


Alignment alignment = null,
StackFit fit = StackFit.loose,
Overflow overflow = Overflow.clip,
TextDirection textDirection = default,
this.textDirection = textDirection;
public readonly TextDirection textDirection;
textDirection: Directionality.of(context),
fit: fit,
overflow: overflow
);

var renderObject = (RenderStack) renderObjectRaw;
renderObject.alignment = alignment;
renderObject.textDirection = Directionality.of(context);
renderObject.fit = fit;
renderObject.overflow = overflow;
}

properties.add(new DiagnosticsProperty<Alignment>("alignment", alignment));
properties.add(new EnumProperty<TextDirection>("textDirection", textDirection, defaultValue: null));
properties.add(new EnumProperty<StackFit>("fit", fit));
properties.add(new EnumProperty<Overflow>("overflow", overflow));
}

defaultValue: VerticalDirection.down));
}
}
public class ShaderMask : SingleChildRenderObjectWidget {
public ShaderMask(
Key key = null,
ShaderCallback shaderCallback = null,
BlendMode blendMode = BlendMode.modulate,
Widget child = null
) : base(key: key, child: child){
D.assert(shaderCallback != null);
D.assert(blendMode != null);
}
public readonly ShaderCallback shaderCallback;
public readonly BlendMode blendMode;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderShaderMask(
shaderCallback: shaderCallback,
blendMode: blendMode
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderShaderMask)renderObject;
((RenderShaderMask)renderObject).shaderCallback = shaderCallback;
((RenderShaderMask)renderObject).blendMode = blendMode;
}
}
public class PhysicalModel : SingleChildRenderObjectWidget {
public PhysicalModel(

}
}
//[!!!] class Flow?
/*public class Flow : MultiChildRenderObjectWidget {
/// Creates a flow layout.
///

public override Widget build(BuildContext context) {
return builder(context);
}
}
public class ColoredBox : SingleChildRenderObjectWidget {
/// Creates a widget that paints its area with the specified [Color].
///
/// The [color] parameter must not be null.
public ColoredBox(Color color = null, Widget child = null, Key key = null) : base(key: key, child: child) {
D.assert(color != null);
}
/// The color to paint the background area with.
public readonly Color color;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderColoredBox(color: color);
}
public void updateRenderObject(BuildContext context, _RenderColoredBox renderObject) {
renderObject.color = color;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Color>("color", color));
}
}
public class _RenderColoredBox : RenderProxyBoxWithHitTestBehavior {
public _RenderColoredBox(Color color = null)
: base(behavior: HitTestBehavior.opaque) {
_color = color;
}
public Color color {
get { return _color; }
set {
D.assert(value != null);
if (value == _color) {
return;
}
_color = value;
markNeedsPaint();
}
}
Color _color;
public override void paint(PaintingContext context, Offset offset) {
if (size > Size.zero) {
Paint paint = new Paint();
paint.color = color;
context.canvas.drawRect(offset & size, paint);
}
if (child != null) {
context.paintChild(child, offset);
}
}
}
}

50
com.unity.uiwidgets/Runtime/widgets/binding.cs


using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
using UnityEngine;

void _handleBuildScheduled() {
D.assert(() => {
if (debugBuildingDirtyElements) {
throw new UIWidgetsError(
"Build scheduled during frame.\n" +
"While the widget tree was being built, laid out, and painted, " +
"a new frame was scheduled to rebuild the widget tree. " +
"This might be because setState() was called from a layout or " +
"paint callback. " +
"If a change is needed to the widget tree, it should be applied " +
"as the tree is being built. Scheduling a change for the subsequent " +
"frame instead results in an interface that lags behind by one frame. " +
"If this was done to make your build dependent on a size measured at " +
"layout time, consider using a LayoutBuilder, CustomSingleChildLayout, " +
"or CustomMultiChildLayout. If, on the other hand, the one frame delay " +
"is the desired effect, for example because this is an " +
"animation, consider scheduling the frame in a post-frame callback " +
"using SchedulerBinding.addPostFrameCallback or " +
"using an AnimationController to trigger the animation."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Build scheduled during frame."),
new ErrorDescription(
"While the widget tree was being built, laid out, and painted, " +
"a new frame was scheduled to rebuild the widget tree."
),
new ErrorHint(
"This might be because setState() was called from a layout or " +
"paint callback. " +
"If a change is needed to the widget tree, it should be applied " +
"as the tree is being built. Scheduling a change for the subsequent " +
"frame instead results in an interface that lags behind by one frame. " +
"If this was done to make your build dependent on a size measured at " +
"layout time, consider using a LayoutBuilder, CustomSingleChildLayout, " +
"or CustomMultiChildLayout. If, on the other hand, the one frame delay " +
"is the desired effect, for example because this is an " +
"animation, consider scheduling the frame in a post-frame callback " +
"using SchedulerBinding.addPostFrameCallback or " +
"using an AnimationController to trigger the animation."
)
});
}
return true;

}
}
bool _readyToProduceFrames = false;
public RenderObjectToWidgetElement<RenderBox> renderViewElement {
get { return _renderViewElement; }
}

}
public void attachRootWidget(Widget rootWidget) {
_readyToProduceFrames = true;
_renderViewElement = new RenderObjectToWidgetAdapter<RenderBox>(
container: renderView,
debugShortDescription: "[root]",

bool isRootWidgetAttached {
get { return _renderViewElement != null; }
}
}
public class RenderObjectToWidgetAdapter<T> : RenderObjectWidget where T : RenderObject {

element.assignOwner(owner);
});
owner.buildScope(element, () => { element.mount(null, null); });
SchedulerBinding.instance.ensureVisualUpdate();
}
else {
element._newWidget = this;

internal override void forgetChild(Element child) {
D.assert(child == _child);
_child = null;
base.forgetChild(child);
}
public override void mount(Element parent, object newSlot) {

if (_newWidget != null) {
Widget newWidget = _newWidget;
_newWidget = null;
update(newWidget);
update((RenderObjectToWidgetAdapter<T>)newWidget);
}
base.performRebuild();

57
com.unity.uiwidgets/Runtime/widgets/container.cs


BoxConstraints constraints = null,
EdgeInsets margin = null,
Matrix4 transfrom = null,
Widget child = null
) : base(key) {
Widget child = null,
Clip clipBehavior = Clip.none
) : base(key: key) {
D.assert(margin == null || margin.isNonNegative);
D.assert(padding == null || padding.isNonNegative);
D.assert(decoration == null || decoration.debugAssertIsValid());

"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"."
);
D.assert(clipBehavior != null);
this.alignment = alignment;
this.padding = padding;
foregroundDecoration = forgroundDecoration;

this.color = color;
this.clipBehavior = clipBehavior;
}
public readonly Widget child;

public readonly BoxConstraints constraints;
public readonly EdgeInsets margin;
public readonly Matrix4 transform;
public readonly Color color;
public readonly Clip clipBehavior;
EdgeInsets _paddingIncludingDecoration {
get {

current = new Padding(padding: effetivePadding, child: current);
}
if (color != null)
current = new ColoredBox(color: color, child: current);
if (decoration != null) {
current = new DecoratedBox(decoration: decoration, child: current);
}

current = new Transform(transform: new Matrix4(transform), child: current);
}
if (clipBehavior != Clip.none) {
current = new ClipPath(
clipper: new _DecorationClipper(
textDirection: Directionality.of(context),
decoration: decoration
),
clipBehavior: clipBehavior,
child: current
);
}
return current;
}

alignment, showName: false, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding",
padding, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Decoration>("bg",
properties.add(new DiagnosticsProperty<Clip>("clipBehavior", clipBehavior, defaultValue: Clip.none));
if (color != null)
properties.add(new DiagnosticsProperty<Color>("bg", color));
else
properties.add(new DiagnosticsProperty<Decoration>("bg",
decoration, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Decoration>("fg",
foregroundDecoration, defaultValue: foundation_.kNullDefaultValue));

margin, defaultValue: foundation_.kNullDefaultValue));
properties.add(ObjectFlagProperty<Matrix4>.has("transform",
transform));
}
}
/// A clipper that uses [Decoration.getClipPath] to clip.
public class _DecorationClipper : CustomClipper<Path> {
public _DecorationClipper(
TextDirection textDirection = TextDirection.rtl,
Decoration decoration = null
) {
D.assert(decoration != null);
textDirection = TextDirection.ltr;
}
public readonly TextDirection textDirection;
public readonly Decoration decoration;
public override Path getClip(Size size) {
return decoration.getClipPath(Offset.zero & size, textDirection);
}
public override bool shouldReclip(CustomClipper<Path> oldClipper) {
return ((_DecorationClipper)oldClipper).decoration != decoration
|| ((_DecorationClipper)oldClipper).textDirection != textDirection;
}
}
}

53
com.unity.uiwidgets/Runtime/widgets/debug.cs


public static bool debugCheckHasMediaQuery(BuildContext context) {
D.assert(() => {
if (!(context.widget is MediaQuery) && context.ancestorWidgetOfExactType(typeof(MediaQuery)) == null) {
Element element = (Element) context;
throw new UIWidgetsError(
"No MediaQuery widget found.\n" +
context.widget.GetType() + " widgets require a MediaQuery widget ancestor.\n" +
"The specific widget that could not find a MediaQuery ancestor was:\n" +
" " + context.widget + "\n" +
"The ownership chain for the affected widget is:\n" +
" " + element.debugGetCreatorChain(10) + "\n" +
"Typically, the MediaQuery widget is introduced by the MaterialApp or " +
"WidgetsApp widget at the top of your application widget tree."
);
if (!(context.widget is MediaQuery) && context.findAncestorWidgetOfExactType<MediaQuery>() == null) {
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary("No MediaQuery widget found."),
new ErrorDescription($"{context.widget.GetType()} widgets require a MediaQuery widget ancestor."),
context.describeWidget("The specific widget that could not find a MediaQuery ancestor was"),
context.describeOwnershipChain("The ownership chain for the affected widget is"),
new ErrorHint(
"Typically, the MediaQuery widget is introduced by the MaterialApp or " +
"WidgetsApp widget at the top of your application widget tree."
)
});
}
return true;

public static bool debugCheckHasDirectionality(BuildContext context) {
D.assert(() => {
if (!(context.widget is Directionality) &&
context.ancestorWidgetOfExactType(typeof(Directionality)) == null) {
Element element = (Element) context;
throw new UIWidgetsError(
"No Directionality widget found.\n" +
context.widget.GetType() + " widgets require a Directionality widget ancestor.\n" +
"The specific widget that could not find a Directionality ancestor was:\n" +
" " + context.widget + "\n" +
"The ownership chain for the affected widget is:\n" +
" " + element.debugGetCreatorChain(10) + "\n" +
"Typically, the Directionality widget is introduced by the MaterialApp " +
"or WidgetsApp widget at the top of your application widget tree. It " +
"determines the ambient reading direction and is used, for example, to " +
"determine how to lay out text, how to interpret \"start\" and \"end\" " +
"values, and to resolve EdgeInsetsDirectional, " +
"AlignmentDirectional, and other *Directional objects.");
context.findAncestorWidgetOfExactType<Directionality>() == null) {
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("No Directionality widget found."),
new ErrorDescription("${context.widget.runtimeType} widgets require a Directionality widget ancestor.\n"),
context.describeWidget("The specific widget that could not find a Directionality ancestor was"),
context.describeOwnershipChain("The ownership chain for the affected widget is"),
new ErrorHint(
"Typically, the Directionality widget is introduced by the MaterialApp " +
"or WidgetsApp widget at the top of your application widget tree. It " +
"determines the ambient reading direction and is used, for example, to " +
"determine how to lay out text, how to interpret \"start\" and \"end\" " +
"values, and to resolve EdgeInsetsDirectional, " +
"AlignmentDirectional, and other *Directional objects."
)
});
}
return true;

14
com.unity.uiwidgets/Runtime/widgets/dismissible.cs


DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(key: key) {
D.assert(key != null);
D.assert(secondaryBackground != null ? background != null : true);
D.assert(secondaryBackground == null || background != null);
this.resizeDuration = resizeDuration ?? new TimeSpan(0, 0, 0, 0, 300);
this.dismissThresholds = dismissThresholds ?? new Dictionary<DismissDirection?, float?>();
this.movementDuration = movementDuration ?? new TimeSpan(0, 0, 0, 0, 200);

D.assert(() => {
if (_resizeAnimation.status != AnimationStatus.forward) {
D.assert(_resizeAnimation.status == AnimationStatus.completed);
throw new UIWidgetsError(
"A dismissed Dismissible widget is still part of the tree.\n" +
"Make sure to implement the onDismissed handler and to immediately remove the Dismissible\n" +
"widget from the application once that handler has fired."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("A dismissed Dismissible widget is still part of the tree."),
new ErrorHint(
"Make sure to implement the onDismissed handler and to immediately remove the Dismissible " +
"widget from the application once that handler has fired."
)
});
}
return true;

16
com.unity.uiwidgets/Runtime/widgets/drag_target.cs


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

}
void _routePointer(PointerEvent pEvent) {
void _routePointer(PointerDownEvent pEvent) {
if (widget.maxSimultaneousDrags != null &&
_activeCount >= widget.maxSimultaneousDrags) {
return;

D.assert(!_candidateAvatars.Contains(avatar));
D.assert(!_rejectedAvatars.Contains(avatar));
if (avatar.data is T && (widget.onWillAccept == null || widget.onWillAccept(avatar.data))) {
if (avatar.data is _DragAvatar<T> && (widget.onWillAccept == null || widget.onWillAccept(avatar.data))) {
_rejectedAvatars.Add(avatar);
return false;
else {
setState(() => {
_rejectedAvatars.Add(avatar);
});
return false;
}
}
public void didLeave(_DragAvatar<T> avatar) {

}
public Widget _build(BuildContext context) {
RenderBox box = (RenderBox) overlayState.context.findRenderObject();
RenderBox box = overlayState.context.findRenderObject() as RenderBox;
Offset overlayTopLeft = box.localToGlobal(Offset.zero);
return new Positioned(
left: _lastOffset.dx - overlayTopLeft.dx,

446
com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.rendering;
using Debug = System.Diagnostics.Debug;
using Object = System.Object;
public class FadeInImage : StatefulWidget {
public class FadeInImage : StatelessWidget {
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
TimeSpan? fadeOutDuration = null,
Curve fadeOutCurve = null,
TimeSpan? fadeInDuration = null,

D.assert(fadeInCurve != null);
D.assert(alignment != null);
this.placeholder = placeholder;
this.placeholderErrorBuilder = placeholderErrorBuilder;
this.imageErrorBuilder = imageErrorBuilder;
this.width = width;
this.height = height;
this.fit = fit;

public static FadeInImage memoryNetwork(
byte[] placeholder,
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
float placeholderScale = 1.0f,
float imageScale = 1.0f,
TimeSpan? fadeOutDuration = null,

BoxFit? fit = null,
Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
Key key = null
Key key = null,
int placeholderCacheWidth = default,
int placeholderCacheHeight = default,
int imageCacheWidth = default,
int imageCacheHeight = default
) {
D.assert(placeholder != null);
D.assert(image != null);

D.assert(alignment != null);
var memoryImage = new MemoryImage(placeholder, placeholderScale);
var networkImage = new NetworkImage(image, imageScale);
/*placeholder = ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
new MemoryImage(placeholder, scale: placeholderScale));
image = ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight,
new NetworkImage(image, scale: imageScale));*/
memoryImage,
networkImage,
fadeOutDuration,
fadeOutCurve,
fadeInDuration,
fadeInCurve,
width, height,
fit,
alignment,
repeat,
key
placeholder: memoryImage,
placeholderErrorBuilder: placeholderErrorBuilder,
image: networkImage,
imageErrorBuilder: imageErrorBuilder,
fadeOutDuration: fadeOutDuration,
fadeOutCurve: fadeOutCurve,
fadeInDuration: fadeInDuration,
fadeInCurve: fadeInCurve,
width: width, height: height,
fit: fit,
alignment: alignment,
repeat: repeat,
key: key
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
AssetBundle bundle = null,
float? placeholderScale = null,
float imageScale = 1.0f,

BoxFit? fit = null,
Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
Key key = null
Key key = null,
int placeholderCacheWidth = default,
int placeholderCacheHeight = default,
int imageCacheWidth = default,
int imageCacheHeight = default
) {
D.assert(placeholder != null);
D.assert(image != null);

var imageProvider = placeholderScale != null
? new ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale ?? 1.0f)
: (ImageProvider) new AssetImage(placeholder, bundle: bundle);
/*placeholder = placeholderScale != null
? ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale))
: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, AssetImage(placeholder, bundle: bundle));*/
imageProvider,
networkImage,
fadeOutDuration,
fadeOutCurve,
fadeInDuration,
fadeInCurve,
width, height,
fit,
alignment,
repeat,
key
placeholder: imageProvider,
placeholderErrorBuilder: placeholderErrorBuilder,
image: networkImage,
imageErrorBuilder: imageErrorBuilder,
fadeOutDuration: fadeOutDuration,
fadeOutCurve: fadeOutCurve,
fadeInDuration: fadeInDuration,
fadeInCurve: fadeInCurve,
width: width, height: height,
fit: fit,
alignment: alignment,
repeat: repeat,
key: key
public readonly ImageErrorWidgetBuilder placeholderErrorBuilder;
public readonly ImageErrorWidgetBuilder imageErrorBuilder;
public readonly TimeSpan fadeOutDuration;
public readonly Curve fadeOutCurve;
public readonly TimeSpan fadeInDuration;

public readonly Alignment alignment;
public readonly ImageRepeat repeat;
public override State createState() {
return new _FadeInImageState();
}
}
enum FadeInImagePhase {
start,
waiting,
fadeOut,
fadeIn,
completed
}
delegate void _ImageProviderResolverListener();
class _ImageProviderResolver {
public _ImageProviderResolver(
_FadeInImageState state,
_ImageProviderResolverListener listener
public Image _image(
ImageProvider image = null,
ImageErrorWidgetBuilder errorBuilder = null,
ImageFrameBuilder frameBuilder = null
this.state = state;
this.listener = listener;
D.assert(image != null);
return new Image(
image: image,
//errorBuilder: errorBuilder,
//frameBuilder: frameBuilder,
width: width,
height: height,
fit: fit,
alignment: alignment,
repeat: repeat,
//matchTextDirection: matchTextDirection,
gaplessPlayback: true
);
readonly _FadeInImageState state;
readonly _ImageProviderResolverListener listener;
FadeInImage widget {
get { return state.widget; }
public override Widget build(BuildContext context) {
Widget result = _image(
image: image,
errorBuilder: imageErrorBuilder,
frameBuilder: (BuildContext context1, Widget child, int frame, bool wasSynchronouslyLoaded) => {
if (wasSynchronouslyLoaded)
return child;
return new _AnimatedFadeOutFadeIn(
key: key,
target: child,
placeholder: _image(
image: placeholder,
errorBuilder: placeholderErrorBuilder
),
isTargetLoaded: frame != null,
fadeInDuration: fadeInDuration,
fadeOutDuration: fadeOutDuration,
fadeInCurve: fadeInCurve,
fadeOutCurve: fadeOutCurve
);
}
);
return result;
}
public ImageStream _imageStream;
public ImageInfo _imageInfo;
public void resolve(ImageProvider provider) {
ImageStream oldImageStream = _imageStream;
Size size = null;
if (widget.width != null && widget.height != null) {
size = new Size((int) widget.width, (int) widget.height);
}
_imageStream = provider.resolve(ImageUtils.createLocalImageConfiguration(state.context, size));
D.assert(_imageStream != null);
// TODO: update
// if (_imageStream.key != oldImageStream?.key) {
// oldImageStream?.removeListener(_handleImageChanged);
// _imageStream.addListener(_handleImageChanged);
// }
public class _AnimatedFadeOutFadeIn : ImplicitlyAnimatedWidget {
public _AnimatedFadeOutFadeIn(
Key key,
Widget target,
Widget placeholder,
bool isTargetLoaded,
TimeSpan fadeOutDuration,
TimeSpan fadeInDuration,
Curve fadeOutCurve,
Curve fadeInCurve
) : base(key: key, duration: fadeInDuration + fadeOutDuration) {
D.assert(target != null);
D.assert(placeholder != null);
D.assert(isTargetLoaded != null);
D.assert(fadeOutDuration != null);
D.assert(fadeOutCurve != null);
D.assert(fadeInDuration != null);
D.assert(fadeInCurve != null);
this.target = target;
this.placeholder = placeholder;
this.isTargetLoaded = isTargetLoaded;
this.fadeInDuration = fadeInDuration;
this.fadeOutDuration = fadeOutDuration;
this.fadeInCurve = fadeInCurve;
this.fadeOutCurve = fadeOutCurve;
void _handleImageChanged(ImageInfo imageInfo, bool synchronousCall) {
_imageInfo = imageInfo;
listener();
}
public readonly Widget target;
public readonly Widget placeholder;
public readonly bool isTargetLoaded;
public readonly TimeSpan? fadeInDuration;
public readonly TimeSpan? fadeOutDuration;
public readonly Curve fadeInCurve;
public readonly Curve fadeOutCurve;
public void stopListening() {
// TODO: update
// _imageStream?.removeListener(_handleImageChanged);
}
}
public override State createState() => new _AnimatedFadeOutFadeInState();
class _FadeInImageState : TickerProviderStateMixin<FadeInImage> {
_ImageProviderResolver _imageResolver;
_ImageProviderResolver _placeholderResolver;
AnimationController _controller;
Animation<float> _animation;
FadeInImagePhase _phase = FadeInImagePhase.start;
public class _AnimatedFadeOutFadeInState : ImplicitlyAnimatedWidgetState<_AnimatedFadeOutFadeIn> {
FloatTween _targetOpacity;
FloatTween _placeholderOpacity;
Animation<float> _targetOpacityAnimation;
Animation<float> _placeholderOpacityAnimation;
public override void initState() {
_imageResolver = new _ImageProviderResolver(state: this, _updatePhase);
_placeholderResolver = new _ImageProviderResolver(state: this, listener: () => {
setState(() => {
// Trigger rebuild to display the placeholder image
});
});
_controller = new AnimationController(
value: 1.0f,
vsync: this
);
_controller.addListener(() => {
setState(() => {
// Trigger rebuild to update opacity value.
});
});
_controller.addStatusListener(status => { _updatePhase(); });
base.initState();
}
/*@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_targetOpacity = visitor(
_targetOpacity,
widget.isTargetLoaded ? 1.0 : 0.0,
(dynamic value) => Tween<double>(begin: value as double),
) as Tween<double>;
_placeholderOpacity = visitor(
_placeholderOpacity,
widget.isTargetLoaded ? 0.0 : 1.0,
(dynamic value) => Tween<double>(begin: value as double),
) as Tween<double>;
}*/
public override void didChangeDependencies() {
_resolveImage();
base.didChangeDependencies();
}
protected override void forEachTween(TweenVisitor visitor) {
_targetOpacity = (FloatTween) visitor.visit(
state: this,
tween: _targetOpacity,
targetValue: widget.isTargetLoaded ? 1.0f : 0.0f,
constructor: (float value) => new FloatTween(begin: value, 0));
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
FadeInImage fadeInImage = oldWidget as FadeInImage;
if (widget.image != fadeInImage.image || widget.placeholder != fadeInImage.placeholder) {
_resolveImage();
_placeholderOpacity = (FloatTween) visitor.visit(
state: this,
tween: _placeholderOpacity,
targetValue: widget.isTargetLoaded ? 0.0f : 1.0f,
constructor: (float value) => new FloatTween(begin: value, 0));
}
void _resolveImage() {
_imageResolver.resolve(widget.image);
protected override void didUpdateTweens() {
List<TweenSequenceItem<float>> list = new List<TweenSequenceItem<float>>();
if (_isShowingPlaceholder) {
_placeholderResolver.resolve(widget.placeholder);
}
Debug.Assert(widget.fadeOutDuration?.Milliseconds != null,
"widget.fadeOutDuration?.Milliseconds != null");
list.Add(new TweenSequenceItem<float>(
tween: _placeholderOpacity.chain(new CurveTween(curve: widget.fadeOutCurve)),
weight: (float) widget.fadeOutDuration?.Milliseconds
));
if (_phase == FadeInImagePhase.start) {
_updatePhase();
}
}
Debug.Assert(widget.fadeInDuration?.Milliseconds != null,
"widget.fadeInDuration?.Milliseconds != null");
list.Add(new TweenSequenceItem<float>(
tween: new ConstantTween<float>(0),
weight: (float) widget.fadeInDuration?.Milliseconds
));
void _updatePhase() {
setState(() => {
switch (_phase) {
case FadeInImagePhase.start:
if (_imageResolver._imageInfo != null) {
_phase = FadeInImagePhase.completed;
}
else {
_phase = FadeInImagePhase.waiting;
}
//[!!!] drive
/*_placeholderOpacityAnimation = animation.drive(list).addStatusListener((AnimationStatus status) =>{
if (_placeholderOpacityAnimation.isCompleted) {
// Need to rebuild to remove placeholder now that it is invisibile.
setState(() => {});
}
});*/
break;
case FadeInImagePhase.waiting:
if (_imageResolver._imageInfo != null) {
_controller.duration = widget.fadeOutDuration;
_animation = new CurvedAnimation(
parent: _controller,
curve: widget.fadeOutCurve
);
_phase = FadeInImagePhase.fadeOut;
_controller.reverse(1.0f);
}
List<TweenSequenceItem<float>> list2 = new List<TweenSequenceItem<float>>();
list2.Add(new TweenSequenceItem<float>(
tween: new ConstantTween<float>(0),
weight: (float) widget.fadeOutDuration?.Milliseconds
));
list2.Add(new TweenSequenceItem<float>(
tween: _targetOpacity.chain(new CurveTween(curve: widget.fadeInCurve)),
weight: (float) widget.fadeInDuration?.Milliseconds
));
//_targetOpacityAnimation = animation.drive(list2);[!!!] animation.cs drive
if (!widget.isTargetLoaded && _isValid(_placeholderOpacity) && _isValid(_targetOpacity)) {
//controller.value = controller.upperBound;[!!!] animation_controller.cs value set
}
}
break;
case FadeInImagePhase.fadeOut:
if (_controller.status == AnimationStatus.dismissed) {
// Done fading out placeholder. Begin target image fade-in.
_controller.duration = widget.fadeInDuration;
_animation = new CurvedAnimation(
parent: _controller,
curve: widget.fadeInCurve
);
_phase = FadeInImagePhase.fadeIn;
_placeholderResolver.stopListening();
_controller.forward(0.0f);
}
break;
case FadeInImagePhase.fadeIn:
if (_controller.status == AnimationStatus.completed) {
// Done finding in new image.
_phase = FadeInImagePhase.completed;
}
bool _isValid(Tween<float> tween) {
return tween.begin != null && tween.end != null;
}
break;
case FadeInImagePhase.completed:
// Nothing to do.
break;
}
});
}
public override void dispose() {
_imageResolver.stopListening();
_placeholderResolver.stopListening();
_controller.dispose();
base.dispose();
}
public override Widget build(BuildContext context) {
Widget target = new FadeTransition(
opacity: _targetOpacityAnimation,
child: widget.target
);
bool _isShowingPlaceholder {
get {
switch (_phase) {
case FadeInImagePhase.start:
case FadeInImagePhase.waiting:
case FadeInImagePhase.fadeOut:
return true;
case FadeInImagePhase.fadeIn:
case FadeInImagePhase.completed:
return false;
if (_placeholderOpacityAnimation.isCompleted) {
return target;
return true;
return new Stack(
fit: StackFit.passthrough,
alignment: Alignment.center,//AlignmentDirectional.center,[!!!]
textDirection: TextDirection.ltr,
children: new List<Widget>() {
target,
new FadeTransition(
opacity: _placeholderOpacityAnimation,
child: widget.placeholder
)
}
);
}
ImageInfo _imageInfo {
get {
return _isShowingPlaceholder
? _placeholderResolver._imageInfo
: _imageResolver._imageInfo;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("targetOpacity", _targetOpacityAnimation));
properties.add(
new DiagnosticsProperty<Animation<float>>("placeholderOpacity", _placeholderOpacityAnimation));
public override Widget build(BuildContext context) {
D.assert(_phase != FadeInImagePhase.start);
ImageInfo imageInfo = _imageInfo;
return new RawImage(
image: imageInfo?.image,
width: widget.width,
height: widget.height,
scale: imageInfo?.scale ?? 1.0f,
color: Color.fromRGBO(255, 255, 255, _animation?.value ?? 1.0f),
colorBlendMode: BlendMode.modulate,
fit: widget.fit,
alignment: widget.alignment,
repeat: widget.repeat
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<FadeInImagePhase>("phase", _phase));
properties.add(new DiagnosticsProperty<ImageInfo>("pixels", _imageInfo));
properties.add(new DiagnosticsProperty<ImageStream>("image stream", _imageResolver._imageStream));
properties.add(new DiagnosticsProperty<ImageStream>("placeholder stream",
_placeholderResolver._imageStream));
}
}
}

647
com.unity.uiwidgets/Runtime/widgets/focus_manager.cs


}
/*string debugDescribeFocusTree() {
public static string debugDescribeFocusTree() {
}());
});
}*/
}
/*void debugDumpFocusTree() {
public static void debugDumpFocusTree() {
}*/
}
}
public class FocusAttachment {

}
}
public class FocusNode : ChangeNotifier {
//DiagnosticableTreeMixin,
public class FocusNode : DiagnosticableTreeMixinChangeNotifier{
public FocusNode(
string debugLabel = "",
FocusOnKeyCallback onKey = null,

D.assert(canRequestFocus != null);
_skipTraversal = skipTraversal;
_canRequestFocus = canRequestFocus;
/*_onKey = onKey {
this.debugLabel = debugLabel; ///????
}*/
_onKey = onKey;
this.debugLabel = debugLabel;
}
public bool skipTraversal {

BuildContext _context;
FocusOnKeyCallback onKey {
public FocusOnKeyCallback onKey {
get { return _onKey; }
}

List<FocusNode> _descendants;
bool _hasKeyboardToken = false;
FocusNode parent {
public FocusNode parent {
get { return _parent; }
}

}
}
Rect rect {
public Rect rect {
get {
D.assert(
context != null, () =>

D.assert(findFirstFocus != null);
if (!canRequestFocus) {
D.assert(FocusManagerUtils._focusDebug(
"Node NOT requesting focus because canRequestFocus is false: $this"));
$"Node NOT requesting focus because canRequestFocus is false: {this}"));
return;
}

}
/*bool nextFocus() {
public bool nextFocus() {
}*
}
bool previousFocus() {
public bool previousFocus() {
bool focusInDirection(TraversalDirection direction) {
public bool focusInDirection(TraversalDirection direction) {
}*/
}
/*public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
}*/
}
/*public override List<DiagnosticsNode> debugDescribeChildren() {
public override List<DiagnosticsNode> debugDescribeChildren() {
return _children.map<DiagnosticsNode>((FocusNode child) {
return _children.Select((FocusNode child)=> {
}).toList();
}*/
}).ToList();
}
/*public string toStringShort() {//override
public override string toStringShort() {//override
bool hasDebugLabel = debugLabel != null && debugLabel.isNotEmpty();
string nullStr = "";
string extraData = $"{(hasDebugLabel ? debugLabel : nullStr)} " +

return $"{describeIdentity(this)}" + $"{(extraData.isNotEmpty() ? extraData : nullStr)}";
return $"{foundation_.describeIdentity(this)}" + $"{(extraData.isNotEmpty() ? extraData : nullStr)}";
}*/
}
}
public class FocusScopeNode : FocusNode {

public void setFirstFocus(FocusScopeNode scope) {
D.assert(scope != null);
D.assert(scope != this, ()=>"Unexpected self-reference in setFirstFocus.");
D.assert(FocusManagerUtils._focusDebug("Setting scope as first focus in $this to node:", new List<string>{scope.ToString()}));
D.assert(FocusManagerUtils._focusDebug($"Setting scope as first focus in {this} to node:", new List<string>{scope.ToString()}));
if (scope._parent == null) {
_reparent(scope);
}

}
public void autofocus(FocusNode node) {
D.assert(FocusManagerUtils._focusDebug("Node autofocusing: $node"));
D.assert(FocusManagerUtils._focusDebug($"Node autofocusing: {node}"));
if (focusedChild == null) {
if (node._parent == null) {
_reparent(node);

primaryFocus._doRequestFocus(findFirstFocus: findFirstFocus);
}
}
/*public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_focusedChildren.isEmpty()) {
return;
}
List<string> childList = _focusedChildren.reversed.map<string>((FocusNode child) {
return child.toStringShort();
}).toList();
properties.add(new IEnumerableProperty<string>("focusedChildren", childList, defaultValue: new List<string>()));
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_focusedChildren.isEmpty()) {
return;
}
List<string> childList = new List<string>();
_focusedChildren.Reverse();
childList = _focusedChildren.Select((FocusNode child)=> {
return child.toStringShort();
}).ToList();
// properties.add(new IEnumerableProperty<string>("focusedChildren", childList, defaultValue: new List<string>()));
}
public class FocusManager : ChangeNotifier {//DiagnosticableTreeMixin,
public class FocusManager : DiagnosticableTreeMixinChangeNotifier{
//RawKeyboard.instance.addListener(_handleRawKeyEvent);
RawKeyboard.instance.addListener(_handleRawKeyEvent);
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent);
}
public static FocusManager instance {

}
if (newMode != _highlightMode) {
_highlightMode = newMode;
//_notifyHighlightModeListeners();
_notifyHighlightModeListeners();
}
}

public void removeHighlightModeListener(ValueChanged<FocusHighlightMode> listener) => _listeners?.Remove(listener);
/*void _notifyHighlightModeListeners() {
void _notifyHighlightModeListeners() {
List<ValueChanged<FocusHighlightMode>> localListeners = List<ValueChanged<FocusHighlightMode>>.from(_listeners);
List<ValueChanged<FocusHighlightMode>> localListeners = new List<ValueChanged<FocusHighlightMode>>();
foreach (var listener in _listeners) {
localListeners.Add(listener);
}
try {
listener(_highlightMode);
listener(_highlightMode);
} catch (exception, stack) {
InformationCollector collector;
D.assert(() =>{
collector = () sync* {
yield DiagnosticsProperty<FocusManager>(
"The $runtimeType sending notification was",
this,
style: DiagnosticsTreeStyle.errorProperty,
);
};
return true;
}());
FlutterError.reportError(FlutterErrorDetails(
exception: exception,
stack: stack,
library: "widgets library",
context: ErrorDescription("while dispatching notifications for $runtimeType"),
informationCollector: collector,
));
}
}*/
}
public readonly FocusScopeNode rootScope = new FocusScopeNode(debugLabel: "Root Focus Scope");

}
}
/*void _handleRawKeyEvent(RawKeyEvent Event) {
void _handleRawKeyEvent(RawKeyEvent Event) {
if (_lastInteractionWasTouch) {
_lastInteractionWasTouch = false;

D.assert(FocusManagerUtils._focusDebug($"Received key event {Event.logicalKey}"));
//D.assert(FocusManagerUtils._focusDebug($"Received key event {Event.logicalKey}"));
if (_primaryFocus == null) {
D.assert(FocusManagerUtils._focusDebug($"No primary focus for key event, ignored: {Event}"));

bool handled = false;
foreach (FocusNode node in List < FocusNode >{
_primaryFocus, ..._primaryFocus.ancestors
}) {
List<FocusNode> nodes = new List<FocusNode>();
nodes.Add(_primaryFocus);
foreach (var node in _primaryFocus.ancestors) {
nodes.Add(node);
}
foreach (FocusNode node in nodes) {
if (node.onKey != null && node.onKey(node, Event)) {
D.assert(FocusManagerUtils._focusDebug($"Node {node} handled key event {Event}."));
handled = true;

if (!handled) {
D.assert(FocusManagerUtils._focusDebug($"Key event not handled by anyone: {Event}."));
}
}*/
}
public FocusNode primaryFocus {

public FocusNode _markedForFocus;
public void _markDetached(FocusNode node) {
D.assert(FocusManagerUtils._focusDebug($"Node was detached: {node}"));
if (_primaryFocus == node) {
_primaryFocus = null;
}
_dirtyNodes?.Remove(node);
D.assert(FocusManagerUtils._focusDebug($"Node was detached: {node}"));
if (_primaryFocus == node) {
_primaryFocus = null;
}
_dirtyNodes?.Remove(node);
}
public void _markPropertiesChanged(FocusNode node) {

}
}
public void _markNextFocus(FocusNode node) {
public void _markNextFocus(FocusNode node) {
_markedForFocus = null;
_markedForFocus = null;
} else {
_markedForFocus = node;
_markNeedsUpdate();

return;
}
_haveScheduledUpdate = true;
//scheduleMicrotask(_applyFocusChange);
async_.scheduleMicrotask(()=> {
_applyFocusChange();
return null;
});
/*public void reparentIfNeeded(FocusNode node) {
D.assert(node != null);
if (node._parent == null || node._parent == this) {
return;
}
node.unfocus();
D.assert(node._parent == null);
if (_focus == null) {
_setFocus(node);
}
}*/
/*void _applyFocusChange() {
void _applyFocusChange() {
_markedForFocus = rootScope;
_markedForFocus = rootScope;
HashSet<FocusNode> previousPath = previousFocus?.ancestors?.toSet() ?? new HashSet<FocusNode>();
HashSet<FocusNode> nextPath = _markedForFocus.ancestors.toSet();
// Notify nodes that are newly focused.
_dirtyNodes.addAll(nextPath.difference(previousPath));
// Notify nodes that are no longer focused
_dirtyNodes.addAll(previousPath.difference(nextPath));
HashSet<FocusNode> previousPath = previousFocus?.ancestors != null ? new HashSet<FocusNode>(previousFocus.ancestors) : new HashSet<FocusNode>();
HashSet<FocusNode> nextPath = new HashSet<FocusNode>(_markedForFocus.ancestors);
foreach(FocusNode node in FocusTravesalUtils.difference(nextPath,previousPath)) {
_dirtyNodes.Add(node);
}
foreach(FocusNode node in FocusTravesalUtils.difference(previousPath,nextPath)) {
_dirtyNodes.Add(node);
}
_primaryFocus = _markedForFocus;
_markedForFocus = null;
_primaryFocus = _markedForFocus;
_markedForFocus = null;
D.assert(FocusManagerUtils._focusDebug("Updating focus from $previousFocus to $_primaryFocus"));
if (previousFocus != null) {
_dirtyNodes.Add(previousFocus);
}
if (_primaryFocus != null) {
_dirtyNodes.Add(_primaryFocus);
}
D.assert(FocusManagerUtils._focusDebug($"Updating focus from {previousFocus} to {_primaryFocus}"));
if (previousFocus != null) {
_dirtyNodes.Add(previousFocus);
}
if (_primaryFocus != null) {
_dirtyNodes.Add(_primaryFocus);
}
D.assert(FocusManagerUtils._focusDebug("Notifying ${_dirtyNodes.length} dirty nodes:", _dirtyNodes.toList().map<String>((FocusNode node) => node.toString())));
D.assert(FocusManagerUtils._focusDebug($"Notifying {_dirtyNodes.Count} dirty nodes:",
_dirtyNodes.ToList().Select((FocusNode node) => {
return node.toString();
}).ToList()));
node._notify();
node._notify();
notifyListeners();
notifyListeners();
if (_kDebugFocus) {
debugDumpFocusTree();
}
return true;
if (FocusManagerUtils._kDebugFocus) {
FocusManagerUtils.debugDumpFocusTree();
}
return true;
}*/
}
/*public override List<DiagnosticsNode> debugDescribeChildren() {
public override List<DiagnosticsNode> debugDescribeChildren() {
}*/
}
/*public void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties.add(new FlagProperty("haveScheduledUpdate", value: _haveScheduledUpdate, ifTrue: "UPDATE SCHEDULED"));
properties.add(new DiagnosticsProperty<FocusNode>("primaryFocus", primaryFocus, defaultValue: null));
properties.add(new DiagnosticsProperty<FocusNode>("nextFocus", _markedForFocus, defaultValue: null));

}
}*/
}
}
/*
public class FocusNode : ChangeNotifier {
internal FocusScopeNode _parent;
internal FocusManager _manager;
internal bool _hasKeyboardToken = false;
public bool hasFocus {
get {
FocusNode node = null;
if (_manager != null) {
node = _manager._currentFocus;
}
return node == this;
}
}
public bool consumeKeyboardToken() {
if (!_hasKeyboardToken) {
return false;
}
_hasKeyboardToken = false;
return true;
}
public void unfocus() {
if (_parent != null) {
_parent._resignFocus(this);
}
D.assert(_parent == null);
D.assert(_manager == null);
}
public override void dispose() {
if (_manager != null) {
_manager._willDisposeFocusNode(this);
}
if (_parent != null) {
_parent._resignFocus(this);
}
D.assert(_parent == null);
D.assert(_manager == null);
base.dispose();
}
internal void _notify() {
notifyListeners();
}
public override string ToString() {
return $"{foundation_.describeIdentity(this)} hasFocus: {hasFocus}";
public class FocusScopeNode : DiagnosticableTree {
internal FocusManager _manager;
internal FocusScopeNode _parent;
internal FocusScopeNode _nextSibling;
internal FocusScopeNode _previousSibling;
internal FocusScopeNode _firstChild;
internal FocusScopeNode _lastChild;
internal FocusNode _focus;
internal List<FocusScopeNode> _focusPath;
public bool isFirstFocus {
get { return _parent == null || _parent._firstChild == this; }
}
internal List<FocusScopeNode> _getFocusPath() {
List<FocusScopeNode> nodes = new List<FocusScopeNode> {this};
FocusScopeNode node = _parent;
while (node != null && node != _manager?.rootScope) {
nodes.Add(node);
node = node._parent;
}
return nodes;
}
internal void _prepend(FocusScopeNode child) {
D.assert(child != this);
D.assert(child != _firstChild);
D.assert(child != _lastChild);
D.assert(child._parent == null);
D.assert(child._manager == null);
D.assert(child._nextSibling == null);
D.assert(child._previousSibling == null);
D.assert(() => {
var node = this;
while (node._parent != null) {
node = node._parent;
}
D.assert(node != child);
return true;
});
child._parent = this;
child._nextSibling = _firstChild;
if (_firstChild != null) {
_firstChild._previousSibling = child;
}
_firstChild = child;
_lastChild = _lastChild ?? child;
child._updateManager(_manager);
}
void _updateManager(FocusManager manager) {
Action<FocusScopeNode> update = null;
update = (child) => {
if (child._manager == manager) {
return;
}
child._manager = manager;
// We don"t proactively null out the manager for FocusNodes because the
// manager holds the currently active focus node until the end of the
// microtask, even if that node is detached from the focus tree.
if (manager != null && child._focus != null) {
child._focus._manager = manager;
}
child._visitChildren(update);
};
update(this);
}
void _visitChildren(Action<FocusScopeNode> vistor) {
FocusScopeNode child = _firstChild;
while (child != null) {
vistor.Invoke(child);
child = child._nextSibling;
}
}
bool _debugUltimatePreviousSiblingOf(FocusScopeNode child, FocusScopeNode equals) {
while (child._previousSibling != null) {
D.assert(child._previousSibling != child);
child = child._previousSibling;
}
return child == equals;
}
bool _debugUltimateNextSiblingOf(FocusScopeNode child, FocusScopeNode equals) {
while (child._nextSibling != null) {
D.assert(child._nextSibling != child);
child = child._nextSibling;
}
return child == equals;
}
internal void _remove(FocusScopeNode child) {
D.assert(child._parent == this);
D.assert(child._manager == _manager);
D.assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
if (child._previousSibling == null) {
D.assert(_firstChild == child);
_firstChild = child._nextSibling;
}
else {
child._previousSibling._nextSibling = child._nextSibling;
}
if (child._nextSibling == null) {
D.assert(_lastChild == child);
_lastChild = child._previousSibling;
}
else {
child._nextSibling._previousSibling = child._previousSibling;
}
child._previousSibling = null;
child._nextSibling = null;
child._parent = null;
child._updateManager(null);
}
internal void _didChangeFocusChain() {
if (isFirstFocus && _manager != null) {
_manager._markNeedsUpdate();
}
}
// TODO: need update
public void requestFocus(FocusNode node = null) {
// D.assert(node != null);
var focusPath = _manager?._getCurrentFocusPath();
if (_focus == node &&
(_focusPath == focusPath || (focusPath != null && _focusPath != null &&
_focusPath.SequenceEqual(focusPath)))) {
return;
}
if (_focus != null) {
_focus.unfocus();
}
node._hasKeyboardToken = true;
_setFocus(node);
}
public void autofocus(FocusNode node) {
D.assert(node != null);
if (_focus == null) {
node._hasKeyboardToken = true;
_setFocus(node);
}
}
public void reparentIfNeeded(FocusNode node) {
D.assert(node != null);
if (node._parent == null || node._parent == this) {
return;
}
node.unfocus();
D.assert(node._parent == null);
if (_focus == null) {
_setFocus(node);
}
}
internal void _setFocus(FocusNode node) {
D.assert(node != null);
D.assert(node._parent == null);
D.assert(_focus == null);
_focus = node;
_focus._parent = this;
_focus._manager = _manager;
_focus._hasKeyboardToken = true;
_didChangeFocusChain();
_focusPath = _getFocusPath();
}
internal void _resignFocus(FocusNode node) {
D.assert(node != null);
if (_focus != node) {
return;
}
_focus._parent = null;
_focus._manager = null;
_focus = null;
_didChangeFocusChain();
}
public void setFirstFocus(FocusScopeNode child) {
D.assert(child != null);
D.assert(child._parent == null || child._parent == this);
if (_firstChild == child) {
return;
}
child.detach();
_prepend(child);
D.assert(child._parent == this);
_didChangeFocusChain();
}
public void reparentScopeIfNeeded(FocusScopeNode child) {
D.assert(child != null);
if (child._parent == null || child._parent == this) {
return;
}
if (child.isFirstFocus) {
setFirstFocus(child);
}
else {
child.detach();
}
}
public void detach() {
_didChangeFocusChain();
if (_parent != null) {
_parent._remove(this);
}
D.assert(_parent == null);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_focus != null) {
properties.add(new DiagnosticsProperty<FocusNode>("focus", _focus));
}
}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (_firstChild != null) {
FocusScopeNode child = _firstChild;
int count = 1;
while (true) {
children.Add(child.toDiagnosticsNode(name: $"child {count}"));
if (child == _lastChild) {
break;
}
child = child._nextSibling;
count += 1;
}
}
return children;
}
}
public class FocusManager {
public FocusManager() {
rootScope._manager = this;
D.assert(rootScope._firstChild == null);
D.assert(rootScope._lastChild == null);
}
public readonly FocusScopeNode rootScope = new FocusScopeNode();
internal readonly FocusScopeNode _noneScope = new FocusScopeNode();
public FocusNode currentFocus {
get { return _currentFocus; }
}
internal FocusNode _currentFocus;
internal void _willDisposeFocusNode(FocusNode node) {
D.assert(node != null);
if (_currentFocus == node) {
_currentFocus = null;
}
}
bool _haveScheduledUpdate = false;
internal void _markNeedsUpdate() {
if (_haveScheduledUpdate) {
return;
}
_haveScheduledUpdate = true;
async_.scheduleMicrotask(() => {
_update();
return null;
});
}
internal FocusNode _findNextFocus() {
FocusScopeNode scope = rootScope;
while (scope._firstChild != null) {
scope = scope._firstChild;
}
return scope._focus;
}
internal void _update() {
_haveScheduledUpdate = false;
var nextFocus = _findNextFocus();
if (_currentFocus == nextFocus) {
return;
}
var previousFocus = _currentFocus;
_currentFocus = nextFocus;
if (previousFocus != null) {
previousFocus._notify();
}
if (_currentFocus != null) {
_currentFocus._notify();
}
}
internal List<FocusScopeNode> _getCurrentFocusPath() {
return _currentFocus?._parent?._getFocusPath();
}
public void focusNone(bool focus) {
if (focus) {
if (_noneScope._parent != null && _noneScope.isFirstFocus) {
return;
}
rootScope.setFirstFocus(_noneScope);
}
else {
if (_noneScope._parent == null) {
return;
}
_noneScope.detach();
}
}
public override string ToString() {
var status = _haveScheduledUpdate ? " UPDATE SCHEDULED" : "";
var indent = " ";
return string.Format("{1}{2}\n{0}currentFocus: {3}\n{4}", indent, foundation_.describeIdentity(this),
status, _currentFocus,
rootScope.toStringDeep(prefixLineOne: indent, prefixOtherLines: indent));
}
}*/

671
com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs


namespace Unity.UIWidgets.widgets {
/*public class FocusTraversalGroup : StatefulWidget {
public enum TraversalDirection {
up,
right,
down,
left,
// TODO(gspencer): Add diagonal traversal directions used by TV remotes and
// game controllers when we support them.
}
public class FocusTravesalUtils {
public static void _focusAndEnsureVisible(
FocusNode node,
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicitPolicy
) {
node.requestFocus();
Scrollable.ensureVisible(node.context, alignment: 1.0f, alignmentPolicy: alignmentPolicy);
}
public static BuildContext _getAncestor(BuildContext context, int count = 1) {
BuildContext target = null;
context.visitAncestorElements((Element ancestor)=> {
count--;
if (count == 0) {
target = ancestor;
return false;
}
return true;
});
return target;
}
public static HashSet<T> difference<T>(HashSet<T> aSet, HashSet<T> bSet) {
HashSet<T> result = new HashSet<T>();
foreach (var a in aSet) {
if (!bSet.Contains(a)) {
result.Add(a);
}
}
return result;
}
public static HashSet<T> intersaction<T>(HashSet<T> aSet, HashSet<T> bSet) {
HashSet<T> result = new HashSet<T>();
result = aSet;
foreach (var b in bSet) {
if (!aSet.Contains(b)) {
result.Add(b);
}
}
return result;
}
static int _MERGE_SORT_LIMIT = 32;
/// as they started in.
public static void insertionSort<T>(List<T> list,
Comparator<T> compare = null, int start = 0, int end =0) {
//compare ??= defaultCompare<T>();
end = end == 0 ?list.Count : end;
for (int pos = start + 1; pos < end; pos++) {
int min = start;
int max = pos;
var element = list[pos];
while (min < max) {
int mid = min + ((max - min) >> 1);
int comparison = compare(element, list[mid]);
if (comparison < 0) {
max = mid;
} else {
min = mid + 1;
}
}
setRange(list,min + 1, pos + 1, list, min);
list[min] = element;
}
}
public delegate int Comparator<T>(T a, T b);
//public Comparator<T> defaultCompare<T>() => (value1, value2) => value1 ;
public static void mergeSort<T>(
List<T> list,
int? start = null , int? end = null, Comparator<T> compare = null) {
int _start = start ?? 0;
int _end = end ?? list.Count;
compare = compare ;//?? <T>();
int length = _end - _start;
if (length < 2) return;
if (length < _MERGE_SORT_LIMIT) {
insertionSort(list, compare: compare, start: _start, end: _end);
return;
}
int middle = _start + ((_end - _start) >> 1);
int firstLength = middle - _start;
int secondLength = _end - middle;
// secondLength is always the same as firstLength, or one greater.
var scratchSpace = new List<T>(secondLength);
_mergeSort(list, compare, middle, _end, scratchSpace, 0);
int firstTarget = _end - firstLength;
_mergeSort(list, compare, _start, middle, list, firstTarget);
_merge(compare, list, firstTarget, _end, scratchSpace, 0, secondLength, list,
_start);
}
public static void _mergeSort<T>(List<T> list, Comparator<T> compare, int start, int end,
List<T> target, int targetOffset) {
int length = end - start;
if (length < _MERGE_SORT_LIMIT) {
_movingInsertionSort(list, compare, start, end, target, targetOffset);
return;
}
int middle = start + (length >> 1);
int firstLength = middle - start;
int secondLength = end - middle;
int targetMiddle = targetOffset + firstLength;
_mergeSort(list, compare, middle, end, target, targetMiddle);
_mergeSort(list, compare, start, middle, list, middle);
_merge(compare, list, middle, middle + firstLength, target, targetMiddle,
targetMiddle + secondLength, target, targetOffset);
}
public static void _movingInsertionSort<T>(List<T> list, Comparator<T> compare, int start,
int end, List<T> target, int targetOffset) {
int length = end - start;
if (length == 0) return;
target[targetOffset] = list[start];
for (int i = 1; i < length; i++) {
var element = list[start + i];
int min = targetOffset;
int max = targetOffset + i;
while (min < max) {
int mid = min + ((max - min) >> 1);
if (compare(element, target[mid]) < 0) {
max = mid;
} else {
min = mid + 1;
}
}
setRange(target,min + 1, targetOffset + i + 1, target, min);
target[min] = element;
}
}
public static List<T>setRange<T>(List<T> alist, int start, int end, List<T> blist, int skipConut = 0 ) {
List<T> copyList = new List<T>();
List<T> resultList = new List<T>();
for (int i = skipConut; i < blist.Count; i++) {
copyList.Add(blist[i]);
}
for (int i = 0; i < start; i++) {
resultList.Add(alist[i]);
}
for (int i = 0; i < copyList.Count; i++) {
resultList.Add(blist[i]);
}
for (int i = start + copyList.Count - 1; i < alist.Count; i++) {
resultList.Add(alist[i]);
}
return resultList;
}
public static void _merge<T>(
Comparator<T> compare,
List<T> firstList,
int firstStart,
int firstEnd,
List<T> secondList,
int secondStart,
int secondEnd,
List<T> target,
int targetOffset) {
// No empty lists reaches here.
D.assert(firstStart < firstEnd);
D.assert(secondStart < secondEnd);
int cursor1 = firstStart;
int cursor2 = secondStart;
var firstElement = firstList[cursor1++];
var secondElement = secondList[cursor2++];
while (true) {
if (compare(firstElement, secondElement) <= 0) {
target[targetOffset++] = firstElement;
if (cursor1 == firstEnd) break; // Flushing second list after loop.
firstElement = firstList[cursor1++];
} else {
target[targetOffset++] = secondElement;
if (cursor2 != secondEnd) {
secondElement = secondList[cursor2++];
continue;
}
target[targetOffset++] = firstElement;
setRange(target,targetOffset, targetOffset + (firstEnd - cursor1),
firstList, cursor1);
return;
}
}
// First list empties first. Reached by break above.
target[targetOffset++] = secondElement;
setRange(target
,targetOffset, targetOffset + (secondEnd - cursor2), secondList, cursor2);
}
}
public class FocusTraversalGroup : StatefulWidget {
public FocusTraversalGroup(
Key key = null,
FocusTraversalPolicy policy = null,

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new TextTreeRenderer.DiagnosticsProperty<FocusTraversalPolicy>("policy", policy));
properties.add(new DiagnosticsProperty<FocusTraversalPolicy>("policy", policy));
}
}
public class _FocusTraversalGroupState : State<FocusTraversalGroup> {

public override bool updateShouldNotify(InheritedWidget oldWidget) => false;
}
public abstract class FocusTraversalPolicy : TextTreeRenderer.Diagnosticable {
public abstract class FocusTraversalPolicy : Diagnosticable {
public class _FocusTraversalGroupInfo {
public _FocusTraversalGroupInfo(
_FocusTraversalGroupMarker marker,
FocusTraversalPolicy defaultPolicy = null,
List<FocusNode> members = null
) {
groupNode = marker?.focusNode;
policy = marker?.policy ?? defaultPolicy ?? new ReadingOrderTraversalPolicy();
members = members ?? new List<FocusNode>();
}
public readonly FocusNode groupNode;
public readonly FocusTraversalPolicy policy;
public readonly List<FocusNode> members;
}
public virtual FocusNode findFirstFocus(FocusNode currentNode) {
D.assert(currentNode != null);

candidate = sorted.isNotEmpty() ? sorted.First() : null;
}
candidate ??= currentNode;
candidate = candidate ?? currentNode;
public abstract void invalidateScopeData(FocusScopeNode node);
public virtual void invalidateScopeData(FocusScopeNode node) {
}
public abstract void changedScope(FocusNode node = null, FocusScopeNode oldScope = null);
bool next(FocusNode currentNode) => _moveFocus(currentNode, forward: true);
public virtual void changedScope(FocusNode node = null, FocusScopeNode oldScope = null) {
}
bool previous(FocusNode currentNode) => _moveFocus(currentNode, forward: false);
public bool next(FocusNode currentNode) => _moveFocus(currentNode, forward: true);
public bool previous(FocusNode currentNode) => _moveFocus(currentNode, forward: false);
public abstract bool inDirection(FocusNode currentNode, TraversalDirection direction);

public List<FocusNode> _sortAllDescendants(FocusScopeNode scope) {
D.assert(scope != null);
_FocusTraversalGroupMarker scopeGroupMarker = _getMarker(scope.context);
FocusTraversalPolicy defaultPolicy = scopeGroupMarker?.policy ?? ReadingOrderTraversalPolicy();
FocusTraversalPolicy defaultPolicy = scopeGroupMarker?.policy ?? new ReadingOrderTraversalPolicy();
BuildContext parentContext = _getAncestor(groupNode.context, count: 2);
BuildContext parentContext =FocusTravesalUtils._getAncestor(groupNode.context, count: 2);
FocusNode parentNode = parentMarker?.focusNode;
groups[parentNode] ??= new _FocusTraversalGroupInfo(parentMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
FocusNode parentNode = parentMarker?.focusNode;
groups[groupNode] = groups.getOrDefault(parentNode) ?? new _FocusTraversalGroupInfo(parentMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
groups[parentNode].members.add(groupNode);
groups[parentNode].members.Add(groupNode);
groups[groupNode] ??= _FocusTraversalGroupInfo(groupMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
D.assert(!groups[groupNode].members.contains(node));
groups[groupNode].members.add(node);
groups[groupNode] = groups.getOrDefault(groupNode) ?? new _FocusTraversalGroupInfo(groupMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
D.assert(!groups[groupNode].members.Contains(node));
groups[groupNode].members.Add(node);
HashSet<FocusNode> groupKeys = groups.Keys.ToSet();
foreach ( FocusNode key in groups.keys) {
List<FocusNode> sortedMembers = groups[key].policy.sortDescendants(groups[key].members).toList();
groups[key].members.clear();
groups[key].members.addAll(sortedMembers);
HashSet<FocusNode> groupKeys = new HashSet<FocusNode>(groups.Keys);
foreach ( FocusNode key in groups.Keys) {
List<FocusNode> sortedMembers = groups[key].policy.sortDescendants(groups[key].members).ToList();
groups[key].members.Clear();
groups[key].members.AddRange(sortedMembers);
}
List<FocusNode> sortedDescendants = new List<FocusNode>();

}
visitGroups(groups[scopeGroupMarker?.focusNode]);
D.assert(
sortedDescendants.toSet().difference(scope.traversalDescendants.toSet()).isEmpty,
$"sorted descendants contains more nodes than it should: ({sortedDescendants.toSet().difference(scope.traversalDescendants.toSet())})"
FocusTravesalUtils.difference(new HashSet<FocusNode>(sortedDescendants),(new HashSet<FocusNode>(scope.traversalDescendants))).isEmpty(),
()=>$"sorted descendants contains more nodes than it should: ({FocusTravesalUtils.difference(new HashSet<FocusNode>(sortedDescendants),(new HashSet<FocusNode>(scope.traversalDescendants)))})"
scope.traversalDescendants.toSet().difference(sortedDescendants.toSet()).isEmpty,
"sorted descendants are missing some nodes: (${scope.traversalDescendants.toSet().difference(sortedDescendants.toSet())})"
FocusTravesalUtils.difference(new HashSet<FocusNode>(scope.traversalDescendants),new HashSet<FocusNode>(sortedDescendants)).isEmpty(),
()=>$"sorted descendants are missing some nodes: ({FocusTravesalUtils.difference(new HashSet<FocusNode>(scope.traversalDescendants),new HashSet<FocusNode>(sortedDescendants))})"
);
return sortedDescendants;
}

if (focusedChild == null) {
FocusNode firstFocus = findFirstFocus(currentNode);
if (firstFocus != null) {
_focusAndEnsureVisible(
FocusTravesalUtils._focusAndEnsureVisible(
alignmentPolicy: forward ? ScrollPositionAlignmentPolicy.keepVisibleAtEnd : ScrollPositionAlignmentPolicy.keepVisibleAtStart,
alignmentPolicy: forward ? ScrollPositionAlignmentPolicy.keepVisibleAtEnd : ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
return true;
}

_focusAndEnsureVisible(sortedNodes.First(), alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd);
FocusTravesalUtils._focusAndEnsureVisible(sortedNodes.First(), alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd);
_focusAndEnsureVisible(sortedNodes.Last(), alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart);
FocusTravesalUtils._focusAndEnsureVisible(sortedNodes.Last(), alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart);
return true;
}

FocusNode previousNode = null;
foreach ( FocusNode node in maybeFlipped) {
if (previousNode == focusedChild) {
_focusAndEnsureVisible(
FocusTravesalUtils._focusAndEnsureVisible(
alignmentPolicy: forward ? ScrollPositionAlignmentPolicy.keepVisibleAtEnd : ScrollPositionAlignmentPolicy.keepVisibleAtStart,
alignmentPolicy: forward ? ScrollPositionAlignmentPolicy.keepVisibleAtEnd : ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
return true;
}

}
}
public class _DirectionalPolicyDataEntry {
public _DirectionalPolicyDataEntry(
TraversalDirection direction ,

public readonly FocusNode node;
}
class _ReadingOrderDirectionalGroupData : Diagnosticable {
public class WidgetOrderTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy {
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
return descendants;
}
}
public class _DirectionalPolicyData {
public _DirectionalPolicyData(List<_DirectionalPolicyDataEntry> history) {
D.assert(history != null);
}
public readonly List<_DirectionalPolicyDataEntry> history;
}
public class _ReadingOrderSortData : Diagnosticable {
public _ReadingOrderSortData(FocusNode node) {
D.assert(node != null);
this.node = node;
rect = node.rect;
directionality = _findDirectionality(node.context);
}
public readonly TextDirection directionality;
public readonly Rect rect;
public readonly FocusNode node;
public static TextDirection _findDirectionality(BuildContext context) {
return (context.getElementForInheritedWidgetOfExactType<Directionality>().widget as Directionality).textDirection;
}
public static TextDirection commonDirectionalityOf(List<_ReadingOrderSortData> list) {
IEnumerable<HashSet<Directionality>> allAncestors = list.Select((_ReadingOrderSortData member) => new HashSet<Directionality>(member.directionalAncestors));
HashSet<Directionality> common = null;
foreach ( HashSet<Directionality> ancestorSet in allAncestors) {
common = common ?? ancestorSet;
common = FocusTravesalUtils.intersaction(common,ancestorSet);
}
if (common.isEmpty()) {
return list.First().directionality;
}
foreach (var com in list.First().directionalAncestors) {
if (common.Contains(com)) {
return com.textDirection;
}
}
return common.First().textDirection;
}
public static void sortWithDirectionality(List<_ReadingOrderSortData> list, TextDirection directionality) {
FocusTravesalUtils.mergeSort<_ReadingOrderSortData>(list,
compare: (_ReadingOrderSortData a, _ReadingOrderSortData b)=> {
switch (directionality) {
case TextDirection.ltr:
return a.rect.left.CompareTo(b.rect.left);
case TextDirection.rtl:
return b.rect.right.CompareTo(a.rect.right);
}
D.assert(false, ()=>"Unhandled directionality $directionality");
return 0;
});
}
public IEnumerable<Directionality> directionalAncestors {
get {
List<Directionality> getDirectionalityAncestors(BuildContext context) {
List<Directionality> result = new List<Directionality>();
InheritedElement directionalityElement = context.getElementForInheritedWidgetOfExactType<Directionality>();
while (directionalityElement != null) {
result.Add(directionalityElement.widget as Directionality);
directionalityElement = FocusTravesalUtils._getAncestor(directionalityElement)?.getElementForInheritedWidgetOfExactType<Directionality>();
}
return result;
}
_directionalAncestors = _directionalAncestors ?? getDirectionalityAncestors(node.context);
return _directionalAncestors;
}
}
List<Directionality> _directionalAncestors;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<TextDirection>("directionality", directionality));
properties.add(new StringProperty("name", node.debugLabel, defaultValue: null));
properties.add(new DiagnosticsProperty<Rect>("rect", rect));
}
}
public class _ReadingOrderDirectionalGroupData : Diagnosticable {
public _ReadingOrderDirectionalGroupData(List<_ReadingOrderSortData> members) {
this.members = members;
}

TextDirection directionality {
public TextDirection directionality {
get {
return members.First().directionality;
}

Rect rect {
get {if (_rect == null) {
foreach(Rect rect in members.Select<Rect>(
foreach(Rect rect in members.Select(
_rect ??= rect;
_rect = _rect ?? rect;
_rect = _rect.expandToInclude(rect);
}
}

}
List<Directionality> _memberAncestors;
public static void sortWithDirectionality(List<_ReadingOrderDirectionalGroupData> list, TextDirection directionality) {
mergeSort<_ReadingOrderDirectionalGroupData>(list, compare: (_ReadingOrderDirectionalGroupData a, _ReadingOrderDirectionalGroupData b) =>{
FocusTravesalUtils.mergeSort<_ReadingOrderDirectionalGroupData>(list, compare: (_ReadingOrderDirectionalGroupData a, _ReadingOrderDirectionalGroupData b) =>{
return a.rect.left.compareTo(b.rect.left);
return a.rect.left.CompareTo(b.rect.left);
return b.rect.right.compareTo(a.rect.right);
return b.rect.right.CompareTo(a.rect.right);
public override void debugFillProperties(TextTreeRenderer.DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties.add(DiagnosticsProperty<TextDirection>("directionality", directionality));
properties.add(DiagnosticsProperty<Rect>("rect", rect));
properties.add(IterableProperty<String>("members", members.map<String>((_ReadingOrderSortData member) {
return ""${member.node.debugLabel}"(${member.rect})";
})));
properties.add(new DiagnosticsProperty<TextDirection>("directionality", directionality));
properties.add(new DiagnosticsProperty<Rect>("rect", rect));
//properties.add(new IterableProperty<string>("members", members.map<String>((_ReadingOrderSortData member) {
// return ""${member.node.debugLabel}"(${member.rect})";
//})));
public class ReadingOrderTraversalPolicy : FocusTraversalPolicy , DirectionalFocusTraversalPolicyMixin {
public interface DirectionalFocusTraversalPolicyMixin {
//Dictionary<FocusScopeNode, _DirectionalPolicyData> _policyData = new Dictionary<FocusScopeNode, _DirectionalPolicyData>();
void invalidateScopeData(FocusScopeNode node);
void changedScope(FocusNode node = null, FocusScopeNode oldScope = null);
FocusNode findFirstFocusInDirection(FocusNode currentNode, TraversalDirection direction);
FocusNode _sortAndFindInitial(FocusNode currentNode, bool vertical = false, bool first = false);
IEnumerable<FocusNode> _sortAndFilterHorizontally(
TraversalDirection direction,
Rect target,
FocusNode nearestScope);
IEnumerable<FocusNode> _sortAndFilterVertically(
TraversalDirection direction,
Rect target,
IEnumerable<FocusNode> nodes);
bool _popPolicyDataIfNeeded(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild);
void _pushPolicyData(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild);
bool inDirection(FocusNode currentNode, TraversalDirection direction);
}
public class ReadingOrderTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy
{
public List<_ReadingOrderDirectionalGroupData> _collectDirectionalityGroups(IEnumerable<_ReadingOrderSortData> candidates) {
TextDirection currentDirection = candidates.First().directionality;
List<_ReadingOrderSortData> currentGroup = new List<_ReadingOrderSortData>();

continue;
}
currentDirection = candidate.directionality;
result.Add(_ReadingOrderDirectionalGroupData(currentGroup));
result.Add(new _ReadingOrderDirectionalGroupData(currentGroup));
result.Add(_ReadingOrderDirectionalGroupData(currentGroup));
result.Add(new _ReadingOrderDirectionalGroupData(currentGroup));
if (bandGroup.members.length == 1) {
if (bandGroup.members.Count == 1) {
continue;
}
_ReadingOrderSortData.sortWithDirectionality(bandGroup.members, bandGroup.directionality);

public _ReadingOrderSortData _pickNext(List<_ReadingOrderSortData> candidates) {
mergeSort<_ReadingOrderSortData>(candidates, compare: (_ReadingOrderSortData a, _ReadingOrderSortData b) => a.rect.top.compareTo(b.rect.top));
FocusTravesalUtils.mergeSort<_ReadingOrderSortData>(candidates, compare: (_ReadingOrderSortData a, _ReadingOrderSortData b) => a.rect.top.CompareTo(b.rect.top));
List<_ReadingOrderSortData> inBand(_ReadingOrderSortData current, IEnumerable<_ReadingOrderSortData> candidates) {
Rect band = Rect.fromLTRB(double.negativeInfinity, current.rect.top, double.infinity, current.rect.bottom);
return candidates.Where((_ReadingOrderSortData item)=> {
List<_ReadingOrderSortData> inBand(_ReadingOrderSortData current, IEnumerable<_ReadingOrderSortData> _candidates) {
Rect band = Rect.fromLTRB(float.NegativeInfinity, current.rect.top, float.PositiveInfinity, current.rect.bottom);
return _candidates.Where((_ReadingOrderSortData item)=> {
D.assert(topmost.rect.isEmpty || inBandOfTop.isNotEmpty);
D.assert(topmost.rect.isEmpty || inBandOfTop.isNotEmpty());
if (inBandOfTop.Count <= 1) {
return topmost;
}

if (bandGroups.Count == 1) {
return bandGroups.First().members.first;
return bandGroups.First().members.First();
return bandGroups.First().members.first;
return bandGroups.First().members.First();
}
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {

}
List<_ReadingOrderSortData> data = new List<_ReadingOrderSortData>(){
foreach ( FocusNode node in descendants)
_ReadingOrderSortData(node),
};
List<_ReadingOrderSortData> data = new List<_ReadingOrderSortData>();
foreach (FocusNode node in descendants)
data.Add(new _ReadingOrderSortData(node));
List<FocusNode> sortedList = new List<FocusNode>();
List<_ReadingOrderSortData> unplaced = data;
_ReadingOrderSortData current = _pickNext(unplaced);

}
return sortedList;
}
}*/
}
public interface Comparable<T> {
int compareTo(T other);
int compare(Comparable<T> a, T b);
}
public abstract class FocusOrder : Diagnosticable , Comparable<FocusOrder> {
public FocusOrder() {
}
public int compareTo(FocusOrder other) {
D.assert(
GetType() == other.GetType(),()=>
"The sorting algorithm must not compare incomparable keys, since they don't "+
$"know how to order themselves relative to each other. Comparing {this} with {other}");
return doCompare(other);
}
public int compare(Comparable<FocusOrder> a, FocusOrder b) {
//throw new NotImplementedException();
return a.compareTo(b);
}
protected abstract int doCompare(FocusOrder other);
}
public class NumericFocusOrder : FocusOrder {
public NumericFocusOrder(float order) {
D.assert(order != null);
this.order = order;
}
public readonly float order;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("order", order));
}
protected override int doCompare(FocusOrder other) {
other = (NumericFocusOrder) other;
return order.CompareTo(((NumericFocusOrder) other).order);
}
}
class LexicalFocusOrder : FocusOrder {
public LexicalFocusOrder(string order) {
D.assert(order != null);
this.order = order;
}
public readonly string order;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new StringProperty("order", order));
}
protected override int doCompare(FocusOrder other) {
other = (LexicalFocusOrder) other;
return order.CompareTo(((LexicalFocusOrder) other).order);
}
}
class _OrderedFocusInfo {
public _OrderedFocusInfo(
FocusNode node = null,
FocusOrder order = null) {
D.assert(node != null);
D.assert(order != null);
this.order = order;
this.node = node;
}
public readonly FocusNode node;
public readonly FocusOrder order;
}
public class OrderedTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy {
public OrderedTraversalPolicy(FocusTraversalPolicy secondary) {
}
public readonly FocusTraversalPolicy secondary;
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
FocusTraversalPolicy secondaryPolicy = secondary ?? new ReadingOrderTraversalPolicy();
IEnumerable<FocusNode> sortedDescendants = secondaryPolicy.sortDescendants(descendants);
List<FocusNode> unordered = new List<FocusNode>();
List<_OrderedFocusInfo> ordered = new List<_OrderedFocusInfo>();
foreach( FocusNode node in sortedDescendants) {
FocusOrder order = FocusTraversalOrder.of(node.context, nullOk: true);
if (order != null) {
ordered.Add(new _OrderedFocusInfo(node: node, order: order));
} else {
unordered.Add(node);
}
}
FocusTravesalUtils.mergeSort<_OrderedFocusInfo>(ordered, compare: (_OrderedFocusInfo a, _OrderedFocusInfo b)=> {
D.assert(
a.order.GetType() == b.order.GetType(),()=>
$"When sorting nodes for determining focus order, the order ({a.order}) of " +
$"node {a.node}, isn't the same type as the order ({b.order}) of {b.node}. " +
"Incompatible order types can't be compared. Use a FocusTraversalGroup to group " +
"similar orders together."
);
return a.order.compareTo(b.order);
});
return ordered.Select((_OrderedFocusInfo info) => info.node).Concat(unordered);
}
}
public class FocusTraversalOrder : InheritedWidget {
public FocusTraversalOrder(Key key = null, FocusOrder order = null, Widget child = null)
: base(key: key, child: child) {
}
public readonly FocusOrder order;
public static FocusOrder of(BuildContext context, bool nullOk = false) {
D.assert(context != null);
D.assert(nullOk != null);
FocusTraversalOrder marker = context.getElementForInheritedWidgetOfExactType<FocusTraversalOrder>()?.widget as FocusTraversalOrder;
FocusOrder order = marker?.order;
if (order == null && !nullOk) {
throw new UIWidgetsError("FocusTraversalOrder.of() was called with a context that "+
"does not contain a TraversalOrder widget. No TraversalOrder widget " +
"ancestor could be found starting from the context that was passed to " +
"FocusTraversalOrder.of().\n" +
"The context used was:\n" +
$" {context}");
}
return order;
}
public override bool updateShouldNotify(InheritedWidget oldWidget) => false;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<FocusOrder>("order", order));
}
}
public class _RequestFocusActionBase : UiWidgetAction {
public _RequestFocusActionBase(LocalKey name) : base(name) {
}
FocusNode _previousFocus;
public override void invoke(FocusNode node, Intent intent) {
_previousFocus = FocusManagerUtils.primaryFocus;
node.requestFocus();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<FocusNode>("previous", _previousFocus));
}
}
public class NextFocusAction : _RequestFocusActionBase {
public NextFocusAction() : base(key) {
}
public readonly static LocalKey key = new ValueKey<Type>(typeof(NextFocusAction));
public override void invoke(FocusNode node, Intent intent) {
node.nextFocus();
}
}
public class PreviousFocusAction : _RequestFocusActionBase {
public PreviousFocusAction() : base(key) {
}
public readonly static LocalKey key = new ValueKey<Type>(typeof(PreviousFocusAction));
public override void invoke(FocusNode node, Intent intent) => node.previousFocus();
}
public class DirectionalFocusIntent : Intent {
public DirectionalFocusIntent(TraversalDirection direction = TraversalDirection.up, bool ignoreTextFields = true)
:base(DirectionalFocusAction.key) {
this.ignoreTextFields = ignoreTextFields;
this.direction = direction;
}
public readonly TraversalDirection direction;
public readonly bool ignoreTextFields;
}
public class DirectionalFocusAction : _RequestFocusActionBase {
public DirectionalFocusAction() : base(key) {
}
public readonly static LocalKey key = new ValueKey<Type>(typeof(DirectionalFocusAction));
public override void invoke(FocusNode node, Intent intent) {
intent = (DirectionalFocusIntent) intent;
if (!((DirectionalFocusIntent)intent).ignoreTextFields || !(node.context.widget is EditableText)) {
node.focusInDirection(((DirectionalFocusIntent) intent).direction);
}
}
}
}

9
com.unity.uiwidgets/Runtime/widgets/form.cs


}
public static FormState of(BuildContext context) {
_FormScope scope = (_FormScope) context.inheritFromWidgetOfExactType(typeof(_FormScope));
_FormScope scope = context.dependOnInheritedWidgetOfExactType<_FormScope>();
return scope?._formState;
}

public bool hasError {
get { return _errorText != null; }
}
//[!!!] call?
/*public bool isValid {
get {
return widget.validator?.call(_value) == null;
}
}*/
public void save() {
if (widget.onSaved != null) {

622
com.unity.uiwidgets/Runtime/widgets/framework.cs


using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

Element newer = parent;
UIWidgetsError error = null;
if (older.toString() != newer.toString()) {
error = new UIWidgetsError(
"Multiple widgets used the same GlobalKey.\n" +
$"The key {key} was used by multiple widgets. The parents of those widgets were:\n" +
$"- {older.toString()}\n" +
$"- {newer.toString()}\n" +
"A GlobalKey can only be specified on one widget at a time in the widget tree."
);
error = new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Multiple widgets used the same GlobalKey."),
new ErrorDescription(
$"The key {key} was used by multiple widgets. The parents of those widgets were:\n" +
$"- {older.toString()}\n" +
$"- {newer.toString()}\n" +
"A GlobalKey can only be specified on one widget at a time in the widget tree."
)
});
error = new UIWidgetsError(
"Multiple widgets used the same GlobalKey.\n" +
$"The key {key} was used by multiple widgets. The parents of those widgets were:\n" +
"different widgets that both had the following description:\n" +
$" {parent.toString()}\n" +
"A GlobalKey can only be specified on one widget at a time in the widget tree."
);
error = new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Multiple widgets used the same GlobalKey."),
new ErrorDescription(
"The key $key was used by multiple widgets. The parents of those widgets were " +
"different widgets that both had the following description:\n" +
" ${parent.toString()}\n" +
"A GlobalKey can only be specified on one widget at a time in the widget tree."
)
});
}
if (child._parent != older) {

_debugIllFatedElements.Clear();
if (duplicates != null) {
var buffer = new StringBuilder();
buffer.AppendLine("Multiple widgets used the same GlobalKey.\n");
List<DiagnosticsNode> information = new List<DiagnosticsNode>();
information.Add(new ErrorSummary("Multiple widgets used the same GlobalKey."));
HashSet<Element> elements = duplicates[key];
buffer.AppendLine($"The key {key} was used by {elements.Count} widgets:");
foreach (Element element in elements) {
buffer.AppendLine("- " + element);
}
HashSet<Element> elements = duplicates.getOrDefault(key);
information.Add( Element.describeElements($"The key $key was used by {elements.Count} widgets", elements));
buffer.Append("A GlobalKey can only be specified on one widget at a time in the widget tree.");
throw new UIWidgetsError(buffer.ToString());
information.Add(new ErrorDescription("A GlobalKey can only be specified on one widget at a time in the widget tree."));
throw new UIWidgetsError(information);
}
return true;

public void setState(VoidCallback fn = null) {
D.assert(() => {
if (_debugLifecycleState == _StateLifecycle.defunct) {
throw new UIWidgetsError(
"setState() called after dispose(): " + this + "\n" +
"This error happens if you call setState() on a State object for a widget that " +
"no longer appears in the widget tree (e.g., whose parent widget no longer " +
"includes the widget in its build). This error can occur when code calls " +
"setState() from a timer or an animation callback. The preferred solution is " +
"to cancel the timer or stop listening to the animation in the dispose() " +
"callback. Another solution is to check the \"mounted\" property of this " +
"object before calling setState() to ensure the object is still in the " +
"tree.\n" +
"This error might indicate a memory leak if setState() is being called " +
"because another object is retaining a reference to this State object " +
"after it has been removed from the tree. To avoid memory leaks, " +
"consider breaking the reference to this object during dispose()."
);
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary($"setState() called after dispose(): {this}"),
new ErrorDescription(
"This error happens if you call setState() on a State object for a widget that " +
"no longer appears in the widget tree (e.g., whose parent widget no longer " +
"includes the widget in its build). This error can occur when code calls " +
"setState() from a timer or an animation callback."
),
new ErrorHint(
"The preferred solution is " +
"to cancel the timer or stop listening to the animation in the dispose() " +
"callback. Another solution is to check the \"mounted\" property of this " +
"object before calling setState() to ensure the object is still in the " +
"tree."
),
new ErrorHint(
"This error might indicate a memory leak if setState() is being called " +
"because another object is retaining a reference to this State object " +
"after it has been removed from the tree. To avoid memory leaks, " +
"consider breaking the reference to this object during dispose()."
)
});
throw new UIWidgetsError(
"setState() called in constructor: " + this + "\n" +
"This happens when you call setState() on a State object for a widget that " +
"hasn\"t been inserted into the widget tree yet. It is not necessary to call " +
"setState() in the constructor, since the state is already assumed to be dirty " +
"when it is initially created."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary($"setState() called in constructor: {this}"),
new ErrorHint(
"This happens when you call setState() on a State object for a widget that " +
"hasn't been inserted into the widget tree yet. It is not necessary to call " +
"setState() in the constructor, since the state is already assumed to be dirty " +
"when it is initially created."
)
});
}
return true;

public abstract bool debugIsValidRenderObject(RenderObject renderObject);
internal abstract string _debugDescribeIncorrectParentDataType(
internal abstract IEnumerable<DiagnosticsNode> _debugDescribeIncorrectParentDataType(
ParentData parentData,
RenderObjectWidget parentDataCreator = null,
DiagnosticsNode ownershipChain = null

public override Type debugTypicalAncestorWidgetClass { get; }
internal override string _debugDescribeIncorrectParentDataType(
internal override IEnumerable<DiagnosticsNode> _debugDescribeIncorrectParentDataType(
ParentData parentData,
RenderObjectWidget parentDataCreator = null,
DiagnosticsNode ownershipChain = null

string result = "";
List<DiagnosticsNode> result = new List<DiagnosticsNode>();
result += new ErrorDescription(
result.Add( new ErrorDescription(
);
));
result += new ErrorDescription(
result.Add( new ErrorDescription(
);
));
result +=
$"Usually, this means that the {GetType()} widget has the wrong ancestor RenderObjectWidget. " +
$"Typically, {GetType()} widgets are placed directly inside {debugTypicalAncestorWidgetClass} widgets.";
result.Add(
new ErrorHint( $"Usually, this means that the {GetType()} widget has the wrong ancestor RenderObjectWidget. " +
$"Typically, {GetType()} widgets are placed directly inside {debugTypicalAncestorWidgetClass} widgets."
));
result +=
$"The offending {GetType()} is currently placed inside a {parentDataCreator.GetType()} widget.";
result.Add(
new ErrorHint(
$"The offending {GetType()} is currently placed inside a {parentDataCreator.GetType()} widget."));
result += new ErrorDescription(
result.Add(new ErrorDescription(
);
));
}
return result;

if (!element.dirty) {
throw new UIWidgetsError(
"scheduleBuildFor() called for a widget that is not marked as dirty.\n" +
"The method was called for the following element:\n" +
" " + element + "\n" +
"This element is not current marked as dirty. Make sure to set the dirty flag before " +
"calling scheduleBuildFor().\n" +
"If you did not attempt to call scheduleBuildFor() yourself, then this probably " +
"indicates a bug in the widgets framework."
new List<DiagnosticsNode>() {
new ErrorSummary("scheduleBuildFor() called for a widget that is not marked as dirty."),
element.describeElement("The method was called for the following element"),
new ErrorDescription(
"This element is not current marked as dirty. Make sure to set the dirty flag before " +
"calling scheduleBuildFor()."),
new ErrorHint(
"If you did not attempt to call scheduleBuildFor() yourself, then this probably " +
"indicates a bug in the widgets framework. Please report it:\n" +
" https://github.com/flutter/flutter/issues/new?template=BUG.md"
),
}
);
}

if (!_debugIsInBuildScope) {
throw new UIWidgetsError(
"BuildOwner.scheduleBuildFor() called inappropriately.\n" +
"The BuildOwner.scheduleBuildFor() method should only be called while the " +
"buildScope() method is actively rebuilding the widget tree."
new List<DiagnosticsNode>() {
new ErrorSummary("BuildOwner.scheduleBuildFor() called inappropriately."),
new ErrorHint(
"The BuildOwner.scheduleBuildFor() method should only be called while the " +
"buildScope() method is actively rebuilding the widget tree."
)
}
);
}

D.assert(() => {
if (_dirtyElements.Any(element => element._active && element.dirty)) {
throw new UIWidgetsError(
"buildScope missed some dirty elements.\n" +
"This probably indicates that the dirty list should have been resorted but was not.\n" +
"The list of dirty elements at the end of the buildScope call was:\n" +
" " + _dirtyElements);
new List<DiagnosticsNode>() {
new ErrorSummary("buildScope missed some dirty elements."),
new ErrorHint("This probably indicates that the dirty list should have been resorted but was not."),
Element.describeElements("The list of dirty elements at the end of the buildScope call was", _dirtyElements),
});
}
return true;

D.assert(keyLabels.isNotEmpty());
throw new UIWidgetsError(
"Duplicate GlobalKeys detected in widget tree.\n" +
"The following GlobalKeys were specified multiple times in the widget tree. This will lead to " +
"parts of the widget tree being truncated unexpectedly, because the second time a key is seen, " +
"the previous instance is moved to the new location. The keys were:\n" +
"- " + string.Join("\n ", keyLabels.ToArray()) + "\n" +
"This was determined by noticing that after the widgets with the above global keys were moved " +
"out of their respective previous parents, those previous parents never updated during this frame, meaning " +
"that they either did not update at all or updated before the widgets were moved, in either case " +
"implying that they still think that they should have a child with those global keys.\n" +
"The specific parents that did not update after having one or more children forcibly removed " +
"due to GlobalKey reparenting are:\n" +
"- " + string.Join("\n ", elementLabels.ToArray()) + "\n" +
"A GlobalKey can only be specified on one widget at a time in the widget tree."
);
new List<DiagnosticsNode>() {
new ErrorSummary("Duplicate GlobalKeys detected in widget tree."),
new ErrorDescription(
"The following GlobalKeys were specified multiple times in the widget tree. This will lead to " +
"parts of the widget tree being truncated unexpectedly, because the second time a key is seen, " +
"the previous instance is moved to the new location. The keys were:\n" + "- " +
string.Join("\n ", keyLabels.ToArray()) + "\n" +
"This was determined by noticing that after$the widgets with the above global keys were moved " +
"out of their respective previous parent, those previous parents never updated during this frame, meaning " +
"that they either did not update at all or updated before the widgets were moved, in either case " +
"implying that they still think that they should have a child with those global keys.\n" +
"The specific parent that did not update after having one or more children forcibly removed " +
"due to GlobalKey reparenting are:\n" +
"- " + string.Join("\n ", elementLabels.ToArray()) + "\n" +
"\nA GlobalKey can only be specified on one widget at a time in the widget tree."
),
});
}
}
}

}
throw new UIWidgetsError(
"visitChildElements() called during build.\n" +
"The BuildContext.visitChildElements() method can\"t be called during " +
"build because the child list is still being updated at that point, " +
"so the children might not be constructed yet, or might be old children " +
"that are going to be replaced."
new List<DiagnosticsNode>() {
new ErrorSummary("visitChildElements() called during build."),
new ErrorDescription(
"The BuildContext.visitChildElements() method can't be called during " +
"build because the child list is still being updated at that point, " +
"so the children might not be constructed yet, or might be old children " +
"that are going to be replaced."
),
}
);
});

D.assert(() => {
if (parent == this) {
throw new UIWidgetsError(
"A GlobalKey was used multiple times inside one widget\"s child list.\n" +
$"The offending GlobalKey was: {key}\n" +
$"The parent of the widgets with that key was:\n {parent}\n" +
$"The first child to get instantiated with that key became:\n {element}\n" +
$"The second child that was to be instantiated with that key was:\n {widget}\n" +
"A GlobalKey can only be specified on one widget at a time in the widget tree.");
new List<DiagnosticsNode>()
{
new ErrorSummary("A GlobalKey was used multiple times inside one widget's child list."),
new DiagnosticsProperty<GlobalKey>("The offending GlobalKey was", key),
parent.describeElement("The parent of the widgets with that key was"),
element.describeElement("The first child to get instantiated with that key became"),
new DiagnosticsProperty<Widget>("The second child that was to be instantiated with that key was", widget, style: DiagnosticsTreeStyle.errorProperty),
new ErrorDescription("A GlobalKey can only be specified on one widget at a time in the widget tree."),
}
);
}
parent.owner._debugTrackElementThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans(

D.assert(() => {
if (_debugLifecycleState != _ElementLifecycle.active) {
throw new UIWidgetsError(
"Cannot get size of inactive element.\n" +
"In order for an element to have a valid size, the element must be " +
"active, which means it is part of the tree. Instead, this element " +
"is in the " + _debugLifecycleState + " state.\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n");
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size of inactive element."),
new ErrorDescription(
"In order for an element to have a valid size, the element must be " +
"active, which means it is part of the tree.\n" +
$"Instead, this element is in the {_debugLifecycleState} state."
),
describeElement("The size getter was called for the following element"),
}
);
"Cannot get size during build.\n" +
"The size of this render object has not yet been determined because " +
"the framework is still in the process of building widgets, which " +
"means the render tree for this frame has not yet been determined. " +
"The size getter should only be called from paint callbacks or " +
"interaction event handlers (e.g. gesture callbacks).\n" +
"\n" +
"If you need some sizing information during build to decide which " +
"widgets to build, consider using a LayoutBuilder widget, which can " +
"tell you the layout constraints at a given location in the tree." +
"\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n");
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size during build."),
new ErrorDescription(
"The size of this render object has not yet been determined because " +
"the framework is still in the process of building widgets, which " +
"means the render tree for this frame has not yet been determined. " +
"The size getter should only be called from paint callbacks or " +
"interaction event handlers (e.g. gesture callbacks)."
),
new ErrorSpacer(),
new ErrorHint(
"If you need some sizing information during build to decide which " +
"widgets to build, consider using a LayoutBuilder widget, which can " +
"tell you the layout constraints at a given location in the tree. See " +
"<https://api.flutter.dev/flutter/widgets/LayoutBuilder-class.html> " +
"for more details."
),
new ErrorSpacer(),
describeElement("The size getter was called for the following element"),
}
);
}
return true;

if (renderObject == null) {
throw new UIWidgetsError(
"Cannot get size without a render object.\n" +
"In order for an element to have a valid size, the element must have " +
"an associated render object. This element does not have an associated " +
"render object, which typically means that the size getter was called " +
"too early in the pipeline (e.g., during the build phase) before the " +
"framework has created the render tree.\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n");
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size without a render object."),
new ErrorHint(
"In order for an element to have a valid size, the element must have " +
"an associated render object. This element does not have an associated " +
"render object, which typically means that the size getter was called " +
"too early in the pipeline (e.g., during the build phase) before the " +
"framework has created the render tree."
),
describeElement("The size getter was called for the following element"),
}
);
"Cannot get size from a RenderSliver.\n" +
"The render object associated with this element is a " +
renderObject.GetType() + ", which is a subtype of RenderSliver. " +
"Slivers do not have a size per se. They have a more elaborate " +
"geometry description, which can be accessed by calling " +
"findRenderObject and then using the \"geometry\" getter on the " +
"resulting object.\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n" +
"The associated render sliver was:\n" +
" " + renderObject.toStringShallow(joiner: "\n "));
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size from a RenderSliver."),
new ErrorHint(
"The render object associated with this element is a " +
$"{renderObject.GetType()}, which is a subtype of RenderSliver. " +
"Slivers do not have a size per se. They have a more elaborate " +
"geometry description, which can be accessed by calling " +
"findRenderObject and then using the \"geometry\" getter on the " +
"resulting object."
),
describeElement("The size getter was called for the following element"),
renderObject.describeForError("The associated render sliver was"),
}
);
"Cannot get size from a render object that is not a RenderBox.\n" +
"Instead of being a subtype of RenderBox, the render object associated " +
"with this element is a " + renderObject.GetType() + ". If this type of " +
"render object does have a size, consider calling findRenderObject " +
"and extracting its size manually.\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n" +
"The associated render object was:\n" +
" " + renderObject.toStringShallow(joiner: "\n "));
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size from a render object that is not a RenderBox."),
new ErrorHint(
"Instead of being a subtype of RenderBox, the render object associated " +
$"with this element is a {renderObject.GetType()}. If this type of " +
"render object does have a size, consider calling findRenderObject " +
"and extracting its size manually."
),
describeElement("The size getter was called for the following element"),
renderObject.describeForError("The associated render object was"),
}
);
"Cannot get size from a render object that has not been through layout.\n" +
"The size of this render object has not yet been determined because " +
"this render object has not yet been through layout, which typically " +
"means that the size getter was called too early in the pipeline " +
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size from a render object that has not been through layout."),
new ErrorHint(
"The size of this render object has not yet been determined because " +
"this render object has not yet been through layout, which typically " +
"means that the size getter was called too early in the pipeline " +
"the size and position of the render objects during layout.\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n" +
"The render object from which the size was to be obtained was:\n" +
" " + box.toStringShallow(joiner: "\n "));
"the size and position of the render objects during layout."
),
describeElement("The size getter was called for the following element"),
box.describeForError("The render object from which the size was to be obtained was"),
}
);
"Cannot get size from a render object that has been marked dirty for layout.\n" +
"The size of this render object is ambiguous because this render object has " +
"been modified since it was last laid out, which typically means that the size " +
"getter was called too early in the pipeline (e.g., during the build phase) " +
"before the framework has determined the size and position of the render " +
"objects during layout.\n" +
"The size getter was called for the following element:\n" +
" " + this + "\n" +
"The render object from which the size was to be obtained was:\n" +
" \n" + box.toStringShallow(joiner: "\n ") +
"Consider using debugPrintMarkNeedsLayoutStacks to determine why the render " +
"object in question is dirty, if you did not expect this.");
new List<DiagnosticsNode>() {
new ErrorSummary("Cannot get size from a render object that has been marked dirty for layout."),
new ErrorHint(
"The size of this render object is ambiguous because this render object has " +
"been modified since it was last laid out, which typically means that the size " +
"getter was called too early in the pipeline (e.g., during the build phase) " +
"before the framework has determined the size and position of the render " +
"objects during layout."
),
describeElement("The size getter was called for the following element"),
box.describeForError("The render object from which the size was to be obtained was"),
new ErrorHint(
"Consider using debugPrintMarkNeedsLayoutStacks to determine why the render " +
"object in question is dirty, if you did not expect this."
),
}
);
}
return true;

D.assert(() => {
if (_debugLifecycleState != _ElementLifecycle.active) {
throw new UIWidgetsError(
"Looking up a deactivated widget\"s ancestor is unsafe.\n" +
"At this point the state of the widget\"s element tree is no longer " +
"stable. To safely refer to a widget\"s ancestor in its dispose() method, " +
"save a reference to the ancestor by calling inheritFromWidgetOfExactType() " +
"in the widget\"s didChangeDependencies() method.\n");
new List<DiagnosticsNode>() {
new ErrorSummary("Looking up a deactivated widget's ancestor is unsafe."),
new ErrorDescription(
"At this point the state of the widget's element tree is no longer " +
"stable."
),
new ErrorHint(
"To safely refer to a widget's ancestor in its dispose() method, " +
"save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() " +
"in the widget's didChangeDependencies() method."
),
}
);
}
return true;

D.assert(() => {
if (owner._debugCurrentBuildTarget == null) {
throw new UIWidgetsError(
methodName + " for " + widget.GetType() + " was called at an " +
"inappropriate time.\n" +
"It may only be called while the widgets are being built. A possible " +
"cause of this error is when $methodName is called during " +
"one of:\n" +
" * network I/O event\n" +
" * file I/O event\n" +
" * timer\n" +
" * microtask (caused by Future.then, async/await, scheduleMicrotask)"
new List<DiagnosticsNode>() {
new ErrorSummary(
$"{methodName} for {widget.GetType()} was called at an " +
"inappropriate time."
),
new ErrorDescription("It may only be called while the widgets are being built."),
new ErrorHint(
$"A possible cause of this error is when {methodName} is called during " +
"one of:\n" +
" * network I/O event\n" +
" * file I/O event\n" +
" * timer\n" +
" * microtask (caused by Future.then, async/await, scheduleMicrotask)"
),
}
);
}

if (!_debugAllowIgnoredCallsToMarkNeedsBuild) {
throw new UIWidgetsError(
"setState() or markNeedsBuild() called during build.\n" +
"This " + widget.GetType() +
" widget cannot be marked as needing to build because the framework " +
"is already in the process of building widgets. A widget can be marked as " +
"needing to be built during the build phase only if one of its ancestors " +
"is currently building. This exception is allowed because the framework " +
"builds parent widgets before children, which means a dirty descendant " +
"will always be built. Otherwise, the framework might not visit this " +
"widget during this build phase.\n" +
"The widget on which setState() or markNeedsBuild() was called was:\n" +
" " + this + "\n" +
(owner._debugCurrentBuildTarget == null
? ""
: "The widget which was currently being built when the offending call was made was:\n " +
owner._debugCurrentBuildTarget)
new List<DiagnosticsNode>(){
new ErrorSummary("setState() or markNeedsBuild() called during build.\n"),
new ErrorDescription("This " + widget.GetType() +
" widget cannot be marked as needing to build because the framework " +
"is already in the process of building widgets. A widget can be marked as " +
"needing to be built during the build phase only if one of its ancestors " +
"is currently building. This exception is allowed because the framework " +
"builds parent widgets before children, which means a dirty descendant " +
"will always be built. Otherwise, the framework might not visit this " +
"widget during this build phase.\n" +
"The widget on which setState() or markNeedsBuild() was called was:\n" +
" " + this + "\n" +
(owner._debugCurrentBuildTarget == null
? ""
: "The widget which was currently being built when the offending call was made was:\n " +
owner._debugCurrentBuildTarget))
}
);
}

D.assert(!_debugAllowIgnoredCallsToMarkNeedsBuild);
throw new UIWidgetsError(
"setState() or markNeedsBuild() called when widget tree was locked.\n" +
"This " + widget.GetType() + " widget cannot be marked as needing to build " +
"because the framework is locked.\n" +
"The widget on which setState() or markNeedsBuild() was called was:\n" +
" " + this + "\n"
new List<DiagnosticsNode>() {
new ErrorSummary("setState() or markNeedsBuild() called when widget tree was locked."),
new ErrorDescription(
$"This {widget.GetType()} widget cannot be marked as needing to build " +
"because the framework is locked."
),
describeElement("The widget on which setState() or markNeedsBuild() was called was"),
}
);
}

D.assert(() => {
if (!_state._debugTypesAreRight(widget)) {
throw new UIWidgetsError(
"StatefulWidget.createState must return a subtype of State<" + widget.GetType() + ">\n" +
"The createState function for " + widget.GetType() + " returned a state " +
"of type " + _state.GetType() + ", which is not a subtype of " +
"State<" + widget.GetType() + ">, violating the contract for createState.");
new List<DiagnosticsNode>() {
new ErrorSummary("StatefulWidget.createState must return a subtype of State<${widget.runtimeType}>"),
new ErrorDescription(
$"The createState function for {widget.GetType()} returned a state " +
$"of type {_state.GetType()}, which is not a subtype of " +
$"State<${widget.GetType()}>, violating the contract for createState."
),
});
}
return true;

}
throw new UIWidgetsError(
_state.GetType() + ".dispose failed to call base.dispose.\n" +
"dispose() implementations must always call their superclass dispose() method, to ensure " +
"that all the resources used by the widget are fully released.");
new List<DiagnosticsNode>() {
new ErrorSummary($"{_state.GetType()}.dispose failed to call super.dispose."),
new ErrorDescription(
"dispose() implementations must always call their superclass dispose() method, to ensure " +
"that all the resources used by the widget are fully released."
),
});
});
_state._element = null;
_state = null;

Type targetType = ancestor.widget.GetType();
if (state._debugLifecycleState == _StateLifecycle.created) {
throw new UIWidgetsError(
"inheritFromWidgetOfExactType(" + targetType + ") or inheritFromElement() was called before " +
_state.GetType() + ".initState() completed.\n" +
"When an inherited widget changes, for example if the value of Theme.of() changes, " +
"its dependent widgets are rebuilt. If the dependent widget\"s reference to " +
"the inherited widget is in a constructor or an initState() method, " +
"then the rebuilt dependent widget will not reflect the changes in the " +
"inherited widget.\n" +
"Typically references to inherited widgets should occur in widget build() methods. Alternatively, " +
"initialization based on inherited widgets can be placed in the didChangeDependencies method, which " +
"is called after initState and whenever the dependencies change thereafter."
);
new List<DiagnosticsNode>() {
new ErrorSummary($"dependOnInheritedWidgetOfExactType<{targetType}>() or dependOnInheritedElement() was called before {_state.GetType()}.initState() completed."),
new ErrorDescription(
"When an inherited widget changes, for example if the value of Theme.of() changes, " +
"its dependent widgets are rebuilt. If the dependent widget's reference to " +
"the inherited widget is in a constructor or an initState() method, " +
"then the rebuilt dependent widget will not reflect the changes in the " +
"inherited widget."
),
new ErrorHint(
"Typically references to inherited widgets should occur in widget build() methods. Alternatively, " +
"initialization based on inherited widgets can be placed in the didChangeDependencies method, which " +
"is called after initState and whenever the dependencies change thereafter."
),
}
);
"inheritFromWidgetOfExactType(" + targetType +
") or inheritFromElement() was called after dispose(): " + this + "\n" +
"This error happens if you call inheritFromWidgetOfExactType() on the " +
"BuildContext for a widget that no longer appears in the widget tree " +
"(e.g., whose parent widget no longer includes the widget in its " +
"build). This error can occur when code calls " +
"inheritFromWidgetOfExactType() from a timer or an animation callback. " +
"The preferred solution is to cancel the timer or stop listening to the " +
"animation in the dispose() callback. Another solution is to check the " +
"\"mounted\" property of this object before calling " +
"inheritFromWidgetOfExactType() to ensure the object is still in the " +
"tree.\n" +
"This error might indicate a memory leak if " +
"inheritFromWidgetOfExactType() is being called because another object " +
"is retaining a reference to this State object after it has been " +
"removed from the tree. To avoid memory leaks, consider breaking the " +
"reference to this object during dispose()."
new List<DiagnosticsNode>() {
new ErrorSummary($"dependOnInheritedWidgetOfExactType<{targetType}>() or dependOnInheritedElement() was called after dispose(): $this"),
new ErrorDescription(
"This error happens if you call dependOnInheritedWidgetOfExactType() on the " +
"BuildContext for a widget that no longer appears in the widget tree " +
"(e.g., whose parent widget no longer includes the widget in its " +
"build). This error can occur when code calls " +
"dependOnInheritedWidgetOfExactType() from a timer or an animation callback."
),
new ErrorHint(
"The preferred solution is to cancel the timer or stop listening to the " +
"animation in the dispose() callback. Another solution is to check the " +
"\"mounted\" property of this object before calling " +
"dependOnInheritedWidgetOfExactType() to ensure the object is still in the " +
"tree."
),
new ErrorHint(
"This error might indicate a memory leak if " +
"dependOnInheritedWidgetOfExactType() is being called because another object " +
"is retaining a reference to this State object after it has been " +
"removed from the tree. To avoid memory leaks, consider breaking the " +
"reference to this object during dispose()."
),
}
);
}

if (badAncestors.isNotEmpty()) {
badAncestors.Insert(0, result);
try {
string errorLog = "Incorrect use of ParentDataWidget.\n" +
"The following ParentDataWidgets are providing parent data to the same RenderObject:";
foreach (ParentDataElement parentDataElement in badAncestors) {
errorLog +=
$"- {parentDataElement.widget} (typically placed directly inside a {parentDataElement.widget.debugTypicalAncestorWidgetClass} widget)";
}
List<ErrorDescription> errors = new List<ErrorDescription>();
foreach (ParentDataElement<ParentData> parentDataElement in badAncestors)
errors.Add(new ErrorDescription(
$"- {parentDataElement.widget} (typically placed directly inside a {parentDataElement.widget.debugTypicalAncestorWidgetClass} widget)"));
errorLog +=
$"However, a RenderObject can only receive parent data from at most one ParentDataWidget.";
errorLog +=
$"Usually, this indicates that at least one of the offending ParentDataWidgets listed above is not placed directly inside a compatible ancestor widget.";
errorLog +=
$"The ownership chain for the RenderObject that received the parent data was:\n {debugGetCreatorChain(10)}";
throw new UIWidgetsError(message: errorLog);
List<DiagnosticsNode> results = new List<DiagnosticsNode>();
results.Add( new ErrorSummary("Incorrect use of ParentDataWidget."));
results.Add(new ErrorDescription("The following ParentDataWidgets are providing parent data to the same RenderObject:"));
results.AddRange(errors);
results.Add(new ErrorDescription("However, a RenderObject can only receive parent data from at most one ParentDataWidget."));
results.Add(new ErrorHint("Usually, this indicates that at least one of the offending ParentDataWidgets listed above is not placed directly inside a compatible ancestor widget."));
results.Add(new ErrorDescription($"The ownership chain for the RenderObject that received the parent data was:\n {debugGetCreatorChain(10)}"));
throw new UIWidgetsError(
results
);
}
catch (UIWidgetsError e) {
WidgetsD._debugReportException("while looking for parent data.", e);

try {
if (!parentDataWidget.debugIsValidRenderObject(renderObject)) {
applyParentData = false;
List<DiagnosticsNode> results = new List<DiagnosticsNode>();
results.Add( new ErrorSummary("Incorrect use of ParentDataWidget.\n") );
results.AddRange(parentDataWidget._debugDescribeIncorrectParentDataType(
parentData: renderObject.parentData,
parentDataCreator: _ancestorRenderObjectElement.widget,
ownershipChain: new ErrorDescription(debugGetCreatorChain(10))
));
"Incorrect use of ParentDataWidget.\n" +
parentDataWidget._debugDescribeIncorrectParentDataType(
parentData: renderObject.parentData,
parentDataCreator: _ancestorRenderObjectElement.widget,
ownershipChain: new ErrorDescription(debugGetCreatorChain(10))
)
results
);
}
}

47
com.unity.uiwidgets/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;
}
}

GestureTapUpCallback onTapUp = null,
GestureTapCallback onTap = null,
GestureTapCancelCallback onTapCancel = null,
GestureTapDownCallback onSecondaryTapDown = null,
GestureTapUpCallback onSecondaryTapUp = null,
GestureTapCancelCallback onSecondaryTapCancel = null,
GestureDoubleTapCallback onDoubleTap = null,
GestureLongPressCallback onLongPress = null,
GestureLongPressStartCallback onLongPressStart = null,

bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
if (havePan || haveScale) {
if (havePan && haveScale) {
throw new UIWidgetsError(
"Incorrect GestureDetector arguments.\n" +
"Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Incorrect GestureDetector arguments."),
new ErrorDescription(
"Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan."
),
new ErrorHint("Just use the scale gesture recognizer.")
});
}
string recognizer = havePan ? "pan" : "scale";

this.onTapUp = onTapUp;
this.onTap = onTap;
this.onTapCancel = onTapCancel;
this.onSecondaryTapDown = onSecondaryTapDown;
this.onSecondaryTapUp = onSecondaryTapUp;
this.onSecondaryTapCancel = onSecondaryTapCancel;
this.onDoubleTap = onDoubleTap;
this.onLongPress = onLongPress;
this.onLongPressUp = onLongPressUp;

public readonly GestureTapUpCallback onTapUp;
public readonly GestureTapCallback onTap;
public readonly GestureTapCancelCallback onTapCancel;
public readonly GestureTapDownCallback onSecondaryTapDown;
public readonly GestureTapUpCallback onSecondaryTapUp;
public readonly GestureTapCancelCallback onSecondaryTapCancel;
public readonly GestureDoubleTapCallback onDoubleTap;
public readonly GestureLongPressCallback onLongPress;
public readonly GestureLongPressUpCallback onLongPressUp;

if (onTapDown != null ||
onTapUp != null ||
onTap != null ||
onTapCancel != null) {
onTapCancel != null ||
onSecondaryTapDown != null ||
onSecondaryTapUp != null ||
onSecondaryTapCancel != null) {
gestures[typeof(TapGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
() => new TapGestureRecognizer(debugOwner: this),

instance.onTap = onTap;
instance.onTapCancel = onTapCancel;
instance.onSecondaryTapDown = onSecondaryTapDown;
instance.onSecondaryTapUp = onSecondaryTapUp;
instance.onSecondaryTapCancel = onSecondaryTapCancel;
}
);
}

public void replaceGestureRecognizers(Dictionary<Type, GestureRecognizerFactory> gestures) {
D.assert(() => {
if (!context.findRenderObject().owner.debugDoingLayout) {
throw new UIWidgetsError(
"Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState.\n" +
"The replaceGestureRecognizers() method can only be called during the layout phase. " +
"To set the gesture recognizers at other times, trigger a new build using setState() " +
"and provide the new gesture recognizers as constructor arguments to the corresponding " +
"RawGestureDetector or GestureDetector object.");
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary(
"Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState."),
new ErrorDescription(
"The replaceGestureRecognizers() method can only be called during the layout phase."),
new ErrorHint(
"To set the gesture recognizers at other times, trigger a new build using setState() " +
"and provide the new gesture recognizers as constructor arguments to the corresponding " +
"RawGestureDetector or GestureDetector object."
)
});
}
return true;

129
com.unity.uiwidgets/Runtime/widgets/heroes.cs


public readonly HeroFlightShuttleBuilder flightShuttleBuilder;
public readonly HeroPlaceholderBuilder placeholderBuilder;
//public readonly TransitionBuilder placeholderBuilder;
internal static Dictionary<object, _HeroState>
_allHeroesFor(BuildContext context, bool isUserGestureTransition, NavigatorState navigator) {
internal static Dictionary<object, _HeroState> _allHeroesFor(
BuildContext context,
bool isUserGestureTransition,
NavigatorState navigator) {
/*void addHero(StatefulElement hero, object tag) {
D.assert(() => {
if (result.ContainsKey(tag)) {
throw new UIWidgetsError(
"There are multiple heroes that share the same tag within a subtree.\n" +
"Within each subtree for which heroes are to be animated (typically a PageRoute subtree), " +
"each Hero must have a unique non-null tag.\n" +
$"In this case, multiple heroes had the following tag: {tag}\n" +
"Here is the subtree for one of the offending heroes:\n" +
$"{hero.toStringDeep(prefixLineOne: "# ")}"
);
}
return true;
});
_HeroState heroState = (_HeroState) hero.state;
result[tag] = heroState;
}*/
"There are multiple heroes that share the same tag within a subtree.\n" +
"Within each subtree for which heroes are to be animated (typically a PageRoute subtree), " +
"each Hero must have a unique non-null tag.\n" +
$"In this case, multiple heroes had the following tag: {tag}\n" +
"Here is the subtree for one of the offending heroes:\n" +
$"{hero.toStringDeep(prefixLineOne: "# ")}"
);
new List<DiagnosticsNode>()
{
new ErrorSummary("There are multiple heroes that share the same tag within a subtree."),
new ErrorDescription(
"Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), "+
"each Hero must have a unique non-null tag.\n"+
$"In this case, multiple heroes had the following tag: {tag}\n"
),
new DiagnosticsProperty<StatefulElement>("Here is the subtree for one of the offending heroes", hero, linePrefix: "# ", style: DiagnosticsTreeStyle.dense),
});
}
return true;
});

result[tag] = heroState;
} else {
// If transition is not allowed, we need to make sure hero is not hidden.
// A hero can be hidden previously due to hero transition.
/*if (element.widget is Hero) {
StatefulElement hero = (StatefulElement) element;
Hero heroWidget = (Hero) element.widget;
if (!isUserGestureTransition || heroWidget.transitionOnUserGestures) {
object tag = heroWidget.tag;
D.assert(tag != null);
if (Navigator.of(hero) == navigator) {
addHero(hero, tag);
}
else {
ModalRoute heroRoute = ModalRoute.of(hero);
if (heroRoute != null && heroRoute is PageRoute && heroRoute.isCurrent) {
addHero(hero, tag);
}
}
}
}*/
Widget widget = element.widget;
if (widget is Hero) {
StatefulElement hero = element as StatefulElement;

GlobalKey _key = GlobalKey.key();
Size _placeholderSize;
bool _shouldIncludeChild = true;
//public void startFlight() {
public void startFlight( bool shouldIncludedChildInPlaceholder = false ) {
_shouldIncludeChild = shouldIncludedChildInPlaceholder;
D.assert(mounted);

}
//public void endFlight() {
public void ensurePlaceholderIsHidden() {
if (mounted) {
setState(() => { _placeholderSize = null; });

}
public override Widget build(BuildContext context) {
D.assert(
//context.ancestorWidgetOfExactType(typeof(Hero)) == null,
//if (_placeholderSize != null) {
// if (widget.placeholderBuilder == null) {
bool showPlaceholder = _placeholderSize != null;
if (showPlaceholder && widget.placeholderBuilder != null) {

width: _placeholderSize.width,
height: _placeholderSize.height
);
}
}
return new SizedBox(
width: _placeholderSize?.width,
height: _placeholderSize?.height,

)
)
);
/*else {
return widget.placeholderBuilder(context, widget.child);
}*/
/*return new KeyedSubtree(
key: _key,
child: widget.child
);*/
}
}

this.createRectTween = createRectTween;
this.shuttleBuilder = shuttleBuilder;
this.isUserGestureTransition = isUserGestureTransition;
this.isDiverted = isDiverted;
}
public readonly HeroFlightDirection type;

}
public override string ToString() {
return $"_HeroFlightManifest($type tag: $tag from route: {fromRoute.settings} " +
return $"_HeroFlightManifest({type} tag: {tag} from route: {fromRoute.settings} " +
public _HeroFlight(_OnFlightEnded onFlightEnded) {
public _HeroFlight(_OnFlightEnded onFlightEnded ) {
this.onFlightEnded = onFlightEnded;
_proxyAnimation = new ProxyAnimation();
_proxyAnimation.addStatusListener(_handleAnimationUpdate);

Widget _buildOverlay(BuildContext context) {
D.assert(manifest != null);
shuttle = shuttle ?? manifest.shuttleBuilder(
context, manifest.animation, manifest.type, manifest.fromHero.context,
manifest.toHero.context
);
context,
manifest.animation,
manifest.type,
manifest.fromHero.context,
manifest.toHero.context);
D.assert(shuttle != null);
return new AnimatedBuilder(

//RenderBox toHeroBox = (RenderBox) manifest.toHero.context?.findRenderObject();
RenderBox toHeroBox = manifest.toHero.context?.findRenderObject() as RenderBox;
if (_aborted || toHeroBox == null || !toHeroBox.attached) {
if (_heroOpacity.isCompleted) {

}
}
else if (toHeroBox.hasSize) {
//RenderBox finalRouteBox = (RenderBox) manifest.toRoute.subtreeContext?.findRenderObject();
RenderBox finalRouteBox = manifest.toRoute.subtreeContext?.findRenderObject() as RenderBox;
Offset toHeroOrigin = toHeroBox.localToGlobal(Offset.zero, ancestor: finalRouteBox);
if (toHeroOrigin != heroRectTween.end.topLeft) {

overlayEntry = null;
manifest.fromHero.endFlight(keepPlaceholder: status == AnimationStatus.completed);
manifest.toHero.endFlight(keepPlaceholder: status == AnimationStatus.dismissed);
//manifest.fromHero.endFlight();
//manifest.toHero.endFlight();
onFlightEnded(this);
}
}

_proxyAnimation.parent = manifest.animation;
}
manifest.fromHero.startFlight(shouldIncludedChildInPlaceholder: manifest.type == HeroFlightDirection.push);
//manifest.fromHero.startFlight();
//HeroUtils._globalBoundingBoxFor(manifest.fromHero.context),
//HeroUtils._globalBoundingBoxFor(manifest.toHero.context)
HeroUtils._boundingBoxFor(manifest.fromHero.context, manifest.fromRoute.subtreeContext),
HeroUtils._boundingBoxFor(manifest.toHero.context, manifest.toRoute.subtreeContext)

public void divert(_HeroFlightManifest newManifest) {
D.assert(manifest.tag == newManifest.tag);
if (manifest.type == HeroFlightDirection.push && newManifest.type == HeroFlightDirection.pop) {
D.assert(newManifest.animation.status == AnimationStatus.reverse);
D.assert(manifest.fromHero == newManifest.toHero);

);
if (manifest.fromHero != newManifest.toHero) {
//manifest.fromHero.endFlight();
//heroRectTween = _doCreateRectTween(heroRectTween.end, HeroUtils._globalBoundingBoxFor(newManifest.toHero.context));
heroRectTween = _doCreateRectTween(
heroRectTween.end,
HeroUtils._boundingBoxFor(newManifest.toHero.context, newManifest.toRoute.subtreeContext)

else {
D.assert(manifest.fromHero != newManifest.fromHero);
D.assert(manifest.toHero != newManifest.toHero);
//heroRectTween = _doCreateRectTween(heroRectTween.evaluate(_proxyAnimation), HeroUtils._globalBoundingBoxFor(newManifest.toHero.context));
heroRectTween = _doCreateRectTween(
heroRectTween.evaluate(_proxyAnimation),
HeroUtils._boundingBoxFor(newManifest.toHero.context, newManifest.toRoute.subtreeContext)

// Let the heroes in each of the routes rebuild with their placeholders.
newManifest.fromHero.startFlight(shouldIncludedChildInPlaceholder: newManifest.type == HeroFlightDirection.push);
//manifest.fromHero.endFlight();
//manifest.toHero.endFlight();
//newManifest.fromHero.startFlight();
newManifest.toHero.startFlight();
overlayEntry.markNeedsBuild();

RouteSettings from = manifest.fromRoute.settings;
RouteSettings to = manifest.toRoute.settings;
object tag = manifest.tag;
return "HeroFlight(for: $tag, from: $from, to: $to ${_proxyAnimation.parent})";
return $"HeroFlight(for: {tag}, from: {from}, to: {to} ${_proxyAnimation.parent})";
}
}

D.assert(route != null);
_maybeStartHeroTransition(route, previousRoute, HeroFlightDirection.pop, true);
}
void didStopUserGesture() {
public override void didStopUserGesture() {
if (navigator.userGestureInProgress)
return;

List<_HeroFlight> invalidFlights = _flights.Values
.Where(isInvalidFlight)
.ToList();
// Treat these invalidated flights as dismissed. Calling _handleAnimationUpdate
// will also remove the flight from _flights.
foreach ( _HeroFlight flight in invalidFlights) {
foreach ( _HeroFlight flight in invalidFlights) {
flight._handleAnimationUpdate(AnimationStatus.dismissed);
}
}

7
com.unity.uiwidgets/Runtime/widgets/icon.cs


)
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IconDataProperty("icon", icon, ifNull: "<empty>", showName: false));
properties.add(new FloatProperty("size", size, defaultValue: null));
properties.add(new ColorProperty("color", color, defaultValue: null));
}
}
}

33
com.unity.uiwidgets/Runtime/widgets/icon_data.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.widgets {
public class IconData : IEquatable<IconData> {

public override string ToString() {
return "IconData(U+" + codePoint.ToString("X5") + ")";
}
}
public class IconDataProperty : DiagnosticsProperty<IconData> {
public IconDataProperty(
String name,
IconData value,
String ifNull = null,
bool showName = true,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
DiagnosticLevel level = DiagnosticLevel.info
) : base(name, value,
showName: showName,
ifNull: ifNull,
style: style,
level: level
) {
D.assert(showName != null);
D.assert(style != null);
D.assert(level != null);
}
public override Dictionary<String, Object> toJsonMap(DiagnosticsSerializationDelegate _delegate) {
Dictionary<String, Object> json = base.toJsonMap(_delegate);
if (value != null) {
json["valueProperties"] = new Dictionary<String, Object>(){
{"codePoint", value.codePoint},
};
}
return json;
}
}
}

18
com.unity.uiwidgets/Runtime/widgets/icon_theme.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.widgets {
public class IconTheme : InheritedWidget {
public class IconTheme : InheritedTheme {
public IconTheme(
Key key = null,
IconThemeData data = null,

public static IconThemeData of(BuildContext context) {
IconThemeData iconThemeData = _getInheritedIconThemeData(context);
return iconThemeData.isConcrete ? iconThemeData : IconThemeData.fallback().merge(iconThemeData);
return iconThemeData.isConcrete ? iconThemeData :
iconThemeData.copyWith(
size: iconThemeData.size ?? IconThemeData.fallback().size,
color: iconThemeData.color ?? IconThemeData.fallback().color,
opacity: iconThemeData.opacity ?? IconThemeData.fallback().opacity
);
IconTheme iconTheme = (IconTheme) context.inheritFromWidgetOfExactType(typeof(IconTheme));
IconTheme iconTheme = (IconTheme) context.dependOnInheritedWidgetOfExactType<IconTheme>();
if (iconTheme != null) {
return iconTheme.data;
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<IconThemeData>("data", data, showName: false));
data.debugFillProperties(properties);
}
public override Widget wrap(BuildContext context, Widget child) {
IconTheme iconTheme = context.findAncestorWidgetOfExactType<IconTheme>();
return this == iconTheme ? child : new IconTheme(data: data, child: child);
}
}
}

7
com.unity.uiwidgets/Runtime/widgets/icon_theme_data.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {

size: other.size
);
}
IconThemeData resolve(BuildContext context) => this;
public bool isConcrete {
get { return color != null && opacity != null && size != null; }
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Color>("color", color,
properties.add(new ColorProperty("color", color,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new FloatProperty("opacity", opacity,
defaultValue: foundation_.kNullDefaultValue));

318
com.unity.uiwidgets/Runtime/widgets/image.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

using Color = Unity.UIWidgets.ui.Color;
using Object = System.Object;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.widgets {

}
}
public delegate Widget ImageFrameBuilder (
BuildContext context,
Widget child,
int frame,
bool wasSynchronouslyLoaded
);
// [!!!] class ImageChunkEvent is missing
public delegate Widget ImageLoadingBuilder(
BuildContext context,
Widget child//,
//ImageChunkEvent loadingProgress
);
public delegate Widget ImageErrorWidgetBuilder(
BuildContext context,
Object error,
StackTrace stackTrace
);
ImageFrameBuilder frameBuilder = null,
ImageLoadingBuilder loadingBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
) : base(key) {
) : base(key: key) {
this.frameBuilder = frameBuilder;
this.loadingBuilder = loadingBuilder;
this.errorBuilder = errorBuilder;
this.width = width;
this.height = height;
this.color = color;

string src,
Key key = null,
float scale = 1.0f,
ImageFrameBuilder frameBuilder = null,
ImageLoadingBuilder loadingBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
IDictionary<string, string> headers = null
IDictionary<string, string> headers = null,
int cacheWidth = default,
int cacheHeight = default
var networkImage = new NetworkImage(src, scale, headers);
var networkImage = new NetworkImage(src, scale, headers);//image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, NetworkImage(src, scale: scale, headers: headers));
key,
networkImage,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: networkImage,
frameBuilder: frameBuilder,
loadingBuilder: loadingBuilder,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);
}

float scale = 1.0f,
ImageFrameBuilder frameBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
var fileImage = new FileImage(file, scale);
var fileImage = new FileImage(file, scale);//ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, FileImage(file, scale: scale));
key,
fileImage,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: fileImage,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);
}

AssetBundle bundle = null,
ImageFrameBuilder frameBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? scale = null,
float? width = null,
float? height = null,

ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
/*image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, scale != null
? ExactAssetImage(name, bundle: bundle, scale: scale, package: package)
: AssetImage(name, bundle: bundle, package: package)
);*/
key,
image,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: image,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);
}

float scale = 1.0f,
ImageFrameBuilder frameBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
// ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, MemoryImage(bytes, scale: scale));
key,
memoryImage,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: memoryImage,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
public readonly ImageFrameBuilder frameBuilder;
public readonly ImageLoadingBuilder loadingBuilder;
public readonly ImageErrorWidgetBuilder errorBuilder;
public readonly float? width;
public readonly float? height;
public readonly Color color;

base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ImageProvider>("image", image));
properties.add(new DiagnosticsProperty<ImageFrameBuilder>("frameBuilder", frameBuilder));
properties.add(new DiagnosticsProperty<ImageLoadingBuilder>("loadingBuilder", loadingBuilder));
properties.add(new DiagnosticsProperty<Color>("color", color,
properties.add(new ColorProperty("color", color,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new EnumProperty<BlendMode>("colorBlendMode", colorBlendMode,
defaultValue: foundation_.kNullDefaultValue));

}
}
public class _ImageState : State<Image> {
public class _ImageState : State<Image> ,WidgetsBindingObserver{
//ImageChunkEvent _loadingProgress;
int _frameNumber;
bool _wasSynchronouslyLoaded;
DisposableBuildContext<State<Image>> _scrollAwareContext;
Object _lastException;
StackTrace _lastStack;
public override void initState() {
base.initState();
WidgetsBinding.instance.addObserver(this);
_scrollAwareContext = new DisposableBuildContext<State<Image>>(this);
}
public override void dispose() {
D.assert(_imageStream != null);
WidgetsBinding.instance.removeObserver(this);
_stopListeningToStream();
_scrollAwareContext.dispose();
base.dispose();
}
_invertColors = false;
_updateInvertColors();
_resolveImage();
if (TickerMode.of(context)) {

public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
Image image = (Image) oldWidget;
if (_isListeningToStream &&
(widget.loadingBuilder == null) != (image.loadingBuilder == null)) {
/*_imageStream.removeListener(_getListener(image.loadingBuilder));
_imageStream.addListener(_getListener());*/
}
/*public override void didChangeAccessibilityFeatures() {
base.didChangeAccessibilityFeatures();
setState(() => {
_updateInvertColors();
});
}*/
void _updateInvertColors() {
_invertColors = MediaQuery.of(context, nullOk: true)?.invertColors
?? false;
}
/*ScrollAwareImageProvider provider = new ScrollAwareImageProvider<dynamic>(
context: _scrollAwareContext,
imageProvider: widget.image
);
ImageStream newStream =
provider.resolve(ImageUtils.createLocalImageConfiguration(
context,
size: widget.width != null && widget.height != null
? new Size(widget.width.Value, widget.height.Value)
: null
));*/
ImageStream newStream =
widget.image.resolve(ImageUtils.createLocalImageConfiguration(
context,

D.assert(newStream != null);
_updateSourceStream(newStream);
}
/*ImageStreamListener _getListener(ImageLoadingBuilder loadingBuilder = null) {
loadingBuilder ??= widget.loadingBuilder;
_lastException = null;
_lastStack = null;
return new ImageStreamListener(
_handleImageFrame,
onChunk: loadingBuilder == null ? null : _handleImageChunk,
onError: widget.errorBuilder != null
? (dynamic error, StackTrace stackTrace) => {
setState(() => {
_lastException = error;
_lastStack = stackTrace;
});
}
: null
);
}*/
/*void _handleImageFrame(ImageInfo imageInfo, bool synchronousCall) {
setState(() =>{
_imageInfo = imageInfo;
_loadingProgress = null;
_frameNumber = _frameNumber == null ? 0 : _frameNumber + 1;
_wasSynchronouslyLoaded |= synchronousCall;
});
}
void _handleImageChunk(ImageChunkEvent _event) {
D.assert(widget.loadingBuilder != null);
setState(() => {
_loadingProgress = _event;
});
}*/
void _updateSourceStream(ImageStream newStream) {
if (_imageStream?.key == newStream?.key) {
return;

// _imageStream.removeListener(_handleImageChanged);
_isListeningToStream = false;
}
public override void dispose() {
D.assert(_imageStream != null);
_stopListeningToStream();
base.dispose();
}
if (_lastException != null) {
D.assert(widget.errorBuilder != null);
return widget.errorBuilder(context, _lastException, _lastStack);
}
RawImage image = new RawImage(
image: _imageInfo?.image,
width: widget.width,

invertColors: _invertColors,
filterQuality: widget.filterQuality
);
/*if (widget.frameBuilder != null)
image = widget.frameBuilder(context, image, _frameNumber, _wasSynchronouslyLoaded);
if (widget.loadingBuilder != null)
image = widget.loadingBuilder(context, image, _loadingProgress);*/
return image;
}

description.add(new DiagnosticsProperty<ImageInfo>("pixels", _imageInfo));
//description.add(new DiagnosticsProperty<ImageChunkEvent>("loadingProgress", _loadingProgress));
description.add(new DiagnosticsProperty<int>("frameNumber", _frameNumber));
description.add(new DiagnosticsProperty<bool>("wasSynchronouslyLoaded", _wasSynchronouslyLoaded));
}
public void didChangeMetrics() {
setState();
}
public void didChangeTextScaleFactor() {
setState();
}
public void didChangePlatformBrightness() {
setState();
}
public void didChangeLocales(List<Locale> locale) {
setState();
}
public Future<bool> didPopRoute() {
return Future.value(false).to<bool>();
}
public Future<bool> didPushRoute(string route) {
return Future.value(false).to<bool>();
}
}
}

101
com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs


base.initState();
_controller = new AnimationController(
duration: widget.duration,
debugLabel: "{" + widget.toStringShort() + "}",
debugLabel: foundation_.kDebugMode ? widget.toStringShort() : null,
_controller.addStatusListener((AnimationStatus status) => {
switch (status) {
case AnimationStatus.completed:
if (widget.onEnd != null)
widget.onEnd();
break;
case AnimationStatus.dismissed:
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
});
_updateCurve();
_constructTweens();
didUpdateTweens();

Matrix4 transform = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(duration != null);
D.assert(margin == null || margin.isNonNegative);
D.assert(padding == null || padding.isNonNegative);

EdgeInsets padding = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
D.assert(padding != null);
D.assert(padding.isNonNegative);
this.padding = padding;

public override Widget build(BuildContext context) {
return new Padding(
padding: _padding.evaluate(animation),
padding: (EdgeInsets) _padding
.evaluate(animation)
.clamp(EdgeInsets.zero, EdgeInsets.infinity),
child: widget.child
);
}

Alignment alignment = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(alignment != null);
this.alignment = alignment;
this.child = child;

float? width = null,
float? height = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(left == null || right == null || width == null);
D.assert(top == null || bottom == null || height == null);
this.child = child;

Widget child = null,
Rect rect = null,
Curve curve = null,
TimeSpan? duration = null
TimeSpan? duration = null,
VoidCallback onEnd = null
) {
return new AnimatedPositioned(
child: child,

width: rect.width,
height: rect.height,
curve: curve ?? Curves.linear,
key: key
key: key,
onEnd: onEnd
);
}

float? width = null,
float? height = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
D.assert(start == null || end == null || width == null);
D.assert(top == null || bottom == null || height == null);
this.child = child;

Widget child = null,
float? opacity = null,
Curve curve = null,
TimeSpan? duration = null
TimeSpan? duration = null,
VoidCallback onEnd = null
base(key: key, curve: curve ?? Curves.linear, duration: duration) {
base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
this.child = child;
this.opacity = opacity ?? 1.0f;

child: widget.child
);
}
}
public class SliverAnimatedOpacity : ImplicitlyAnimatedWidget {
protected SliverAnimatedOpacity(
Key key = null,
Widget sliver = null,
float opacity = default,
Curve curve = null,//Curve curve = Curve.linear
TimeSpan duration = default,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
}
public readonly Widget sliver;
public readonly float opacity;
public override State createState() {
return new _SliverAnimatedOpacityState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("opacity", opacity));
}
}
class _SliverAnimatedOpacityState : ImplicitlyAnimatedWidgetState<SliverAnimatedOpacity> {
FloatTween _opacity;
Animation<float> _opacityAnimation;
protected override void forEachTween(TweenVisitor visitor) {
_opacity = (FloatTween) visitor.visit(this,_opacity, widget.opacity, (float value) => new FloatTween(begin: value, 0));
}
protected override void didUpdateTweens() {
_opacityAnimation = animation.drive(_opacity);
}
public override Widget build(BuildContext context) {
return new SliverFadeTransition(
opacity: _opacityAnimation,
sliver: widget.sliver
);
}
}
public class AnimatedDefaultTextStyle : ImplicitlyAnimatedWidget {

125
com.unity.uiwidgets/Runtime/widgets/layout_builder.cs


namespace Unity.UIWidgets.widgets {
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints);
public abstract class ConstrainedLayoutBuilder<ConstraintType> : RenderObjectWidget where ConstraintType : Constraints {
public delegate Widget ConstraintBuilder(BuildContext context, ConstraintType constraints);
public class LayoutBuilder : RenderObjectWidget {
public LayoutBuilder(
public ConstrainedLayoutBuilder(
LayoutWidgetBuilder builder = null) : base(key: key) {
ConstraintBuilder builder = null
) : base(key: key) {
public readonly LayoutWidgetBuilder builder;
return new _LayoutBuilderElement(this);
return new _LayoutBuilderElement<ConstraintType>(this);
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderLayoutBuilder();
}
public readonly ConstraintBuilder builder;
class _LayoutBuilderElement : RenderObjectElement {
public _LayoutBuilderElement(
LayoutBuilder widget) : base(widget) {
public class _LayoutBuilderElement<ConstraintType> : RenderObjectElement
where ConstraintType : Constraints {
public _LayoutBuilderElement(ConstrainedLayoutBuilder<ConstraintType> widget)
: base(widget) {
new LayoutBuilder widget {
get { return (LayoutBuilder) base.widget; }
public new ConstrainedLayoutBuilder<ConstraintType> widget {
get {
return base.widget as ConstrainedLayoutBuilder<ConstraintType>;
}
new _RenderLayoutBuilder renderObject {
get { return (_RenderLayoutBuilder) base.renderObject; }
public new RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject> renderObject {
get { return base.renderObject as RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject>;}
if (_child != null) {
if (_child != null)
}
base.forgetChild(child);
base.mount(parent, newSlot);
renderObject.callback = _layout;
base.mount(parent, newSlot); // Creates the renderObject.
renderObject.updateCallback(_layout);
newWidget = (ConstrainedLayoutBuilder<ConstraintType>) newWidget;
renderObject.callback = _layout;
renderObject.updateCallback(_layout);
base.performRebuild();
base.performRebuild(); // Calls widget.updateRenderObject (a no-op in this case).
renderObject.callback = null;
renderObject.updateCallback(null);
void _layout(BoxConstraints constraints) {
owner.buildScope(this, () => {
public void _layout(ConstraintType constraints) {
owner.buildScope(this, ()=> {
built = widget.builder(this, constraints);
built = widget.builder(this, constraints);
_child = updateChild(_child, built, null);
_child = updateChild(_child, built, null);
_RenderLayoutBuilder renderObject = this.renderObject;
RenderObjectWithChildMixin<RenderObject> renderObject = this.renderObject;
renderObject.child = (RenderBox) child;
renderObject.child = child;
D.assert(renderObject == this.renderObject);
}

protected override void removeChildRenderObject(RenderObject child) {
_RenderLayoutBuilder renderObject = this.renderObject;
RenderConstrainedLayoutBuilderMixinRenderObject<ConstraintType, RenderObject> renderObject = this.renderObject;
public interface RenderConstrainedLayoutBuilder<ConstraintType,ChildType>
where ConstraintType : Constraints
where ChildType : RenderObject
{
public class _RenderLayoutBuilder : RenderObjectWithChildMixinRenderBox<RenderBox> {
LayoutCallback<ConstraintType> _callback { get; set; }
void updateCallback(LayoutCallback<ConstraintType> value);
void layoutAndBuildChild();
}
public class LayoutBuilder : ConstrainedLayoutBuilder<BoxConstraints> {
public LayoutBuilder(
Key key = null,
ConstraintBuilder builder = null
) : base(key: key, builder: builder) {
D.assert(builder != null);
}
public static LayoutBuilder Create(
LayoutWidgetBuilder builder,
Key key = null
) {
ConstraintBuilder _builder = (context, constraints) => {
return builder(context, (BoxConstraints)constraints);
};
return new LayoutBuilder(key,_builder);
}
public new LayoutWidgetBuilder builder {
get {
LayoutWidgetBuilder _builder = (context, constraints) => {
return base.builder(context, (BoxConstraints) constraints);
};
return _builder;
}
}
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderLayoutBuilder();
}
}
public class _RenderLayoutBuilder : RenderConstrainedLayoutBuilderMixinRenderBox<BoxConstraints, RenderBox> {
LayoutCallback<BoxConstraints> callback = null) {
LayoutCallback<BoxConstraints> callback = null) {
_callback = callback;
}

return true;
}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
D.assert(_debugThrowIfNotCheckingIntrinsics());
return 0.0f;
}

33
com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;

return null;
}
List<Future> futures = new List<Future>();
foreach (_FixedExtentScrollPosition position in positions) {
foreach (_FixedExtentScrollPosition position in positions.Cast<_FixedExtentScrollPosition>()) {
futures.Add(position.animateTo(
itemIndex * position.itemExtent,
duration: duration,

float offAxisFraction = 0.0f,
bool useMagnifier = false,
float magnification = 1.0f,
float overAndUnderCenterOpacity = 1.0f,
float squeeze = 1.0f,
ValueChanged<int> onSelectedItemChanged = null,
bool clipToSize = true,
bool renderChildrenOutsideViewport = false,

D.assert(perspective > 0);
D.assert(perspective <= 0.01f, () => RenderListWheelViewport.perspectiveTooHighMessage);
D.assert(magnification > 0);
D.assert(overAndUnderCenterOpacity != null);
D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
D.assert(squeeze != null);
D.assert(squeeze > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,
() => RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict

this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
this.squeeze = squeeze;
this.controller = controller;
this.physics = physics;
this.diameterRatio = diameterRatio;

public static ListWheelScrollView useDelegate(
float itemExtent,
float overAndUnderCenterOpacity = 1.0f,
float squeeze = 1.0f,
List<Widget> children = null,
ListWheelChildDelegate childDelegate = null,
Key key = null,

public readonly bool useMagnifier;
public readonly float magnification;
public readonly float itemExtent;
public readonly float overAndUnderCenterOpacity;
public readonly float squeeze;
public readonly ValueChanged<int> onSelectedItemChanged;
public readonly bool clipToSize;
public readonly bool renderChildrenOutsideViewport;

offAxisFraction: widget.offAxisFraction,
useMagnifier: widget.useMagnifier,
magnification: widget.magnification,
overAndUnderCenterOpacity: widget.overAndUnderCenterOpacity,
squeeze: widget.squeeze,
clipToSize: widget.clipToSize,
renderChildrenOutsideViewport: widget.renderChildrenOutsideViewport,
offset: _offset,

internal override void forgetChild(Element child) {
_childElements.Remove((int) (child.slot));
base.forgetChild(child);
}
}

bool useMagnifier = false,
float magnification = 1.0f,
bool clipToSize = true,
bool renderChildrenOutsideViewport = false
bool renderChildrenOutsideViewport = false,
float overAndUnderCenterOpacity = 1.0f,
float squeeze = 1.0f
) : base(key: key) {
D.assert(childDelegate != null);
D.assert(offset != null);

D.assert(overAndUnderCenterOpacity != null);
D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
D.assert(itemExtent > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,

this.magnification = magnification;
this.clipToSize = clipToSize;
this.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
this.squeeze = squeeze;
}
public readonly float diameterRatio;

public readonly float magnification;
public readonly float overAndUnderCenterOpacity;
public readonly float squeeze;
public readonly bool clipToSize;
public readonly bool renderChildrenOutsideViewport;
public readonly ViewportOffset offset;

offAxisFraction: offAxisFraction,
useMagnifier: useMagnifier,
magnification: magnification,
overAndUnderCenterOpacity: overAndUnderCenterOpacity,
squeeze: squeeze,
clipToSize: clipToSize,
renderChildrenOutsideViewport: renderChildrenOutsideViewport
);

viewport.offAxisFraction = offAxisFraction;
viewport.useMagnifier = useMagnifier;
viewport.magnification = magnification;
viewport.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
viewport.squeeze = squeeze;
viewport.clipToSize = clipToSize;
viewport.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
}

21
com.unity.uiwidgets/Runtime/widgets/localizations.cs


using System.Linq;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {

public static Locale localeOf(BuildContext context, bool nullOk = false) {
D.assert(context != null);
_LocalizationsScope scope =
(_LocalizationsScope) context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope));
(_LocalizationsScope) context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>();
if (nullOk && scope == null) {
return null;
}

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

D.assert(type != null);
_LocalizationsScope scope =
(_LocalizationsScope) context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope));
(_LocalizationsScope) context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>();
if (scope != null && scope.localizationsState != null) {
return scope.localizationsState.resourcesFor<T>(type);
}

_locale = locale;
}
else {
// WidgetsBinding.instance.deferFirstFrameReport();
// WidgetsBinding.instance.allowFirstFrameReport();
if (!mounted) {
return;
if (mounted) {
setState(() => {
_typeToResources = (Dictionary<Type, object>) value;
_locale = locale;
});
setState(() => {
_typeToResources = (Dictionary<Type, object>)value;
_locale = locale;
});
});
}
}

34
com.unity.uiwidgets/Runtime/widgets/media_query.cs


viewPadding : EdgeInsets.fromWindowPadding(window.viewPadding, window.devicePixelRatio),
viewInsets: EdgeInsets.fromWindowPadding(window.viewInsets, window.devicePixelRatio),
systemGestureInsets : EdgeInsets.fromWindowPadding(window.systemGestureInsets, window.devicePixelRatio),
physicalDepth : window.physicalDepth
// accessibleNavigation: window.accessibilityFeatures.accessibleNavigation,
// invertColors: window.accessibilityFeatures.invertColors,
// disableAnimations: window.accessibilityFeatures.disableAnimations,
// boldText: window.accessibilityFeatures.boldText,
// highContrast : window.accessibilityFeatures.highContrast,
//alwaysUse24HourFormat: window.alwaysUse24HourFormat
physicalDepth : window.physicalDepth,
accessibleNavigation: window.accessibilityFeatures.accessibleNavigation,
invertColors: window.accessibilityFeatures.invertColors,
disableAnimations: window.accessibilityFeatures.disableAnimations,
boldText: window.accessibilityFeatures.boldText,
highContrast : window.accessibilityFeatures.highContrast,
alwaysUse24HourFormat: window.alwaysUse24HourFormat
);
}

D.assert(context != null);
//MediaQuery query = context.dependOnInheritedWidgetOfExactType<MediaQuery>();
MediaQuery query = (MediaQuery) context.inheritFromWidgetOfExactType(typeof(MediaQuery));
MediaQuery query = (MediaQuery) context.dependOnInheritedWidgetOfExactType<MediaQuery>();
if (query != null) {
return query.data;
}

}
throw new UIWidgetsError(
"MediaQuery.of() called with a context that does not contain a MediaQuery.\n" +
"No MediaQuery ancestor could be found starting from the context that was passed " +
"to MediaQuery.of(). This can happen because you do not have a WidgetsApp or " +
"MaterialApp widget (those widgets introduce a MediaQuery), or it can happen " +
"if the context you use comes from a widget above those widgets.\n" +
"The context used was:\n" +
$" {context}");
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("MediaQuery.of() called with a context that does not contain a MediaQuery."),
new ErrorDescription(
"No MediaQuery ancestor could be found starting from the context that was passed " +
"to MediaQuery.of(). This can happen because you do not have a WidgetsApp or " +
"MaterialApp widget (those widgets introduce a MediaQuery), or it can happen " +
"if the context you use comes from a widget above those widgets."
),
context.describeElement("The context used was")
});
}
public static float textScaleFactorOf(BuildContext context) {

98
com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs


using Unity.UIWidgets.animation;
using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.widgets {
public class ModalBarrier : StatelessWidget {

}
public override Widget build(BuildContext context) {
return new GestureDetector(
onTapDown: details => {
return new _ModalBarrierGestureDetector(
onDismiss: () => {
behavior: HitTestBehavior.opaque,
child: new ConstrainedBox(
constraints: BoxConstraints.expand(),
child: color == null ? null : new DecoratedBox(decoration: new BoxDecoration(color))
child: new MouseRegion(
opaque: true,
child: new ConstrainedBox(
constraints: BoxConstraints.expand(),
child: color == null ? null : new DecoratedBox(
decoration: new BoxDecoration(
color: color
)
)
)
)
);
}

return new ModalBarrier(color: color?.value, dismissible: dismissible);
}
}
public class _AnyTapGestureRecognizer : BaseTapGestureRecognizer {
public _AnyTapGestureRecognizer( Object debugOwner = null) : base(debugOwner: debugOwner) {}
public VoidCallback onAnyTapUp;
protected override bool isPointerAllowed(PointerDownEvent _event) {
if (onAnyTapUp == null)
return false;
return base.isPointerAllowed(_event);
}
protected override void handleTapDown(PointerDownEvent down = null) {
// Do nothing.
}
protected override void handleTapUp(PointerDownEvent down = null, PointerUpEvent up = null) {
if (onAnyTapUp != null)
onAnyTapUp();
}
protected override void handleTapCancel(PointerDownEvent down = null, PointerCancelEvent cancel = null, string reason = null) {
// Do nothing.
}
public override string debugDescription {
get {
return "any tap";
}
}
}
public class _AnyTapGestureRecognizerFactory : GestureRecognizerFactory<_AnyTapGestureRecognizer> {
public _AnyTapGestureRecognizerFactory(VoidCallback onAnyTapUp = null) {
this.onAnyTapUp = onAnyTapUp;
}
public readonly VoidCallback onAnyTapUp;
public override _AnyTapGestureRecognizer constructor() => new _AnyTapGestureRecognizer();
public override void initializer(_AnyTapGestureRecognizer instance) {
instance.onAnyTapUp = onAnyTapUp;
}
}
public class _ModalBarrierGestureDetector : StatelessWidget {
public _ModalBarrierGestureDetector(
Key key = null,
Widget child = null,
VoidCallback onDismiss = null
) : base(key: key) {
D.assert(child != null);
D.assert(onDismiss != null);
}
public readonly Widget child;
public readonly VoidCallback onDismiss;
public override Widget build(BuildContext context) {
Dictionary<Type, GestureRecognizerFactory> gestures = new Dictionary<Type, GestureRecognizerFactory>(){
{typeof(_AnyTapGestureRecognizer), new _AnyTapGestureRecognizerFactory(onAnyTapUp: onDismiss)}
};
return new RawGestureDetector(
gestures: gestures,
behavior: HitTestBehavior.opaque,
child: child
);
}
}
}

253
com.unity.uiwidgets/Runtime/widgets/navigator.cs


using System;
using System.Collections;
using Unity.UIWidgets.external.simplejson;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;

routeEntry = historyEntry;
break;
}
}
return routeEntry?.isPresent == true;
}
return routeEntry?.isPresent == true;
}
}
}

}
public class RouteSettings {
public RouteSettings(string name = null, bool isInitialRoute = false, object arguments = null) {
public RouteSettings(
string name = null,
object arguments = null) {
this.isInitialRoute = isInitialRoute;
RouteSettings copyWith(string name = null, bool? isInitialRoute = null, object arguments = null) {
RouteSettings copyWith(
string name = null,
object arguments = null) {
isInitialRoute ?? this.isInitialRoute,
public readonly bool isInitialRoute;
public readonly string name;

}
}
public abstract class Page<T> : RouteSettings {
public abstract class Page : RouteSettings {
public Page(
Key key = null,
string name = null,

public LocalKey key;
public bool canUpdate(Page<object> other) {
public bool canUpdate(Page other) {
public abstract Route<T> createRoute(BuildContext context);
//public abstract Route createRoute(BuildContext context);
public override string ToString() {
return $"{GetType()}(\"{name}\",{key},{arguments})";

/*public class Page<T> : Page {
readonly Page _page;
public abstract class Page<T> : Page {
public Page(
Key key = null,
string name = null,

}
public bool canUpdate(Page<object> other) {
return other.GetType() == GetType() &&
other.key == key;
}
public Route<T> createRoute(BuildContext context) {
//return new Route<T>(context);
}
}*/
public abstract Route<T> createRoute(BuildContext context);
}
public class CustomBuilderPage<T> : Page<T> {
public CustomBuilderPage(

object arguments = null
) : base(key: key, name: name, arguments: arguments) {
D.assert(key != null);
D.assert(routeBuilder != null);
this.routeBuilder = routeBuilder;
}

}
public IEnumerable<RouteTransitionRecord> _transition(
List<RouteTransitionRecord> newPageRouteHistory,
Dictionary<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute,
Dictionary<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes
List<RouteTransitionRecord> newPageRouteHistory = null,
Dictionary<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute = null,
Dictionary<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes = null
) {
IEnumerable<RouteTransitionRecord> results = resolve(
newPageRouteHistory: newPageRouteHistory,

foreach(RouteTransitionRecord item in locationToExitingPageRoute.Values) {
exitingPageRoutes.Add(item);
}
// Firstly, verifies all exiting routes have been marked.
foreach (RouteTransitionRecord exitingPageRoute in exitingPageRoutes) {
D.assert(!exitingPageRoute._debugWaitingForExitDecision);
if (pageRouteToPagelessRoutes.ContainsKey(exitingPageRoute)) {

List<RouteTransitionRecord> newPageRouteHistory = null,
Dictionary<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute = null,
Dictionary<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes = null) {
void handleExitingRoute(RouteTransitionRecord location, bool isLast) {
RouteTransitionRecord exitingPageRoute = locationToExitingPageRoute[location];
if (exitingPageRoute == null)

public static readonly string defaultRouteName = "/";
/// <summary>
/// Future<T> pushNamed<T extends object>(
public static Future<T> pushNamed<T>(BuildContext context, string routeName, object arguments = null) {
return of(context).pushNamed<T>(routeName, arguments: arguments);

TO result , object arguments = null) {
TO result = default , object arguments = null) {
TO result ,
TO result = default,
object arguments = null) {
return of(context).popAndPushNamed<T,TO>(routeName, result: result, arguments: arguments);
}

return of(context).push<T>(route);
}
public static Future<T> pushReplacement<T,TO>(BuildContext context, Route<T> newRoute, TO result ) {
public static Future<T> pushReplacement<T,TO>(BuildContext context, Route<T> newRoute, TO result = default ) {
return of(context).pushReplacement<T,TO>(newRoute, result);
}

}
public static void replace<T>(BuildContext context, Route oldRoute, Route<T> newRoute ) {
public static void replace<T>(BuildContext context, Route oldRoute = null, Route<T> newRoute = null) {
public static void replaceRouteBelow<T>(BuildContext context, Route anchorRoute, Route<T> newRoute ) {
public static void replaceRouteBelow<T>(BuildContext context, Route anchorRoute = null, Route<T> newRoute = null ) {
of(context).replaceRouteBelow<T>(anchorRoute: anchorRoute, newRoute: newRoute);
}

public static void removeRouteBelow(BuildContext context, Route anchorRoute) {
of(context).removeRouteBelow(anchorRoute);
}
/*public static void replace(BuildContext context, Route oldRoute = null, Route newRoute = null) {
D.assert(oldRoute != null);
D.assert(newRoute != null);
of(context).replace(oldRoute: oldRoute, newRoute: newRoute);
}
public static void replaceRouteBelow(BuildContext context, Route anchorRoute = null, Route newRoute = null) {
D.assert(anchorRoute != null);
D.assert(newRoute != null);
of(context).replaceRouteBelow(anchorRoute: anchorRoute, newRoute: newRoute);
}
public static bool canPop(BuildContext context) {
NavigatorState navigator = of(context, nullOk: true);
return navigator != null && navigator.canPop();
}
public static Future<bool> maybePop(BuildContext context, object result = null) {
return of(context).maybePop(result);
}
public static bool pop(BuildContext context, object result = null) {
return of(context).pop(result);
}
public static void popUntil(BuildContext context, RoutePredicate predicate) {
of(context).popUntil(predicate);
}
public static void removeRoute(BuildContext context, Route route) {
of(context).removeRoute(route);
}
static void removeRouteBelow(BuildContext context, Route anchorRoute) {
of(context).removeRouteBelow(anchorRoute);
}*/
public static NavigatorState of(
BuildContext context,
bool rootNavigator = false,

_RouteLifecycle initialState
) {
D.assert(route != null);
D.assert(initialState != null);
D.assert(
initialState == _RouteLifecycle.staging ||
initialState == _RouteLifecycle.add ||

}
public Route route;
public _RouteLifecycle currentState;
public Route lastAnnouncedPreviousRoute; // last argument to Route.didChangePrevious
public Route lastAnnouncedPoppedNextRoute; // last argument to Route.didPopNext

get { return route.settings is Page<object>; }
get { return route.settings is Page; }
public bool canUpdateFrom(Page<object> page) {
public bool canUpdateFrom(Page page) {
Page<object> routePage = route.settings as Page<object>;
Page routePage = route.settings as Page;
return page.canUpdate(routePage);
}

lastAnnouncedPoppedNextRoute = poppedRoute;
}
public void handlePop(NavigatorState navigator, Route previousPresent) {
public void handlePop(NavigatorState navigator , Route previousPresent = null) {
D.assert(navigator != null);
D.assert(navigator._debugLocked);
D.assert(route._navigator == navigator);

}
public void handleRemoval(NavigatorState navigator, Route previousPresent) {
public void handleRemoval(NavigatorState navigator, Route previousPresent = null) {
D.assert(navigator != null);
D.assert(navigator._debugLocked);
D.assert(route._navigator == navigator);

public bool doingPop = false;
public void didAdd(NavigatorState navigator, bool isNewFirst, Route previous, Route previousPresent) {
public void didAdd(
NavigatorState navigator = null,
bool isNewFirst = false,
Route previous = null,
Route previousPresent = null) {
route.didAdd();
currentState = _RouteLifecycle.idle;
if (isNewFirst) {

bool _reportRemovalToObserver = true;
// Route is removed without being completed.
public void remove(bool isReplaced = false) {
D.assert(
!hasPage || _debugWaitingForExitDecision, () =>

currentState = _RouteLifecycle.remove;
}
// Route completes with `result` and is removed.
public void complete<T>(T result, bool isReplaced = false) {
D.assert(
!hasPage || _debugWaitingForExitDecision, () =>

public void dispose() {
D.assert(currentState.GetHashCode() < _RouteLifecycle.disposed.GetHashCode());
((Route)route).dispose();
//route._navigator = null;
currentState = _RouteLifecycle.disposed;
}

"This route cannot be marked for pop. Either a decision has already been " +
"made or it does not require an explicit decision on how to transition out."
);
pop<object>(result);
pop(result);
_debugWaitingForExitDecision = false;
}

"been made or it does not require an explicit decision on how to transition " +
"out."
);
complete<object>(result);
complete(result);
_debugWaitingForExitDecision = false;
}

string initialRoute = widget.initialRoute;
if (widget.pages.isNotEmpty()) {
foreach (Page<object> page in widget.pages) {
foreach (Page<object> page in widget.pages) {
_history.Add(
new _RouteEntry(
page.createRoute(context),

}
if (initialRoute != null) {
foreach (Route route in
(widget.onGenerateInitialRoutes(this, widget.initialRoute
?? Navigator.defaultRouteName))) {
_history.Add(
new _RouteEntry(
route,
initialState: _RouteLifecycle.add
)
);
}
_history.AddRange(
widget.onGenerateInitialRoutes(
this,
widget.initialRoute ?? Navigator.defaultRouteName
).Select((Route route) =>
new _RouteEntry(
route,
initialState: _RouteLifecycle.add
)
)
);
D.assert(!_debugLocked);
D.assert(() => {
_debugLocked = true;

}
public new void didUpdateWidget(Navigator oldWidget) {
// oldWidget = (Navigator) oldWidget;
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (Navigator) oldWidget;
base.didUpdateWidget(oldWidget);
D.assert(
widget.pages.isEmpty() || widget.onPopPage != null, () =>

void _debugCheckDuplicatedPageKeys() {
D.assert(() => {
List<Key> keyReservation = new List<Key>();
foreach (Page<object> page in widget.pages) {
foreach (Page page in widget.pages) {
if (page.key != null) {
D.assert(!keyReservation.Contains(page.key));
keyReservation.Add(page.key);

});
foreach (NavigatorObserver observer in widget.observers)
observer._navigator = null;
focusScopeNode.dispose();/// focus manager dispose
focusScopeNode.dispose();
// don"t unlock, so that the object becomes unusable
D.assert(_debugLocked);
}

if (newPagesBottom > newPagesTop)
break;
Page<object> newPage = widget.pages[newPagesBottom];
Page newPage = widget.pages[newPagesBottom];
if (!oldEntry.canUpdateFrom(newPage))
break;
previousOldPageRouteEntry = oldEntry;

continue;
}
Page<object> newPage = widget.pages[newPagesTop];
Page newPage = widget.pages[newPagesTop];
if (!oldEntry.canUpdateFrom(newPage))
break;
pagelessRoutesToSkip = 0;

continue;
D.assert(oldEntry.hasPage);
Page<object> page = oldEntry.route.settings as Page<object>;
Page page = oldEntry.route.settings as Page;
if (page.key == null)
continue;

continue;
}
Page<object> potentialPageToRemove = potentialEntryToRemove.route.settings as Page<object>;
Page potentialPageToRemove = potentialEntryToRemove.route.settings as Page;
if (
potentialPageToRemove.key == null ||

}
previousOldPageRouteEntry = oldEntry;
Page<object> newPage = widget.pages[newPagesBottom];
Page newPage = widget.pages[newPagesBottom];
D.assert(oldEntry.canUpdateFrom(newPage));
oldEntry.route._updateSettings(newPage);
newHistory.Add(oldEntry);

}
results = widget.transitionDelegate._transition(
newPageRouteHistory:newHistoryRecord,
// List<RouteTransitionRecord> : newHistory = List<_RouteEntry>
locationToExitingPageRoute: locationToExitingPageRoute,
pageRouteToPagelessRoutes: pageRouteToPagelessRoutesRecord
).Cast<_RouteEntry>();

// Adds the leading pageless routes if there is any.
if (pageRouteToPagelessRoutes.ContainsKey(null)) {
foreach (var pageRoute in pageRouteToPagelessRoutes[null]) {
_history.Add(pageRoute);
}
//_history.addAll(pageRouteToPagelessRoutes[null]);
_history.AddRange(pageRouteToPagelessRoutes[null]);
//_history.addAll(pageRouteToPagelessRoutes[result]);
foreach (var pageRoute in pageRouteToPagelessRoutes[result]) {
_history.Add(pageRoute);
}
_history.AddRange(pageRouteToPagelessRoutes[result]);
}
}

_flushRouteAnnouncement();
/* _RouteEntry lastEntry = null;//_history.lastWhere(_RouteEntry.isPresentPredicate, orElse: () => null);
_RouteEntry lastEntry = null;//_history.lastWhere(_RouteEntry.isPresentPredicate, orElse: () => null);
foreach (var historyEntry in _history) {
if (_RouteEntry.isPresentPredicate(historyEntry)) {
lastEntry = historyEntry;

if (routeName != _lastAnnouncedRouteName) {
//RouteNotificationMessages.maybeNotifyRouteChange(routeName, _lastAnnouncedRouteName);
//RouteNotificationMessages.maybeNotifyRouteChange(routeName, _lastAnnouncedRouteName);
}*/
}
// Lastly, removes the overlay entries of all marked entries and disposes
// them.

D.assert(() => {
if (widget.onUnknownRoute == null) {
throw new UIWidgetsError(
"Navigator.onGenerateRoute returned null when requested to build route " + $"{name}." +
"The onGenerateRoute callback must never return null, unless an onUnknownRoute " +
"callback is provided as well." +
new DiagnosticsProperty<NavigatorState>("The Navigator was", this,
style: DiagnosticsTreeStyle.errorProperty)
new List<DiagnosticsNode>() {
new ErrorSummary($"Navigator.onGenerateRoute returned null when requested to build route \"{name}\"."),
new ErrorDescription(
"The onGenerateRoute callback must never return null, unless an onUnknownRoute "+
"callback is provided as well."
),
new DiagnosticsProperty<NavigatorState>("The Navigator was", this, style: DiagnosticsTreeStyle.errorProperty),
}
);
}

D.assert(() => {
if (route == null) {
throw new UIWidgetsError(
"Navigator.onUnknownRoute returned null when requested to build route " + $"{name}." +
"The onUnknownRoute callback must never return null." +
new DiagnosticsProperty<NavigatorState>("The Navigator was", this,
style: DiagnosticsTreeStyle.errorProperty)
new List<DiagnosticsNode>() {
new ErrorSummary($"Navigator.onUnknownRoute returned null when requested to build route \"{name}\"."),
new ErrorDescription("The onUnknownRoute callback must never return null."),
new DiagnosticsProperty<NavigatorState>("The Navigator was", this, style: DiagnosticsTreeStyle.errorProperty),
}
);
}

public Future<T> pushReplacementNamed<T, TO>(
string routeName,
TO result,
TO result = default,
object arguments = null
) {
return pushReplacement<T, TO>(_routeNamed<T>(routeName, arguments: arguments), result: result);

string routeName,
TO result,
TO result = default,
object arguments = null
) {
pop<TO>(result);

_afterNavigation(route);
return route.popped.to<T>();
}
/*if (!kReleaseMode) {
if (!foundation_.kReleaseMode) {
if (route is TransitionRoute<T>) {
TransitionRoute<T> transitionRoute = (TransitionRoute<T>)route;
description = transitionRoute.debugLabel;
if (route is TransitionRoute ){
//TransitionRoute transitionRoute = route;
description = ((TransitionRoute)route).debugLabel;
description = "$route";
description = $"{route}";
}
routeJsonable["description"] = description;

"name": settings.name
{"name", settings.name}
if (settings.arguments != null) {
/*if (settings.arguments != null) {
toEncodable: (object object) => "$object"
);
}
toEncodable: (object _object) => $"{_object}"
);
}*/
developer.postEvent("Flutter.Navigation", < string, object >{
"route": routeJsonable
// todo
developer.developer_.postEvent("Flutter.Navigation", new Hashtable{
{"route", routeJsonable}
}*/
}
public Future<T> pushReplacement<T, TO>(Route<T> newRoute, TO result) {
D.assert(!_debugLocked);

_debugLocked = true;
return true;
});
//D.assert(_history.where(_RouteEntry.isRoutePredicate(route)).length == 1);
// D.assert(_history.Where(_RouteEntry.isRoutePredicate(route)).Count() == 1);
List<_RouteEntry> routeEntries = new List<_RouteEntry>();
foreach (var historyEntry in _history) {
if (_RouteEntry.isRoutePredicate(route)(historyEntry)) {

51
com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs


public readonly DragStartBehavior dragStartBehavior;
public static SliverOverlapAbsorberHandle sliverOverlapAbsorberHandleFor(BuildContext context) {
_InheritedNestedScrollView target =
(_InheritedNestedScrollView) context.inheritFromWidgetOfExactType(typeof(_InheritedNestedScrollView));
_InheritedNestedScrollView target = context.dependOnInheritedWidgetOfExactType<_InheritedNestedScrollView>();
() => {
return
"NestedScrollView.sliverOverlapAbsorberHandleFor must be called with a context that contains a NestedScrollView.";
});
() => "NestedScrollView.sliverOverlapAbsorberHandleFor must be called with a context that contains a NestedScrollView."
);
List<Widget> slivers = new List<Widget> { };
List<Widget> slivers = new List<Widget>();
slivers.AddRange(headerSliverBuilder(context, bodyIsScrolled));
slivers.Add(new SliverFillRemaining(
child: new PrimaryScrollController(

}
public override State createState() {
return new _NestedScrollViewState();
return new NestedScrollViewState();
class _NestedScrollViewState : State<NestedScrollView> {
internal SliverOverlapAbsorberHandle _absorberHandle = new SliverOverlapAbsorberHandle();
class NestedScrollViewState : State<NestedScrollView> {
internal readonly SliverOverlapAbsorberHandle _absorberHandle = new SliverOverlapAbsorberHandle();
ScrollController innerController => _coordinator._innerController;
ScrollController outerController => _coordinator._outerController;
_NestedScrollCoordinator _coordinator;

class _InheritedNestedScrollView : InheritedWidget {
public _InheritedNestedScrollView(
Key key = null,
_NestedScrollViewState state = null,
NestedScrollViewState state = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(state != null);

public readonly _NestedScrollViewState state;
public readonly NestedScrollViewState state;
public override bool updateShouldNotify(InheritedWidget _old) {
_InheritedNestedScrollView old = _old as _InheritedNestedScrollView;

class _NestedScrollCoordinator : ScrollActivityDelegate, ScrollHoldController {
public _NestedScrollCoordinator(
_NestedScrollViewState _state,
NestedScrollViewState _state,
ScrollController _parent,
VoidCallback _onHasScrolledBodyChanged) {
float initialScrollOffset = _parent?.initialScrollOffset ?? 0.0f;

this._onHasScrolledBodyChanged = _onHasScrolledBodyChanged;
}
public readonly _NestedScrollViewState _state;
public readonly NestedScrollViewState _state;
ScrollController _parent;
public readonly VoidCallback _onHasScrolledBodyChanged;

float velocity) {
return position.createBallisticScrollActivity(
position.physics.createBallisticSimulation(
velocity == 0 ? (ScrollMetrics) position : _getMetrics(position, velocity),
velocity == 0f ? (ScrollMetrics) position : _getMetrics(position, velocity),
velocity
),
mode: _NestedBallisticScrollActivityMode.inner

public SliverOverlapAbsorber(
Key key = null,
SliverOverlapAbsorberHandle handle = null,
Widget child = null
) : base(key: key, child: child) {
Widget child = null,
Widget sliver = null
) : base(key: key, child: sliver ?? child) {
D.assert(child == null || sliver == null);
this.handle = handle;
}

public class RenderSliverOverlapAbsorber : RenderObjectWithChildMixinRenderSliver<RenderSliver> {
public RenderSliverOverlapAbsorber(
SliverOverlapAbsorberHandle handle,
RenderSliver child = null
RenderSliver child = null,
RenderSliver sliver = null
D.assert(child == null || sliver == null);
this.child = child;
this.child = sliver ?? child;
}
public SliverOverlapAbsorberHandle handle {

scrollExtent: childLayoutGeometry.scrollExtent - childLayoutGeometry.maxScrollObstructionExtent,
paintExtent: childLayoutGeometry.paintExtent,
paintOrigin: childLayoutGeometry.paintOrigin,
layoutExtent: childLayoutGeometry.paintExtent - childLayoutGeometry.maxScrollObstructionExtent,
layoutExtent: Mathf.Max(0, childLayoutGeometry.paintExtent - childLayoutGeometry.maxScrollObstructionExtent),
maxPaintExtent: childLayoutGeometry.maxPaintExtent,
maxScrollObstructionExtent: childLayoutGeometry.maxScrollObstructionExtent,
hitTestExtent: childLayoutGeometry.hitTestExtent,

public SliverOverlapInjector(
Key key = null,
SliverOverlapAbsorberHandle handle = null,
Widget child = null
) : base(key: key, child: child) {
Widget child = null,
Widget sliver = null
) : base(key: key, child: sliver ?? child) {
D.assert(child == null || sliver == null);
this.handle = handle;
}

385
com.unity.uiwidgets/Runtime/widgets/overlay.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.widgets {
public class OverlayEntry {

internal OverlayState _overlay;
internal readonly GlobalKey<_OverlayEntryWidgetState> _key = new LabeledGlobalKey<_OverlayEntryWidgetState>();
internal readonly GlobalKey<_OverlayEntryWidgetState> _key = GlobalKey<_OverlayEntryWidgetState>.key();//new LabeledGlobalKey<_OverlayEntryWidgetState>();
public void remove() {
D.assert(_overlay != null);

class _OverlayEntryWidget : StatefulWidget {
internal _OverlayEntryWidget(Key key, OverlayEntry entry, bool tickerEnabled = true) : base(key: key) {
internal _OverlayEntryWidget(
Key key,
OverlayEntry entry,
bool tickerEnabled = true) : base(key: key) {
D.assert(key != null);
D.assert(entry != null);
this.entry = entry;

class _OverlayEntryWidgetState : State<_OverlayEntryWidget> {
public override Widget build(BuildContext context) {
return widget.entry.builder(context);
return new TickerMode(
enabled: widget.tickerEnabled,
child: widget.entry.builder(context)
);
/* the state that changed is in the builder */
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key) {
public Overlay(
Key key = null,
List<OverlayEntry> initialEntries = null) : base(key) {
D.assert(initialEntries != null);
this.initialEntries = initialEntries;
}

public static OverlayState of(BuildContext context, Widget debugRequiredFor = null) {
OverlayState result = (OverlayState) context.ancestorStateOfType(new TypeMatcher<OverlayState>());
public static OverlayState of(
BuildContext context,
bool rootOverlay = false,
Widget debugRequiredFor = null) {
OverlayState result = rootOverlay
? context.findRootAncestorStateOfType<OverlayState>()
: context.findAncestorStateOfType<OverlayState>();
? $"\nThe context from which that widget was searching for an overlay was:\n {context}"
: "";
? context.describeElement($"\nThe context from which that widget was searching for an overlay was:\n {context}")
: context.describeElement("");
"No Overlay widget found.\n" +
$"{debugRequiredFor.GetType()} widgets require an Overlay widget ancestor for correct operation.\n" +
"The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n" +
"The specific widget that failed to find an overlay was:\n" +
$" {debugRequiredFor}" +
$"{additional}"
);
new List<DiagnosticsNode>()
{
new ErrorSummary("No Overlay widget found."),
new ErrorDescription($"{debugRequiredFor.GetType()} widgets require an Overlay widget ancestor for correct operation."),
new ErrorHint("The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call."),
new DiagnosticsProperty<Widget>("The specific widget that failed to find an overlay was", debugRequiredFor, style: DiagnosticsTreeStyle.errorProperty),
additional
});
}
return true;

{
List<OverlayEntry> newEntriesList =
newEntries is List<OverlayEntry> ? (newEntries as List<OverlayEntry>) : newEntries.ToList();
/*D.assert(above == null || below == null, () => "Only one of `above` and `below` may be specified.");
D.assert(above == null || (above._overlay == this && _entries.Contains(above)),
() => "The provided entry for `above` is not present in the Overlay.");
D.assert(below == null || (below._overlay == this && _entries.Contains(below)),
() => "The provided entry for `below` is not present in the Overlay.");
D.assert(newEntriesList.All(entry => !_entries.Contains(entry)),
() => "One or more of the specified entries are already present in the Overlay.");
D.assert(newEntriesList.All(entry => entry._overlay == null),
() => "One or more of the specified entries are already present in another Overlay.");*/
above == null || below == null,
()=>"Only one of `above` and `below` may be specified."
);
above == null || below == null,
() => "Only one of `above` and `below` may be specified."
);
D.assert(
above == null || (above._overlay == this && _entries.Contains(above)),
() => "The provided entry for `above` is not present in the Overlay."
);
D.assert(
below == null || (below._overlay == this && _entries.Contains(below)),
() => "The provided entry for `below` is not present in the Overlay."
);
above == null || (above._overlay == this && _entries.Contains(above) && newEntriesList.Contains(above)),
()=>"The entry used for `above` must be in the Overlay and in the `newEntriesList`."
);
newEntriesList.All(entry => entry._overlay == null || entry._overlay == this),
() => "One or more of the specified entries are already present in another Overlay."
);
below == null || (below._overlay == this && _entries.Contains(below) && newEntriesList.Contains(below)),
()=>"The entry used for `below` must be in the Overlay and in the `newEntriesList`."
);
int overlayEntry = 0;
foreach (var newEntry in newEntriesList) {
if (newEntry._overlay == null || newEntry._overlay == this) {
overlayEntry++;
}
}
D.assert(overlayEntry == newEntriesList.Count,
()=>"One or more of the specified entries are already present in another Overlay."
);
int lastoverlayEntry = 0;
foreach (var newEntry in newEntriesList) {
if (_entries.IndexOf(newEntry) == _entries.LastIndexOf(newEntry)) {
lastoverlayEntry++;
}
}
D.assert(lastoverlayEntry == newEntriesList.Count,
()=>"One or more of the specified entries are specified multiple times."
);
newEntriesList.All(entry => _entries.IndexOf(entry) == _entries.LastIndexOf(entry)),
() => "One or more of the specified entries are specified multiple times."
);
if (newEntriesList.isEmpty()) {
return;
}

foreach (OverlayEntry entry in newEntriesList) {
old.Remove(entry);
}
_entries.InsertRange(_insertionIndex(below, above), old);
});
}

public override Widget build(BuildContext context) {
var children = new List<Widget>();
int onstageCount = 0;
int onstageCount = 0;
for (var i = _entries.Count - 1; i >= 0; i -= 1) {
var entry = _entries[i];
if (onstage) {

return new _Theatre(
skipCount: children.Count - onstageCount,
children: children.ToList()
// onstage: new Stack(
// fit: StackFit.expand,
// children: onstageChildren
// ),
// offstage: offstageChildren
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<List<OverlayEntry>>("entries", _entries));
}
internal _Theatre(Key key = null,
internal _Theatre(
Key key = null,
List<Widget> children = null) : base(key, children) {
D.assert(skipCount != null);
List<Widget> children = null) : base(key: key, children: children) {
D.assert(skipCount >= 0);
D.assert(children != null);
D.assert(children.Count() >= skipCount);

public readonly int skipCount;
public readonly Stack onstage;
public readonly List<Widget> offstage;
public override Element createElement() {
return new _TheatreElement(this);

renderObject.skipCount = skipCount;
renderObject.textDirection = Directionality.of(context);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IntProperty("skipCount", skipCount));
}
}
class _TheatreElement : MultiChildRenderObjectElement {

}
}
// Element _onstage;
// static readonly object _onstageSlot = new object();
//
// List<Element> _offstage;
// readonly HashSet<Element> _forgottenOffstageChildren = new HashSet<Element>();
//
// protected override void insertChildRenderObject(RenderObject child, object slot) {
// D.assert(this.renderObject.debugValidateChild(child));
// if (slot == _onstageSlot) {
// D.assert(child is RenderStack);
// this.renderObject.child = (RenderStack) child;
// }
// else {
// D.assert(slot == null || slot is Element);
// this.renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// }
//
// protected override void moveChildRenderObject(RenderObject child, object slot) {
// if (slot == _onstageSlot) {
// this.renderObject.remove((RenderBox) child);
// D.assert(child is RenderStack);
// this.renderObject.child = (RenderStack) child;
// }
// else {
// D.assert(slot == null || slot is Element);
// if (this.renderObject.child == child) {
// this.renderObject.child = null;
// this.renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// else {
// this.renderObject.move((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// }
// }
//
// protected override void removeChildRenderObject(RenderObject child) {
// if (this.renderObject.child == child) {
// this.renderObject.child = null;
// }
// else {
// this.renderObject.remove((RenderBox) child);
// }
// }
//
// public override void visitChildren(ElementVisitor visitor) {
// if (this._onstage != null) {
// visitor(this._onstage);
// }
//
// foreach (var child in this._offstage) {
// if (!this._forgottenOffstageChildren.Contains(child)) {
// visitor(child);
// }
// }
// }
//
// // public override void debugVisitOnstageChildren(ElementVisitor visitor) {
// // if (this._onstage != null) {
// // visitor(this._onstage);
// // }
// // }
//
//
// protected override void forgetChild(Element child) {
// if (child == this._onstage) {
// this._onstage = null;
// }
// else {
// D.assert(this._offstage.Contains(child));
// D.assert(!this._forgottenOffstageChildren.Contains(child));
// this._forgottenOffstageChildren.Add(child);
// }
// }
//
// public override void mount(Element parent, object newSlot) {
// base.mount(parent, newSlot);
// this._onstage = this.updateChild(this._onstage, this.widget.onstage, _onstageSlot);
// this._offstage = new List<Element>(this.widget.offstage.Count);
// Element previousChild = null;
// for (int i = 0; i < this._offstage.Count; i += 1) {
// var newChild = this.inflateWidget(this.widget.offstage[i], previousChild);
// this._offstage[i] = newChild;
// previousChild = newChild;
// }
// }
//
// public override void update(Widget newWidget) {
// base.update(newWidget);
// D.assert(Equals(this.widget, newWidget));
// this._onstage = this.updateChild(this._onstage, this.widget.onstage, _onstageSlot);
// this._offstage = this.updateChildren(this._offstage, this.widget.offstage,
// forgottenChildren: this._forgottenOffstageChildren);
// this._forgottenOffstageChildren.Clear();
// }
// }
class _RenderTheatre :
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData> {
class _RenderTheatre : ContainerRenderObjectMixinRenderBox<RenderBox, StackParentData> {
D.assert(skipCount != null);
D.assert(textDirection != null);
_textDirection = textDirection;
_skipCount = skipCount;
addAll(children);

public override void setupParentData(RenderObject child) {
if (!(child.parentData is StackParentData)) {
child.parentData = new StackParentData();
}
}
if (_resolvedAlignment != null)
if (_resolvedAlignment != null) {
// TODO: AlignmentDirectional
Alignment al = Alignment.topLeft;
}
//FIXME: wait for changes on painting/alignment.cs (by Siyao)
//then uncomment the line below and remove the switch clauses
//_resolvedAlignment = AlignmentDirectional.topStart.resolve(textDirection);
switch (textDirection) {
case TextDirection.rtl:
_resolvedAlignment = new Alignment(-1, -1);

public int skipCount {
get { return _skipCount; }
set {
D.assert(value != null);
if (_skipCount != value) {
_skipCount = value;
markNeedsLayout();

RenderBox _firstOnstageChild {
get {
if (skipCount == childCount) {
if (skipCount == base.childCount) {
return null;
}

}
}
public override void setupParentData(RenderObject child) {
if (!(child.parentData is StackParentData)) {
child.parentData = new StackParentData();
}
}
public override void redepthChildren() {
if (child != null) {
redepthChild(child);
}
base.redepthChildren();
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (child != null) {
visitor(child);
}
base.visitChildren(visitor);
}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.child != null) {
children.Add(child.toDiagnosticsNode(name: "onstage"));
}
if (firstChild != null) {
var child = firstChild;
int count = 1;
while (true) {
children.Add(
child.toDiagnosticsNode(
name: $"offstage {count}",
style: DiagnosticsTreeStyle.offstage
)
);
if (child == lastChild) {
break;
}
var childParentData = (StackParentData) child.parentData;
child = childParentData.nextSibling;
count += 1;
}
}
else {
children.Add(
DiagnosticsNode.message(
"no offstage children",
style: DiagnosticsTreeStyle.offstage
)
);
}
return children;
}
RenderBox _lastOnstageChild {
get { return skipCount == childCount ? null : lastChild; }
}

}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
return RenderStack.getIntrinsicDimension(_firstOnstageChild,
(RenderBox child) => child.getMinIntrinsicHeight(width));
}

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

_resolve();
D.assert(_resolvedAlignment != null);
// Same BoxConstraints as used by RenderStack for StackFit.expand.
BoxConstraints nonPositionedConstraints = BoxConstraints.tight(constraints.biggest);
RenderBox child = _firstOnstageChild;

for (int i = 0; i < _onstageChildCount; i++) {
D.assert(child != null);
StackParentData childParentData = child.parentData as StackParentData;
if (childParentData.offset.dx != 0 || childParentData.offset.dy != 0) {
i = i;
}
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,

}
}
void visitChildrenForSemantics(RenderObjectVisitor visitor) {
RenderBox child = _firstOnstageChild;
while (child != null) {
visitor(child);
StackParentData childParentData = child.parentData as StackParentData;
child = childParentData.nextSibling;
}
}
public override Rect describeApproximatePaintClip(RenderObject child) =>
_hasVisualOverflow ? Offset.zero & size : null;

properties.add(new EnumProperty<TextDirection>("textDirection", textDirection));
}
public override List<DiagnosticsNode> debugDescribeChildren() {
List<DiagnosticsNode> offstageChildren = new List<DiagnosticsNode>();
List<DiagnosticsNode> onstageChildren = new List<DiagnosticsNode>();
int count = 1;
bool onstage = false;
RenderBox child = firstChild;
RenderBox firstOnstageChild = _firstOnstageChild;
while (child != null) {
if (child == firstOnstageChild) {
onstage = true;
count = 1;
}
if (onstage) {
onstageChildren.Add(
child.toDiagnosticsNode(
name: $"onstage {count}"
)
);
} else {
offstageChildren.Add(
child.toDiagnosticsNode(
name: $"offstage {count}",
style: DiagnosticsTreeStyle.offstage
)
);
}
StackParentData childParentData = child.parentData as StackParentData;
child = childParentData.nextSibling;
count += 1;
}
List<DiagnosticsNode> result = new List<DiagnosticsNode>();
result.AddRange(onstageChildren);
if (offstageChildren.isNotEmpty()) {
result.AddRange(offstageChildren);
}
else {
result.Add(DiagnosticsNode.message("no offstage children", style: DiagnosticsTreeStyle.offstage));
}
return result;
}
}
}

6
com.unity.uiwidgets/Runtime/widgets/overscroll_indicator.cs


}
properties.add(new MessageProperty("show", showDescription));
properties.add(new DiagnosticsProperty<Color>("color", color, showName: false));
properties.add(new ColorProperty("color", color, showName: false));
}
}

}
if (notification is OverscrollNotification) {
_GlowController controller;
_GlowController controller = null;
OverscrollNotification _notification = notification as OverscrollNotification;
if (_notification.overscroll < 0.0f) {
controller = _leadingController;

}
else {
throw new Exception("overscroll is 0.0f!");
D.assert(false, () =>"over scroll cannot be 0.0f.");
}
bool isLeading = controller == _leadingController;

2
com.unity.uiwidgets/Runtime/widgets/page_storage.cs


public readonly PageStorageBucket bucket;
public static PageStorageBucket of(BuildContext context) {
PageStorage widget = (PageStorage) context.ancestorWidgetOfExactType(typeof(PageStorage));
PageStorage widget = context.findAncestorWidgetOfExactType<PageStorage>();
return widget == null ? null : widget.bucket;
}

65
com.unity.uiwidgets/Runtime/widgets/page_view.cs


float _viewportFraction;
float _initialPageOffset {
get {
return Mathf.Max(0, viewportDimension * (viewportFraction - 1) / 2);
}
}
return page * viewportDimension * viewportFraction;
return page * viewportDimension * viewportFraction + _initialPageOffset;
D.assert(
pixels == null || (minScrollExtent != null && maxScrollExtent != null),
() => "Page value is only available after content dimensions are established."
);
return getPageFromPixels(pixels.clamp(minScrollExtent, maxScrollExtent),
viewportDimension);
}

return result;
}
public override bool applyContentDimensions(float minScrollExtent, float maxScrollExtent) {
float newMinScrollExtent = minScrollExtent + _initialPageOffset;
return base.applyContentDimensions(
newMinScrollExtent,
Mathf.Max(newMinScrollExtent, maxScrollExtent - _initialPageOffset)
);
}
}
public class _ForceImplicitScrollPhysics : ScrollPhysics {
public _ForceImplicitScrollPhysics(
bool allowImplicitScrolling = false,
ScrollPhysics parent = null
) : base(parent: parent) {
D.assert(allowImplicitScrolling != null);
}
public override ScrollPhysics applyTo(ScrollPhysics ancestor) {
return new _ForceImplicitScrollPhysics(
allowImplicitScrolling: allowImplicitScrolling,
parent: buildParent(ancestor)
);
}
public readonly bool allowImplicitScrolling;
}
public class PageScrollPhysics : ScrollPhysics {

return new PageScrollPhysics(parent: buildParent(ancestor));
}
float _getPage(ScrollPosition position) {
float _getPage(ScrollMetrics position) {
if (position is _PagePosition) {
return ((_PagePosition) position).page;
}

float _getPixels(ScrollPosition position, float page) {
float _getPixels(ScrollMetrics position, float page) {
if (position is _PagePosition) {
return ((_PagePosition) position).getPixelsFromPage(page);
}

float _getTargetPixels(ScrollPosition position, Tolerance tolerance, float velocity) {
float _getTargetPixels(ScrollMetrics position, Tolerance tolerance, float velocity) {
float page = _getPage(position);
if (velocity < -tolerance.velocity) {
page -= 0.5f;

DragStartBehavior dragStartBehavior = DragStartBehavior.start,
IndexedWidgetBuilder itemBuilder = null,
SliverChildDelegate childDelegate = null,
int itemCount = 0
int itemCount = 0,
bool allowImplicitScrolling = false
) : base(key: key) {
this.scrollDirection = scrollDirection;
this.reverse = reverse;

this.dragStartBehavior = dragStartBehavior;
this.controller = controller ?? PageViewUtils._defaultPageController;
this.allowImplicitScrolling = allowImplicitScrolling;
if (itemBuilder != null) {
childrenDelegate = new SliverChildBuilderDelegate(itemBuilder, childCount: itemCount);
}

bool pageSnapping = true,
ValueChanged<int> onPageChanged = null,
int itemCount = 0,
bool allowImplicitScrolling = false,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
) {
return new PageView(

pageSnapping: pageSnapping,
onPageChanged: onPageChanged,
itemCount: itemCount,
allowImplicitScrolling: allowImplicitScrolling,
dragStartBehavior: dragStartBehavior
);
}

public readonly SliverChildDelegate childrenDelegate;
public readonly DragStartBehavior dragStartBehavior;
public readonly bool allowImplicitScrolling;
public override State createState() {
return new _PageViewState();

public override Widget build(BuildContext context) {
AxisDirection axisDirection = _getDirection(context);
ScrollPhysics physics = widget.pageSnapping
ScrollPhysics physics = new _ForceImplicitScrollPhysics(
allowImplicitScrolling: widget.allowImplicitScrolling
).applyTo(widget.pageSnapping
: widget.physics;
: widget.physics);
return new NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) => {

physics: physics,
viewportBuilder: (BuildContext _context, ViewportOffset position) => {
return new Viewport(
cacheExtent: 0.0f,
cacheExtent: widget.allowImplicitScrolling ? 1.0f : 0.0f,
cacheExtentStyle: CacheExtentStyle.viewport,
del: widget.childrenDelegate
_delegate: widget.childrenDelegate
)
}
);

description.add(new DiagnosticsProperty<ScrollPhysics>("physics", widget.physics, showName: false));
description.add(new FlagProperty("pageSnapping", value: widget.pageSnapping,
ifFalse: "snapping disabled"));
description.add(new FlagProperty("allowImplicitScrolling", value: widget.allowImplicitScrolling, ifTrue: "allow implicit scrolling"));
}
}
}

36
com.unity.uiwidgets/Runtime/widgets/pages.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public class PagesUtils {
public static Widget _defaultTransitionsBuilder(BuildContext context, Animation<float>
animation, Animation<float> secondaryAnimation, Widget child) {
return child;
}
}
public PageRoute(RouteSettings settings, bool fullscreenDialog = false) : base(settings) {
public PageRoute(
RouteSettings settings = null,
bool fullscreenDialog = false) : base(settings) {
this.fullscreenDialog = fullscreenDialog;
}

return previousRoute is PageRoute;
}
public override AnimationController createAnimationController() {
var controller = base.createAnimationController();
if (settings.isInitialRoute) {
controller.setValue(1.0f);
}
return controller;
}
}
public class PageRouteBuilder : PageRoute {

bool opaque = true,
bool barrierDismissible = false,
Color barrierColor = null,
bool maintainState = true
) : base(settings) {
string barrierLabel = null,
bool maintainState = true,
bool fullscreenDialog = false
) : base(settings,fullscreenDialog) {
D.assert(transitionsBuilder != null);
this.transitionsBuilder = transitionsBuilder ?? _defaultTransitionsBuilder;
this.transitionsBuilder = transitionsBuilder ?? PagesUtils._defaultTransitionsBuilder;
this.barrierLabel = barrierLabel;
this.maintainState = maintainState;
this.barrierDismissible = barrierDismissible;
}

public override bool opaque { get; }
public override string barrierLabel { get; }
Widget _defaultTransitionsBuilder(BuildContext context, Animation<float>
animation, Animation<float> secondaryAnimation, Widget child) {
return child;
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) {

5
com.unity.uiwidgets/Runtime/widgets/primary_scroll_controller.cs


public readonly ScrollController controller;
public static ScrollController of(BuildContext context) {
PrimaryScrollController result =
(PrimaryScrollController) context.inheritFromWidgetOfExactType(typeof(PrimaryScrollController));
return result == null ? null : result.controller;
PrimaryScrollController result = context.dependOnInheritedWidgetOfExactType<PrimaryScrollController>();
return result?.controller;
}
public override bool updateShouldNotify(InheritedWidget oldWidget) {

4
com.unity.uiwidgets/Runtime/widgets/route_notification_messages.cs


} else {
// No op.
}
}*/
}
/*public static void _notifyRouteChange(string routeName, string previousRouteName) {
public static void _notifyRouteChange(string routeName, string previousRouteName) {
SystemChannels.navigation.invokeMethod<void>(
'routeUpdated',
<string, dynamic>{

177
com.unity.uiwidgets/Runtime/widgets/routes.cs


namespace Unity.UIWidgets.widgets {
public abstract class OverlayRoute : Route {
readonly List<OverlayEntry> _overlayEntries = new List<OverlayEntry>();
public readonly List<OverlayEntry> _overlayEntries = new List<OverlayEntry>();
public OverlayRoute(
RouteSettings settings = null

get { return true; }
}
public abstract ICollection<OverlayEntry> createOverlayEntries();
public abstract IEnumerable<OverlayEntry> createOverlayEntries();
protected internal override void install(){//(OverlayEntry insertionPoint) {
protected internal override void install(){
navigator.overlay?.insertAll(_overlayEntries);
base.install();
}
protected internal override bool didPop(object result) {

navigator.finalizeRoute(this);
}
/*foreach (var entry in _overlayEntries) {
entry.remove();
}*/
public abstract class OverlayRoute<T> : OverlayRoute {
public readonly List<OverlayEntry> _overlayEntries = new List<OverlayEntry>();
public OverlayRoute(
RouteSettings settings = null
) : base(settings : settings) {
}
protected internal new bool didPop(T result) {
var returnValue = base.didPop(result);
D.assert(returnValue);
if (finishedWhenPopped) {
navigator.finalizeRoute(this);
}
return returnValue;
}
}
) : base(settings) {
) : base(settings) {
}
public Future completed {

D.assert(duration >= TimeSpan.Zero && duration != null);
return new AnimationController(
duration: duration,
//reverseDuration: reverseDuration, /// todo
reverseDuration: reverseDuration,
debugLabel: debugLabel,
vsync: navigator
);

D.assert(_controller != null,
() => $"{GetType()}.didPush called before calling install() or after calling dispose().");
D.assert(!_transitionCompleter.isCompleted, () => $"Cannot reuse a {GetType()} after disposing it.");
//_animation.addStatusListener(_handleStatusChanged);
//return _controller.forward();
_didPushOrReplace();
base.didPush();
return _controller.forward();

if (oldRoute is TransitionRoute) {
_controller.setValue(((TransitionRoute)oldRoute)._controller.value);
}
_animation.addStatusListener(_handleStatusChanged);
_didPushOrReplace();
base.didReplace(oldRoute);
}
public void _didPushOrReplace() {

void _updateSecondaryAnimation(Route nextRoute) {
VoidCallback previousTrainHoppingListenerRemover = _trainHoppingListenerRemover;
_trainHoppingListenerRemover = null;
if (nextRoute is TransitionRoute && canTransitionTo((TransitionRoute) nextRoute) &&
((TransitionRoute) nextRoute).canTransitionFrom(this)) {
if (nextRoute is TransitionRoute && canTransitionTo((TransitionRoute)nextRoute) &&
((TransitionRoute) nextRoute).canTransitionFrom((TransitionRoute)this)) {
currentTrain.value == nextTrain.value ||
nextTrain.status == AnimationStatus.completed ||
nextTrain.status == AnimationStatus.dismissed
) {
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
currentTrain.value == nextTrain.value ||
nextTrain.status == AnimationStatus.completed ||
nextTrain.status == AnimationStatus.dismissed
) {
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
TrainHoppingAnimation newAnimation = null;
void _jumpOnAnimationEnd(AnimationStatus status) {
switch (status) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
TrainHoppingAnimation newAnimation = null;
void _jumpOnAnimationEnd(AnimationStatus status) {
switch (status) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
}
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
}
_trainHoppingListenerRemover = ()=> {
nextTrain.removeStatusListener(_jumpOnAnimationEnd);
newAnimation?.dispose();
};
nextTrain.addStatusListener(_jumpOnAnimationEnd);
newAnimation = new TrainHoppingAnimation(
currentTrain,
nextTrain,
onSwitchedTrain: ()=> {
D.assert(_secondaryAnimation.parent == newAnimation);
D.assert(newAnimation.currentTrain == ((TransitionRoute)nextRoute)._animation);
_setSecondaryAnimation(newAnimation.currentTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
}
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
}
_trainHoppingListenerRemover = ()=> {
nextTrain.removeStatusListener(_jumpOnAnimationEnd);
newAnimation?.dispose();
};
nextTrain.addStatusListener(_jumpOnAnimationEnd);
newAnimation = new TrainHoppingAnimation(
currentTrain,
nextTrain,
onSwitchedTrain: ()=> {
D.assert(_secondaryAnimation.parent == newAnimation);
D.assert(newAnimation.currentTrain == ((TransitionRoute)nextRoute)._animation);
_setSecondaryAnimation(newAnimation.currentTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
}
}
);
_setSecondaryAnimation(newAnimation, ((TransitionRoute)nextRoute).completed);
}

}
}
public class LocalHistoryEntry {
public LocalHistoryEntry(VoidCallback onRemove = null) {
this.onRemove = onRemove;

if (_localHistory.isEmpty()) {
//changedInternalState();
if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks) {
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timestamp) =>{
changedInternalState();
});

if (willHandlePopInternally) {
return Future.value(RoutePopDisposition.pop).to<RoutePopDisposition>();
}
return base.willPop();
}

Listenable _listenable;
public readonly FocusScopeNode focusScopeNode = new FocusScopeNode();//debugLabel: "$_ModalScopeState Focus Scope");
public readonly FocusScopeNode focusScopeNode = new FocusScopeNode(debugLabel: $"{typeof(_ModalScopeState)} Focus Scope");
var animations = new List<Listenable> { };
var animations = new List<Listenable>();
if (widget.route.animation != null) {
animations.Add(widget.route.animation);
}

child: new PageStorage(
bucket: widget.route._storageBucket,
child: new FocusScope(
node: widget.route.focusScopeNode,
node: focusScopeNode,
child: new RepaintBoundary(
child: new AnimatedBuilder(
animation: _listenable, // immutable

animation: widget.route.navigator?.userGestureInProgressNotifier ?? new ValueNotifier<bool>(false),
builder: (BuildContext context1, Widget child1) =>{
bool ignoreEvents = _shouldIgnoreFocusRequest;
//focusScopeNode.canRequestFocus = !ignoreEvents; // todo
focusScopeNode.canRequestFocus = !ignoreEvents; // todo
return new IgnorePointer(
ignoring: ignoreEvents,
child: child1

)
/*new IgnorePointer(
ignoring: widget.route.animation?.status ==
AnimationStatus.reverse,
child: child
)*/
child: _page
child: _page = _page ?? new RepaintBoundary(
key: widget.route._subtreeKey, // immutable
child: new Builder(
builder: (BuildContext context2) =>{
return widget.route.buildPage(
context2,
widget.route.animation,
widget.route.secondaryAnimation
);
}
)
)
)
)
)

public static Color _kTransparent = new Color(0x00000000);
public static ModalRoute of(BuildContext context) {
//_ModalScopeStatus widget = (_ModalScopeStatus) context.inheritFromWidgetOfExactType(typeof(_ModalScopeStatus));
//return (ModalRoute<T>) widget?.route;
_ModalScopeStatus widget = context.dependOnInheritedWidgetOfExactType<_ModalScopeStatus>();
return widget?.route as ModalRoute;
}

}
base.didAdd();
}
/*public override void dispose() {
focusScopeNode.detach();
base.dispose();
}*/
public virtual bool barrierDismissible { get; }

protected internal override void changedExternalState() {
base.changedExternalState();
//_scopeKey.currentState?._forceRebuildPage();
if (_scopeKey.currentState != null)
_scopeKey.currentState._forceRebuildPage();
}

public readonly GlobalKey<_ModalScopeState> _scopeKey = new LabeledGlobalKey<_ModalScopeState>();
internal readonly GlobalKey _subtreeKey = GlobalKey.key();
internal readonly PageStorageBucket _storageBucket = new PageStorageBucket();
//static readonly Animatable<float> _easeCurveTween = new CurveTween(curve: Curves.ease);
OverlayEntry _modalBarrier;
Widget _buildModalBarrier(BuildContext context) {

public Widget _modalScopeCache;
public virtual Widget _buildModalScope(BuildContext context) {
return _modalScopeCache = _modalScopeCache ?? new _ModalScope(
key: _scopeKey,
route: this
// _ModalScope calls buildTransitions() and buildChild(), defined above
);
return _modalScopeCache = _modalScopeCache ?? new _ModalScope(key: _scopeKey, route: this);
public override ICollection<OverlayEntry> createOverlayEntries() {
public override IEnumerable<OverlayEntry> createOverlayEntries() {
_modalBarrier = new OverlayEntry(builder: _buildModalBarrier);
var content = new OverlayEntry(
builder: _buildModalScope, maintainState: maintainState

}
public override Widget _buildModalScope(BuildContext context) {
return _modalScopeCache = _modalScopeCache ?? new _ModalScope<T>(
key: _scopeKey,
route: this
// _ModalScope calls buildTransitions() and buildChild(), defined above
);
return _modalScopeCache = _modalScopeCache ?? new _ModalScope<T>(key: _scopeKey, route: this);
}

}
}
var subscribers =_listeners.getOrDefault((R) route);
/* foreach (var key in _listeners.Keys) {
subscribers.Add(_listeners[key].ToList());
}*/
var subscribers =_listeners.getOrDefault((R) route).ToList();
if (subscribers != null) {
foreach (RouteAware routeAware in subscribers) {
routeAware.didPop();

10
com.unity.uiwidgets/Runtime/widgets/safe_area.cs


bool right = true,
bool bottom = true,
EdgeInsets mininum = null,
Widget child = null
Widget child = null,
bool maintainBottomViewPadding = false
) : base(key: key) {
D.assert(child != null);
this.left = left;

minimum = mininum ?? EdgeInsets.zero;
this.child = child;
this.maintainBottomViewPadding = maintainBottomViewPadding;
}
public readonly bool left;

public readonly EdgeInsets minimum;
public readonly Widget child;
public readonly bool maintainBottomViewPadding;
EdgeInsets padding = MediaQuery.of(context).padding;
MediaQueryData data = MediaQuery.of(context);
EdgeInsets padding = data.padding;
if (data.padding.bottom == 0.0 && data.viewInsets.bottom != 0.0 && maintainBottomViewPadding)
padding = padding.copyWith(bottom: data.viewPadding.bottom);
return new Padding(
padding: EdgeInsets.only(
left: Mathf.Max(left ? padding.left : 0.0f, minimum.left),

7
com.unity.uiwidgets/Runtime/widgets/scroll_configuration.cs


}
public virtual ScrollPhysics getScrollPhysics(BuildContext context) {
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS
#else
return new ClampingScrollPhysics();
#endif
}
public virtual bool shouldNotify(ScrollBehavior oldDelegate) {

public readonly ScrollBehavior behavior;
public static ScrollBehavior of(BuildContext context) {
ScrollConfiguration configuration =
(ScrollConfiguration) context.inheritFromWidgetOfExactType(typeof(ScrollConfiguration));
ScrollConfiguration configuration = context.dependOnInheritedWidgetOfExactType<ScrollConfiguration>();
if (configuration != null) {
return configuration.behavior;
}

9
com.unity.uiwidgets/Runtime/widgets/scroll_metrics.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.widgets {

}
public static float extentInside(this ScrollMetrics it) {
return Mathf.Min(it.pixels, it.maxScrollExtent) -
Mathf.Max(it.pixels, it.minScrollExtent) +
Mathf.Min(it.viewportDimension, it.maxScrollExtent - it.minScrollExtent);
D.assert(it.minScrollExtent <= it.maxScrollExtent);
return it.viewportDimension
- (it.minScrollExtent - it.pixels).clamp(0, it.viewportDimension)
- (it.pixels - it.maxScrollExtent).clamp(0, it.viewportDimension);
}
public static float extentAfter(this ScrollMetrics it) {

6
com.unity.uiwidgets/Runtime/widgets/scroll_notification.mixin.njk


{% macro ViewportNotificationMixin(with) %}
public abstract class ViewportNotificationMixin{{with}} : {{with}} {
public int depth {
get { return this._depth; }
get { return _depth; }
}
int _depth = 0;

this._depth += 1;
_depth += 1;
}
return base.visitAncestor(element);

base.debugFillDescription(description);
description.Add(string.Format("depth: {0} ({1})",
this._depth, this._depth == 0 ? "local" : "remote"));
_depth, _depth == 0 ? "local" : "remote"));
}
}
{% endmacro %}

29
com.unity.uiwidgets/Runtime/widgets/scroll_physics.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.physics;

}
return parent.shouldAcceptUserOffset(position);
}
public bool recommendDeferredLoading(float velocity, ScrollMetrics metrics, BuildContext context) {
D.assert(metrics != null);
D.assert(context != null);
if (parent == null) {
float maxPhysicalPixels = WidgetsBinding.instance.window.physicalSize.longestSide;
return velocity.abs() > maxPhysicalPixels;
}
return parent.recommendDeferredLoading(velocity, metrics, context);
}
public virtual float applyBoundaryConditions(ScrollMetrics position, float value) {

public override float applyBoundaryConditions(ScrollMetrics position, float value) {
D.assert(() => {
if (value == position.pixels) {
throw new UIWidgetsError(
$"{GetType()}.applyBoundaryConditions() was called redundantly.\n" +
$"The proposed new position, {value}, is exactly equal to the current position of the " +
$"given {position.GetType()}, {position.pixels}.\n" +
"The applyBoundaryConditions method should only be called when the value is " +
"going to actually change the pixels, otherwise it is redundant.\n" +
"The physics object in question was:\n" + $" {this}\n" +
"The position object in question was:\n" + $" {position}\n");
throw new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary($"{GetType()}.applyBoundaryConditions() was called redundantly."),
new ErrorDescription($"The proposed new position, {value}, is exactly equal to the current position of the " +
$"given {position.GetType()}, {position.pixels}.\n" +
"The applyBoundaryConditions method should only be called when the value is " +
"going to actually change the pixels, otherwise it is redundant."),
new DiagnosticsProperty<ScrollPhysics>("The physics object in question was", this, style: DiagnosticsTreeStyle.errorProperty),
new DiagnosticsProperty<ScrollMetrics>("The position object in question was", position, style: DiagnosticsTreeStyle.errorProperty)
});
}
return true;

40
com.unity.uiwidgets/Runtime/widgets/scroll_position.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public enum ScrollPositionAlignmentPolicy {
explicitPolicy,
keepVisibleAtEnd,
keepVisibleAtStart,
}
public abstract class ScrollPosition : ViewportOffset, ScrollMetrics {
protected ScrollPosition(
ScrollPhysics physics = null,

if (!PhysicsUtils.nearEqual(_minScrollExtent, minScrollExtent, Tolerance.defaultTolerance.distance) ||
!PhysicsUtils.nearEqual(_maxScrollExtent, maxScrollExtent, Tolerance.defaultTolerance.distance) ||
_didChangeViewportDimensionOrReceiveCorrection) {
D.assert(minScrollExtent <= maxScrollExtent);
_minScrollExtent = minScrollExtent;
_maxScrollExtent = maxScrollExtent;
_haveDimensions = true;

activity.applyNewDimensions();
}
public Future ensureVisible(RenderObject renderObject,
public Future ensureVisible(
RenderObject renderObject,
Curve curve = null
Curve curve = null,
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicitPolicy
float target = viewport.getOffsetToReveal(renderObject, alignment).offset.clamp(
minScrollExtent, maxScrollExtent);
float target = 0f;
switch (alignmentPolicy) {
case ScrollPositionAlignmentPolicy.explicitPolicy:
target = viewport.getOffsetToReveal(renderObject, alignment).offset.clamp(minScrollExtent, maxScrollExtent);
break;
case ScrollPositionAlignmentPolicy.keepVisibleAtEnd:
target = viewport.getOffsetToReveal(renderObject, 1.0f).offset.clamp(minScrollExtent, maxScrollExtent) ;
if (target < pixels) {
target = pixels;
}
break;
case ScrollPositionAlignmentPolicy.keepVisibleAtStart:
target = viewport.getOffsetToReveal(renderObject, 0.0f).offset.clamp(minScrollExtent, maxScrollExtent) ;
if (target > pixels) {
target = pixels;
}
break;
}
if (target == pixels) {
return Future.value();
}

new UserScrollNotification(metrics:
ScrollMetricsUtils.copyWith(this), context: context.notificationContext, direction: direction
).dispatch(context.notificationContext);
}
public bool recommendDeferredLoading(BuildContext context) {
D.assert(context != null);
D.assert(activity != null);
return physics.recommendDeferredLoading(activity.velocity, ScrollMetricsUtils.copyWith(this), context);
}
public override void dispose() {

91
com.unity.uiwidgets/Runtime/widgets/scroll_view.cs


using UnityEngine;
namespace Unity.UIWidgets.widgets {
public enum ScrollViewKeyboardDismissBehavior {
manual,
onDrag
}
public abstract class ScrollView : StatelessWidget {
protected ScrollView(
Key key = null,

Key center = null,
float anchor = 0.0f,
float? cacheExtent = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) : base(key: key) {
D.assert(!(controller != null && primary == true),
() => "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +

this.anchor = anchor;
this.cacheExtent = cacheExtent;
this.dragStartBehavior = dragStartBehavior;
this.keyboardDismissBehavior = keyboardDismissBehavior;
}
public readonly Axis scrollDirection;

public readonly float anchor;
public readonly float? cacheExtent;
public readonly DragStartBehavior dragStartBehavior;
public readonly ScrollViewKeyboardDismissBehavior keyboardDismissBehavior;
protected AxisDirection getDirection(BuildContext context) {
return LayoutUtils.getAxisDirectionFromAxisReverseAndDirectionality(

viewportBuilder: (viewportContext, offset) =>
buildViewport(viewportContext, offset, axisDirection, slivers)
);
return primary && scrollController != null
Widget scrollableResult = primary && scrollController != null
if (keyboardDismissBehavior == ScrollViewKeyboardDismissBehavior.onDrag) {
return new NotificationListener<ScrollUpdateNotification>(
child: scrollableResult,
onNotification: (ScrollUpdateNotification notification) => {
FocusScopeNode focusScope = FocusScope.of(context);
if (notification.dragDetails != null && focusScope.hasFocus) {
focusScope.unfocus();
}
return false;
}
);
}
else {
return scrollableResult;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

bool shrinkWrap = false,
EdgeInsets padding = null,
float? cacheExtent = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) : base(
key: key,
scrollDirection: scrollDirection,

physics: physics,
shrinkWrap: shrinkWrap,
cacheExtent: cacheExtent,
dragStartBehavior: dragStartBehavior
dragStartBehavior: dragStartBehavior,
keyboardDismissBehavior: keyboardDismissBehavior
) {
this.padding = padding;
}

bool addRepaintBoundaries = true,
float? cacheExtent = null,
List<Widget> children = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) : base(
key: key,
scrollDirection: scrollDirection,

shrinkWrap: shrinkWrap,
padding: padding,
cacheExtent: cacheExtent,
dragStartBehavior: dragStartBehavior
dragStartBehavior: dragStartBehavior,
keyboardDismissBehavior: keyboardDismissBehavior
) {
this.itemExtent = itemExtent;
childrenDelegate = new SliverChildListDelegate(

bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
float? cacheExtent = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) : base(key: key,
scrollDirection: scrollDirection,
reverse: reverse,

shrinkWrap: shrinkWrap,
padding: padding,
cacheExtent: cacheExtent,
dragStartBehavior: dragStartBehavior
dragStartBehavior: dragStartBehavior,
keyboardDismissBehavior: keyboardDismissBehavior
D.assert(itemCount == null || itemCount >= 0);
this.itemExtent = itemExtent;
childrenDelegate = new SliverChildBuilderDelegate(
itemBuilder,

bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
float? cacheExtent = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) {
return new ListView(
key: key,

itemCount: itemCount,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
dragStartBehavior: dragStartBehavior
dragStartBehavior: dragStartBehavior,
keyboardDismissBehavior: keyboardDismissBehavior
);
}

bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
float? cacheExtent = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) : base(
key: key,
scrollDirection: scrollDirection,

shrinkWrap: shrinkWrap,
padding: padding,
cacheExtent: cacheExtent,
dragStartBehavior: dragStartBehavior
dragStartBehavior: dragStartBehavior,
keyboardDismissBehavior: keyboardDismissBehavior
) {
D.assert(itemBuilder != null);
D.assert(separatorBuilder != null);

(context, index) => {
int itemIndex = index / 2;
return index % 2 == 0
? itemBuilder(context, itemIndex)
: separatorBuilder(context, itemIndex);
Widget widget = null;
if (index % 2 == 0) {
widget = itemBuilder(context, itemIndex);
}
else {
widget = separatorBuilder(context, itemIndex);
D.assert(() => {
if (widget == null) {
throw new UIWidgetsError("separatorBuilder cannot return null.");
}
return true;
});
}
return widget;
childCount: Mathf.Max(0, itemCount * 2 - 1),
childCount: _computeActualChildCount(itemCount),
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries
);

int itemCount = 0,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
float? cacheExtent = null
float? cacheExtent = null,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
) {
return new ListView(
key,

itemCount,
addAutomaticKeepAlives,
addRepaintBoundaries,
cacheExtent
cacheExtent,
keyboardDismissBehavior: keyboardDismissBehavior
);
}

base.debugFillProperties(properties);
properties.add(new FloatProperty("itemExtent", itemExtent,
defaultValue: foundation_.kNullDefaultValue));
}
static int _computeActualChildCount(int itemCount) {
return Mathf.Max(0, itemCount * 2 - 1);
}
}

182
com.unity.uiwidgets/Runtime/widgets/scrollable.cs


ScrollController controller = null,
ScrollPhysics physics = null,
ViewportBuilder viewportBuilder = null,
ScrollIncrementCalculator incrementCalculator = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(key: key) {
D.assert(viewportBuilder != null);

this.physics = physics;
this.viewportBuilder = viewportBuilder;
this.incrementCalculator = incrementCalculator;
this.dragStartBehavior = dragStartBehavior;
}

public readonly ViewportBuilder viewportBuilder;
public readonly ScrollIncrementCalculator incrementCalculator;
public readonly DragStartBehavior dragStartBehavior;
public Axis axis {

}
public static ScrollableState of(BuildContext context) {
_ScrollableScope widget = (_ScrollableScope) context.inheritFromWidgetOfExactType(typeof(_ScrollableScope));
_ScrollableScope widget = context.dependOnInheritedWidgetOfExactType<_ScrollableScope>();
public static Future ensureVisible(BuildContext context,
static bool recommendDeferredLoadingForContext(BuildContext context) {
_ScrollableScope widget = context.getElementForInheritedWidgetOfExactType<_ScrollableScope>()?.widget as _ScrollableScope;
if (widget == null) {
return false;
}
return widget.position.recommendDeferredLoading(context);
}
public static Future ensureVisible(
BuildContext context,
Curve curve = null
Curve curve = null,
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicitPolicy
) {
duration = duration ?? TimeSpan.Zero;
curve = curve ?? Curves.ease;

context.findRenderObject(),
alignment: alignment,
duration: duration,
curve: curve
curve: curve,
alignmentPolicy: alignmentPolicy
));
context = scrollable.context;
scrollable = of(context);

float _targetScrollOffsetForPointerScroll(PointerScrollEvent e) {
float delta = widget.axis == Axis.horizontal ? e.delta.dx : e.delta.dy;
if (AxisUtils.axisDirectionIsReversed(widget.axisDirection)) {
delta += -1;
}
return Mathf.Min(Mathf.Max(position.pixels + delta, position.minScrollExtent),
position.maxScrollExtent);
}

void _handlePointerScroll(PointerEvent e) {
D.assert(e is PointerScrollEvent);
if (_physics != null && !_physics.shouldAcceptUserOffset(position)) {
return;
}
float targetScrollOffset = _targetScrollOffsetForPointerScroll(e as PointerScrollEvent);
if (targetScrollOffset != position.pixels) {
position.jumpTo(targetScrollOffset);

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ScrollPosition>("position", position));
}
}
public delegate float ScrollIncrementCalculator(ScrollIncrementDetails details);
public enum ScrollIncrementType {
line,
page
}
public class ScrollIncrementDetails {
public ScrollIncrementDetails(
ScrollIncrementType type,
ScrollMetrics metrics
) {
D.assert(metrics != null);
this.type = type;
this.metrics = metrics;
}
public readonly ScrollIncrementType type;
public readonly ScrollMetrics metrics;
}
public class ScrollIntent : Intent {
public ScrollIntent(
AxisDirection direction,
ScrollIncrementType type = ScrollIncrementType.line
) : base (ScrollAction.key) {
this.direction = direction;
this.type = type;
}
public readonly AxisDirection direction;
public readonly ScrollIncrementType type;
protected bool isEnabled(BuildContext context) {
return Scrollable.of(context) != null;
}
}
public class ScrollAction : UiWidgetAction {
public ScrollAction() : base(key) {
}
public static readonly LocalKey key = new ValueKey<Type>(typeof(ScrollAction));
float _calculateScrollIncrement(ScrollableState state, ScrollIncrementType type = ScrollIncrementType.line) {
D.assert(state.position != null);
D.assert(state.position.pixels != null);
D.assert(state.widget.physics == null || state.widget.physics.shouldAcceptUserOffset(state.position));
if (state.widget.incrementCalculator != null) {
return state.widget.incrementCalculator(
new ScrollIncrementDetails(
type: type,
metrics: state.position
)
);
}
switch (type) {
case ScrollIncrementType.line:
return 50.0f;
case ScrollIncrementType.page:
return 0.8f * state.position.viewportDimension;
}
return 0.0f;
}
float _getIncrement(ScrollableState state, ScrollIntent intent) {
float increment = _calculateScrollIncrement(state, type: intent.type);
switch (intent.direction) {
case AxisDirection.down:
switch (state.axisDirection) {
case AxisDirection.up:
return -increment;
break;
case AxisDirection.down:
return increment;
break;
case AxisDirection.right:
case AxisDirection.left:
return 0.0f;
}
break;
case AxisDirection.up:
switch (state.axisDirection) {
case AxisDirection.up:
return increment;
break;
case AxisDirection.down:
return -increment;
break;
case AxisDirection.right:
case AxisDirection.left:
return 0.0f;
}
break;
case AxisDirection.left:
switch (state.axisDirection) {
case AxisDirection.right:
return -increment;
break;
case AxisDirection.left:
return increment;
break;
case AxisDirection.up:
case AxisDirection.down:
return 0.0f;
}
break;
case AxisDirection.right:
switch (state.axisDirection) {
case AxisDirection.right:
return increment;
break;
case AxisDirection.left:
return -increment;
break;
case AxisDirection.up:
case AxisDirection.down:
return 0.0f;
}
break;
}
return 0.0f;
}
public override void invoke(FocusNode node, Intent intent) {
ScrollableState state = Scrollable.of(node.context);
D.assert(state != null, () => "ScrollAction was invoked on a context that has no scrollable parent");
D.assert(state.position.pixels != null, () => "Scrollable must be laid out before it can be scrolled via a ScrollAction");
if (state.widget.physics != null && !state.widget.physics.shouldAcceptUserOffset(state.position)) {
return;
}
float increment = _getIncrement(state, intent as ScrollIntent);
if (increment == 0.0f) {
return;
}
state.position.moveTo(
state.position.pixels + increment,
duration: TimeSpan.FromMilliseconds(100),
curve: Curves.easeInOut
);
}
}
}

289
com.unity.uiwidgets/Runtime/widgets/scrollbar.cs


using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.widgets {
static class ScrollbarPainterUtils {
public const float _kMinThumbExtent = 18.0f;
public const float _kMinInteractiveSize = 48.0f;
}
public class ScrollbarPainter : ChangeNotifier, CustomPainter {
public ScrollbarPainter(
Color color,

EdgeInsets padding = null,
float minLength = _kMinThumbExtent,
float minOverscrollLength = _kMinThumbExtent
float minLength = ScrollbarPainterUtils._kMinThumbExtent,
float? minOverscrollLength = null
this.color = color;
this.textDirection = textDirection;
D.assert(color != null);
D.assert(fadeoutOpacityAnimation != null);
D.assert(minLength >= 0);
D.assert(minOverscrollLength == null || minOverscrollLength.Value <= minLength);
D.assert(minOverscrollLength == null || minOverscrollLength.Value >= 0);
padding = padding ?? EdgeInsets.zero;
D.assert(padding.isNonNegative);
_color = color;
_textDirection = textDirection;
_padding = padding;
this.thickness = thickness;
this.fadeoutOpacityAnimation = fadeoutOpacityAnimation;
this.mainAxisMargin = mainAxisMargin;

this.minOverscrollLength = minOverscrollLength;
this.minOverscrollLength = minOverscrollLength ?? minLength;
const float _kMinThumbExtent = 18.0f;
public Color color {
get { return _color; }
set {
D.assert(value != null);
if (color == value) {
return;
}
_color = value;
notifyListeners();
}
}
Color _color;
public Color color;
public TextDirection? textDirection;
public TextDirection textDirection {
get { return _textDirection; }
set {
if (textDirection == value) {
return;
}
_textDirection = value;
notifyListeners();
}
}
TextDirection _textDirection;
public Animation<float> fadeoutOpacityAnimation;
public float mainAxisMargin;
public float crossAxisMargin;
public readonly Animation<float> fadeoutOpacityAnimation;
public readonly float mainAxisMargin;
public readonly float crossAxisMargin;
public float minLength;
public float minOverscrollLength;
public EdgeInsets padding {
get { return _padding; }
set {
D.assert(value != null);
if (padding == value) {
return;
}
_padding = value;
notifyListeners();
}
}
EdgeInsets _padding;
public readonly float minLength;
public readonly float minOverscrollLength;
Rect _thumbRect;
public void update(ScrollMetrics metrics, AxisDirection axisDirection) {
_lastMetrics = metrics;

void updateThickness(float nextThickness, Radius nextRadius) {
thickness = nextThickness;
radius = nextRadius;
notifyListeners();
}
Paint _paint {
get {
var paint = new Paint();

}
void _paintThumbCrossAxis(Canvas canvas, Size size, float thumbOffset, float thumbExtent, AxisDirection direction) {
float x = 0;
float y = 0;
Size thumbSize = Size.zero;
float _getThumbX(Size size) {
D.assert(textDirection != null);
switch (textDirection) {
case TextDirection.rtl:
return crossAxisMargin;
case TextDirection.ltr:
return size.width - thickness - crossAxisMargin;
switch (direction) {
case AxisDirection.down:
thumbSize = new Size(thickness, thumbExtent);
x = textDirection == TextDirection.rtl
? crossAxisMargin + padding.left
: size.width - thickness - crossAxisMargin - padding.right;
y = thumbOffset;
break;
case AxisDirection.up:
thumbSize = new Size(thickness, thumbExtent);
x = textDirection == TextDirection.rtl
? crossAxisMargin + padding.left
: size.width - thickness - crossAxisMargin - padding.right;
y = thumbOffset;
break;
case AxisDirection.left:
thumbSize = new Size(thumbExtent, thickness);
x = thumbOffset;
y = size.height - thickness - crossAxisMargin - padding.bottom;
break;
case AxisDirection.right:
thumbSize = new Size(thumbExtent, thickness);
x = thumbOffset;
y = size.height - thickness - crossAxisMargin - padding.bottom;
break;
return 0;
}
void _paintVerticalThumb(Canvas canvas, Size size, float thumbOffset, float thumbExtent) {
Offset thumbOrigin = new Offset(_getThumbX(size), thumbOffset);
Size thumbSize = new Size(thickness, thumbExtent);
Rect thumbRect = thumbOrigin & thumbSize;
_thumbRect = new Offset(x, y) & thumbSize;
canvas.drawRect(thumbRect, _paint);
canvas.drawRect(_thumbRect, _paint);
canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, radius), _paint);
canvas.drawRRect(RRect.fromRectAndRadius(_thumbRect, radius), _paint);
float _thumbExtent() {
float fractionVisible = ((_lastMetrics.extentInside() - _mainAxisPadding) / (_totalContentExtent - _mainAxisPadding))
.clamp(0.0f, 1.0f);
void _paintHorizontalThumb(Canvas canvas, Size size, float thumbOffset, float thumbExtent) {
Offset thumbOrigin = new Offset(thumbOffset, size.height - thickness);
Size thumbSize = new Size(thumbExtent, thickness);
Rect thumbRect = thumbOrigin & thumbSize;
if (radius == null) {
canvas.drawRect(thumbRect, _paint);
}
else {
canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, radius), _paint);
}
}
float thumbExtent = Mathf.Max(
Mathf.Min(_trackExtent, minOverscrollLength),
_trackExtent * fractionVisible
);
public delegate void painterDelegate(Canvas canvas, Size size, float thumbOffset, float thumbExtent);
void _paintThumb(
float before,
float inside,
float after,
float viewport,
Canvas canvas,
Size size,
painterDelegate painter
) {
float thumbExtent = Mathf.Min(viewport, minOverscrollLength);
if (before + inside + after > 0.0) {
float fractionVisible = inside / (before + inside + after);
thumbExtent = Mathf.Max(
thumbExtent,
viewport * fractionVisible - 2 * mainAxisMargin
);
if (before != 0.0 && after != 0.0) {
thumbExtent = Mathf.Max(
minLength,
thumbExtent
);
}
else {
thumbExtent = Mathf.Max(
thumbExtent,
minLength * (((inside / viewport) - 0.8f) / 0.2f)
);
}
float fractionPast = before / (before + after);
float thumbOffset = (before + after > 0.0)
? fractionPast * (viewport - thumbExtent - 2 * mainAxisMargin) + mainAxisMargin
: mainAxisMargin;
painter(canvas, size, thumbOffset, thumbExtent);
}
float fractionOverscrolled = 1.0f - _lastMetrics.extentInside() / _lastMetrics.viewportDimension;
float safeMinLength = Mathf.Min(minLength, _trackExtent);
float newMinLength = (_beforeExtent > 0 && _afterExtent > 0)
? safeMinLength
: safeMinLength * (1.0f - fractionOverscrolled.clamp(0.0f, 0.2f) / 0.2f);
return thumbExtent.clamp(newMinLength, _trackExtent);
}
public override void dispose() {

bool _isVertical => _lastAxisDirection == AxisDirection.down || _lastAxisDirection == AxisDirection.up;
bool _isReversed => _lastAxisDirection == AxisDirection.up || _lastAxisDirection == AxisDirection.left;
float _beforeExtent => _isReversed ? _lastMetrics.extentAfter() : _lastMetrics.extentBefore();
float _afterExtent => _isReversed ? _lastMetrics.extentBefore() : _lastMetrics.extentAfter();
float _mainAxisPadding => _isVertical ? padding.vertical : padding.horizontal;
float _trackExtent => _lastMetrics.viewportDimension - 2 * mainAxisMargin - _mainAxisPadding;
float _totalContentExtent {
get {
return _lastMetrics.maxScrollExtent
- _lastMetrics.minScrollExtent
+ _lastMetrics.viewportDimension;
}
}
float getTrackToScroll(float thumbOffsetLocal) {
float scrollableExtent = _lastMetrics.maxScrollExtent - _lastMetrics.minScrollExtent;
float thumbMovableExtent = _trackExtent - _thumbExtent();
return scrollableExtent * thumbOffsetLocal / thumbMovableExtent;
}
float _getScrollToTrack(ScrollMetrics metrics, float thumbExtent) {
float scrollableExtent = metrics.maxScrollExtent - metrics.minScrollExtent;
float fractionPast = (scrollableExtent > 0)
? ((metrics.pixels - metrics.minScrollExtent) / scrollableExtent).clamp(0.0f, 1.0f)
: 0;
return (_isReversed ? 1 - fractionPast : fractionPast) * (_trackExtent - thumbExtent);
}
|| fadeoutOpacityAnimation.value == 0.0) {
|| fadeoutOpacityAnimation.value == 0.0f) {
switch (_lastAxisDirection) {
case AxisDirection.down:
_paintThumb(_lastMetrics.extentBefore(), _lastMetrics.extentInside(),
_lastMetrics.extentAfter(), size.height, canvas, size, _paintVerticalThumb);
break;
case AxisDirection.up:
_paintThumb(_lastMetrics.extentAfter(), _lastMetrics.extentInside(),
_lastMetrics.extentBefore(), size.height, canvas, size, _paintVerticalThumb);
break;
case AxisDirection.right:
_paintThumb(_lastMetrics.extentBefore(), _lastMetrics.extentInside(),
_lastMetrics.extentAfter(), size.width, canvas, size, _paintHorizontalThumb);
break;
case AxisDirection.left:
_paintThumb(_lastMetrics.extentAfter(), _lastMetrics.extentInside(),
_lastMetrics.extentBefore(), size.width, canvas, size, _paintHorizontalThumb);
break;
if (_lastMetrics.viewportDimension <= _mainAxisPadding || _trackExtent <= 0) {
return;
float beforePadding = _isVertical ? padding.top : padding.left;
float thumbExtent = _thumbExtent();
float thumbOffsetLocal = _getScrollToTrack(_lastMetrics, thumbExtent);
float thumbOffset = thumbOffsetLocal + mainAxisMargin + beforePadding;
_paintThumbCrossAxis(canvas, size, thumbOffset, thumbExtent, _lastAxisDirection.Value);
}
bool hitTestInteractive(Offset position) {
if (_thumbRect == null) {
return false;
}
if (fadeoutOpacityAnimation.value == 0.0f) {
return false;
}
Rect interactiveThumbRect = _thumbRect.expandToInclude(
Rect.fromCircle(center: _thumbRect.center, radius: ScrollbarPainterUtils._kMinInteractiveSize / 2)
);
return interactiveThumbRect.contains(position);
return false;
if (_thumbRect == null) {
return null;
}
if (fadeoutOpacityAnimation.value == 0.0f) {
return false;
}
return _thumbRect.contains(position);
}
public bool shouldRepaint(CustomPainter oldRaw) {

|| mainAxisMargin != old.mainAxisMargin
|| crossAxisMargin != old.crossAxisMargin
|| radius != old.radius
|| minLength != old.minLength;
|| minLength != old.minLength
|| padding != old.padding;
}
return false;

6
com.unity.uiwidgets/Runtime/widgets/selectable_text.cs


}
void _handleDragUpdate(DragUpdateDetails details) {
_lastDragUpdateDetails = details;
_dragUpdateThrottleTimer = _dragUpdateThrottleTimer ??
Timer.create(TextSelectionUtils._kDragSelectionUpdateThrottle,
_handleDragUpdateThrottled);
_lastDragUpdateDetails = details;
_dragUpdateThrottleTimer = _dragUpdateThrottleTimer ?? Timer.create(TextSelectionUtils._kDragSelectionUpdateThrottle, _handleDragUpdateThrottled);
}
object _handleDragUpdateThrottled() {

6
com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs


}
protected override float computeMinIntrinsicWidth(float height) {
protected internal override float computeMinIntrinsicWidth(float height) {
if (child != null) {
return child.getMinIntrinsicWidth(height);
}

protected override float computeMaxIntrinsicWidth(float height) {
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child != null) {
return child.getMaxIntrinsicWidth(height);
}

protected override float computeMinIntrinsicHeight(float width) {
protected internal override float computeMinIntrinsicHeight(float width) {
if (child != null) {
return child.getMinIntrinsicHeight(width);
}

493
com.unity.uiwidgets/Runtime/widgets/sliver.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.external;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public abstract class SliverChildDelegate {

public abstract bool shouldRebuild(SliverChildDelegate oldDelegate);
public virtual int? findIndexByKey(Key key) {
return null;
}
public override string ToString() {
var description = new List<string>();
debugFillDescription(description);

}
}
public delegate int ChildIndexGetter(Key key);
public class _SaltedValueKey : ValueKey<Key>{
public _SaltedValueKey(Key key) : base(key) {
D.assert(key != null);
}
}
ChildIndexGetter findChildIndexCallback = null,
int? childCount = null,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true

this.findChildIndexCallback = findChildIndexCallback;
this.childCount = childCount;
this.addAutomaticKeepAlives = addAutomaticKeepAlives;
this.addRepaintBoundaries = addRepaintBoundaries;

public readonly bool addAutomaticKeepAlives;
public readonly bool addRepaintBoundaries;
public readonly ChildIndexGetter findChildIndexCallback;
public override int? findIndexByKey(Key key) {
if (findChildIndexCallback == null)
return null;
D.assert(key != null);
Key childKey;
if (key is _SaltedValueKey) {
_SaltedValueKey saltedValueKey = (_SaltedValueKey)key;
childKey = saltedValueKey.value;
} else {
childKey = key;
}
return findChildIndexCallback(childKey);
}
if (index < 0 || (childCount != null && index >= childCount)) {
if (index < 0 || (childCount != null && index >= childCount))
}
Widget child = builder(context, index);
if (child == null) {
Widget child;
/*try {
child = builder(context, index);
} catch (exception, stackTrace) {
child = _createErrorWidget(exception, stackTrace);
}*/
child = builder(context, index);
if (child == null)
}
if (addRepaintBoundaries) {
child = RepaintBoundary.wrap(child, index);
}
if (addAutomaticKeepAlives) {
Key key = child.key != null ? new _SaltedValueKey(child.key) : null;
if (addRepaintBoundaries)
child = new RepaintBoundary(child: child);
/*if (addSemanticIndexes) {
int semanticIndex = semanticIndexCallback(child, index);
if (semanticIndex != null)
child = IndexedSemantics(index: semanticIndex + semanticIndexOffset, child: child);
}*/
if (addAutomaticKeepAlives)
}
return child;
return new KeyedSubtree(child: child, key: key);
}
public override int? estimatedChildCount {

this.children = children;
this.addAutomaticKeepAlives = addAutomaticKeepAlives;
this.addRepaintBoundaries = addRepaintBoundaries;
_keyToIndex = new Dictionary<Key, int>();
}
public readonly bool addAutomaticKeepAlives;

public readonly List<Widget> children;
public readonly Dictionary<Key, int> _keyToIndex;
public override Widget build(BuildContext context, int index) {
D.assert(children != null);
if (index < 0 || index >= children.Count) {
public bool _isConstantInstance {
get {
return _keyToIndex == null;
}
}
public int? _findChildIndex(Key key) {
if (_isConstantInstance) {
// Lazily fill the [_keyToIndex].
if (!_keyToIndex.ContainsKey(key)) {
int index = _keyToIndex[null];
while (index < children.Count) {
Widget child = children[index];
if (child.key != null) {
_keyToIndex[child.key] = index;
}
if (child.key == key) {
// Record current index for next function call.
_keyToIndex[null] = index + 1;
return index;
}
index += 1;
}
_keyToIndex[null] = index;
} else {
return _keyToIndex[key];
}
return null;
}
public override int? findIndexByKey(Key key) {
D.assert(key != null);
Key childKey;
if (key is _SaltedValueKey) {
_SaltedValueKey saltedValueKey = (_SaltedValueKey)key;
childKey = saltedValueKey.value;
} else {
childKey = key;
}
return _findChildIndex(childKey);
}
public override Widget build(BuildContext context, int index) {
D.assert(children != null);
if (index < 0 || index >= children.Count)
return null;
D.assert(child != null);
if (addRepaintBoundaries) {
child = RepaintBoundary.wrap(child, index);
}
if (addAutomaticKeepAlives) {
Key key = child.key != null? new _SaltedValueKey(child.key) : null;
D.assert(
child != null,()=>
"The sliver's children must not contain null values, but a null value was found at index $index"
);
if (addRepaintBoundaries)
child = new RepaintBoundary(child: child);
/*if (addSemanticIndexes) {
int semanticIndex = semanticIndexCallback(child, index);
if (semanticIndex != null)
child = IndexedSemantics(index: semanticIndex + semanticIndexOffset, child: child);
}*/
if (addAutomaticKeepAlives)
}
return child;
return new KeyedSubtree(child: child, key: key);
}
public override int? estimatedChildCount {

public abstract override RenderObject createRenderObject(BuildContext context);
}
public class SliverIgnorePointer : SingleChildRenderObjectWidget {
public SliverIgnorePointer(
Key key = null,
bool ignoring = true,
bool? ignoringSemantics = null,
Widget sliver = null
) : base(key: key, child: sliver) {
D.assert(ignoring != null);
this.ignoring = ignoring;
this.ignoringSemantics = ignoringSemantics;
}
public readonly bool ignoring;
public readonly bool? ignoringSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverIgnorePointer(
ignoring: ignoring,
ignoringSemantics: ignoringSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverIgnorePointer) renderObject;
((RenderSliverIgnorePointer)renderObject).ignoring = ignoring;
((RenderSliverIgnorePointer)renderObject).ignoringSemantics = ignoringSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("ignoring", ignoring));
properties.add(new DiagnosticsProperty<bool>("ignoringSemantics", (bool)ignoringSemantics, defaultValue: null));
}
}
public class SliverOffstage : SingleChildRenderObjectWidget {
public SliverOffstage(
Key key = null,
bool offstage = true,
Widget sliver = null) : base(key: key, child: sliver) {
D.assert(offstage != null);
this.offstage = offstage;
}
public readonly bool offstage;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverOffstage(offstage: offstage);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverOffstage) renderObject;
((RenderSliverOffstage)renderObject).offstage = offstage;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("offstage", offstage));
}
public override Element createElement() {
return new _SliverOffstageElement(this);
}
}
public abstract class SliverMultiBoxAdaptorWidget : SliverWithKeepAliveWidget {
protected SliverMultiBoxAdaptorWidget(
Key key = null,

public override Element createElement() {
return new SliverMultiBoxAdaptorElement(this);
}
public abstract override RenderObject createRenderObject(BuildContext context);
public virtual float? estimateMaxScrollOffset(
SliverConstraints constraints,
int firstIndex,

properties.add(new DiagnosticsProperty<SliverChildDelegate>("del", del));
}
}
public class SliverList : SliverMultiBoxAdaptorWidget {
public SliverList(
Key key = null,
SliverChildDelegate del = null
) : base(key: key, del: del) {
}
public override RenderObject createRenderObject(BuildContext context) {
SliverMultiBoxAdaptorElement element = (SliverMultiBoxAdaptorElement) context;
return new RenderSliverList(childManager: element);
}
}
public class SliverOpacity : SingleChildRenderObjectWidget {
public SliverOpacity(
Key key = null,
float opacity = 0f,
bool alwaysIncludeSemantics = false,
Widget sliver = null) : base(key: key, child: sliver) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
D.assert(alwaysIncludeSemantics != null);
this.opacity = opacity;
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public readonly float opacity;
public readonly bool alwaysIncludeSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverOpacity(
opacity: opacity,
alwaysIncludeSemantics: alwaysIncludeSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverOpacity) renderObject;
((RenderSliverOpacity) renderObject).opacity = opacity;
((RenderSliverOpacity) renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<float>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}
public class _SliverOffstageElement : SingleChildRenderObjectElement {
public _SliverOffstageElement(SliverOffstage widget) : base(widget) {
}
public SliverOffstage widget {
get { return base.widget as SliverOffstage; }
}
public override void debugVisitOnstageChildren(ElementVisitor visitor) {
if (!widget.offstage)
base.debugVisitOnstageChildren(visitor);
}
}
public class SliverFixedExtentList : SliverMultiBoxAdaptorWidget {
public SliverFixedExtentList(
Key key = null,

renderObject.itemExtent = itemExtent;
}
}
public class SliverGrid : SliverMultiBoxAdaptorWidget {
public SliverGrid(
Key key = null,

float childAspectRatio = 1.0f,
List<Widget> children = null
) {
SliverGridDelegate gridDelegate = new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount ?? 0,
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio
);
layoutDelegate: new SliverChildListDelegate(children ?? new List<Widget> { }),
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount ?? 0,
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio
)
layoutDelegate: new SliverChildListDelegate(children ?? new List<Widget>()),
gridDelegate: gridDelegate
);
}

}
}
public class SliverFillViewport : SliverMultiBoxAdaptorWidget {
public class SliverIgnorePointer : SingleChildRenderObjectWidget {
public SliverIgnorePointer(
Key key = null,
bool ignoring = true,
bool? ignoringSemantics = null,
Widget sliver = null
) : base(key: key, child: sliver) {
D.assert(ignoring != null);
this.ignoring = ignoring;
this.ignoringSemantics = ignoringSemantics;
}
public readonly bool ignoring;
public readonly bool? ignoringSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverIgnorePointer(
ignoring: ignoring,
ignoringSemantics: ignoringSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverIgnorePointer) renderObject;
((RenderSliverIgnorePointer)renderObject).ignoring = ignoring;
((RenderSliverIgnorePointer)renderObject).ignoringSemantics = ignoringSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("ignoring", ignoring));
properties.add(new DiagnosticsProperty<bool>("ignoringSemantics", (bool)ignoringSemantics, defaultValue: null));
}
}
public class SliverOffstage : SingleChildRenderObjectWidget {
public SliverOffstage(
Key key = null,
bool offstage = true,
Widget sliver = null) : base(key: key, child: sliver) {
D.assert(offstage != null);
this.offstage = offstage;
}
public readonly bool offstage;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverOffstage(offstage: offstage);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverOffstage) renderObject;
((RenderSliverOffstage)renderObject).offstage = offstage;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("offstage", offstage));
}
public override Element createElement() {
return new _SliverOffstageElement(this);
}
}
public class SliverList : SliverMultiBoxAdaptorWidget {
public SliverList(
Key key = null,
SliverChildDelegate del = null
) : base(key: key, del: del) {
}
public override RenderObject createRenderObject(BuildContext context) {
SliverMultiBoxAdaptorElement element = (SliverMultiBoxAdaptorElement) context;
return new RenderSliverList(childManager: element);
}
}
public class SliverOpacity : SingleChildRenderObjectWidget {
public SliverOpacity(
Key key = null,
float opacity = 0f,
bool alwaysIncludeSemantics = false,
Widget sliver = null) : base(key: key, child: sliver) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
D.assert(alwaysIncludeSemantics != null);
this.opacity = opacity;
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public readonly float opacity;
public readonly bool alwaysIncludeSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverOpacity(
opacity: opacity,
alwaysIncludeSemantics: alwaysIncludeSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverOpacity) renderObject;
((RenderSliverOpacity) renderObject).opacity = opacity;
((RenderSliverOpacity) renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<float>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}
public class _SliverOffstageElement : SingleChildRenderObjectElement {
public _SliverOffstageElement(SliverOffstage widget) : base(widget) {
}
public SliverOffstage widget {
get { return base.widget as SliverOffstage; }
}
public override void debugVisitOnstageChildren(ElementVisitor visitor) {
if (!widget.offstage)
base.debugVisitOnstageChildren(visitor);
}
}
/*public class SliverFillViewport : SliverMultiBoxAdaptorWidget {
public SliverFillViewport(
Key key = null, SliverChildDelegate del = null,
float viewportFraction = 1.0f) : base(key: key, del: del) {

public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
((RenderSliverFillViewport) renderObject).viewportFraction = viewportFraction;
}
}
}*/
public class SliverMultiBoxAdaptorElement : RenderObjectElement, RenderSliverBoxChildManager {
public SliverMultiBoxAdaptorElement(SliverMultiBoxAdaptorWidget widget) : base(widget) {

protected override void performRebuild() {
_childWidgets.Clear();
base.performRebuild();
SplayTree<int, Element> newChildren = new SplayTree<int, Element>();
Dictionary<int, float> indexToLayoutOffset = new Dictionary<int, float>();
Element newChild = updateChild(_childElements.getOrDefault(index), _build(index),
index);
if (_childElements[index] != null && _childElements[index] != newChildren[index]) {
_childElements[index] = updateChild(_childElements[index], null, index);
}
Element newChild = updateChild(newChildren[index], _build(index), index);
SliverMultiBoxAdaptorParentData parentData = (SliverMultiBoxAdaptorParentData) newChild.renderObject.parentData;
if (!parentData.keptAlive) {
_currentBeforeChild = (RenderBox) newChild.renderObject;
SliverMultiBoxAdaptorParentData parentData = newChild.renderObject.parentData as SliverMultiBoxAdaptorParentData;
if (index == 0) {
parentData.layoutOffset = 0.0f;
} else if (indexToLayoutOffset.ContainsKey(index)) {
parentData.layoutOffset = indexToLayoutOffset[index];
if (!parentData.keptAlive)
_currentBeforeChild = newChild.renderObject as RenderBox;
} else {
_childElements.Remove(index);
else {
}
foreach ( int index in _childElements.Keys.ToList()) {
Key key = _childElements[index].widget.key;
int? newIndex = key == null ? null : widget.del.findIndexByKey(key);
SliverMultiBoxAdaptorParentData childParentData =
_childElements[index].renderObject?.parentData as SliverMultiBoxAdaptorParentData;
if (childParentData != null && childParentData.layoutOffset != null)
indexToLayoutOffset[index] = (float)childParentData.layoutOffset;
if (newIndex != null && newIndex != index) {
if (childParentData != null)
childParentData.layoutOffset = null;
newChildren[newIndex ?? 0] = _childElements[index];
newChildren.putIfAbsent(index, () => null);
} else {
newChildren.putIfAbsent(index, () => _childElements[index]);
// processElement may modify the Map - need to do a .toList() here.
_childElements.Keys.ToList().ForEach(action: processElement);
if (_didUnderflow) {
var lastKey = _childElements?.Last()?.Key ?? -1;
processElement(lastKey + 1);
renderObject.setDebugChildIntegrityEnabled(false); // Moving children will temporary violate the integrity.
//newChildren.Keys.ForEach(processElement);
foreach (var key in newChildren.Keys) {
processElement(key);
}
if (_didUnderflow) {
int lastKey = _childElements.Count == 0 ? -1 : _childElements.Keys.Last();
int rightBoundary = lastKey + 1;
newChildren[rightBoundary] = _childElements[rightBoundary];
processElement(rightBoundary);
}
finally {
} finally {
renderObject.setDebugChildIntegrityEnabled(true);
}
}

D.assert(child.slot != null);
D.assert(_childElements.ContainsKey((int) child.slot));
_childElements.Remove((int) child.slot);
base.forgetChild(child);
}
public void removeChild(RenderBox child) {

return true;
}
public void didAdoptChild(RenderBox child) {
public virtual void didAdoptChild(RenderBox child) {
D.assert(_currentlyUpdatingChildIndex != null);
SliverMultiBoxAdaptorParentData childParentData = (SliverMultiBoxAdaptorParentData) child.parentData;
childParentData.index = _currentlyUpdatingChildIndex.Value;

break;
}
return parentData.layoutOffset < renderObject.constraints.scrollOffset +
renderObject.constraints.remainingPaintExtent &&
return parentData.layoutOffset != null &&
parentData.layoutOffset < renderObject.constraints.scrollOffset + renderObject.constraints.remainingPaintExtent &&
public class SliverFillRemaining : SingleChildRenderObjectWidget {
/*public class SliverFillRemaining : SingleChildRenderObjectWidget {
public SliverFillRemaining(
Key key = null,
Widget child = null

public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverFillRemaining();
}
}
}*/
public class KeepAlive : ParentDataWidget<KeepAliveParentDataMixin> {
public KeepAlive(

}
public override Type debugTypicalAncestorWidgetClass {
get => typeof(SliverWithKeepAliveWidget);
get { return typeof(SliverWithKeepAliveWidget); }
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

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

正在加载...
取消
保存