浏览代码

Merge branch 'shiyun/skia' of github.com:Unity-Technologies/com.unity.uiwidgets into merge_latest_skia_changes

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
0832f7ee
共有 44 个文件被更改,包括 1638 次插入1450 次删除
  1. 76
      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. 2
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs
  10. 3
      com.unity.uiwidgets/Runtime/developer/extension.cs
  11. 5
      com.unity.uiwidgets/Runtime/rendering/binding.cs
  12. 371
      com.unity.uiwidgets/Runtime/rendering/box.cs
  13. 80
      com.unity.uiwidgets/Runtime/rendering/custom_layout.cs
  14. 75
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  15. 3
      com.unity.uiwidgets/Runtime/rendering/object.cs
  16. 63
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  17. 42
      com.unity.uiwidgets/Runtime/ui2/compositing.cs
  18. 4
      com.unity.uiwidgets/Runtime/widgets/actions.cs
  19. 28
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  20. 38
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  21. 47
      com.unity.uiwidgets/Runtime/widgets/debug.cs
  22. 12
      com.unity.uiwidgets/Runtime/widgets/dismissible.cs
  23. 220
      com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs
  24. 622
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  25. 28
      com.unity.uiwidgets/Runtime/widgets/gesture_detector.cs
  26. 51
      com.unity.uiwidgets/Runtime/widgets/heroes.cs
  27. 2
      com.unity.uiwidgets/Runtime/widgets/layout_builder.cs
  28. 2
      com.unity.uiwidgets/Runtime/widgets/localizations.cs
  29. 34
      com.unity.uiwidgets/Runtime/widgets/media_query.cs
  30. 98
      com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs
  31. 253
      com.unity.uiwidgets/Runtime/widgets/navigator.cs
  32. 4
      com.unity.uiwidgets/Runtime/widgets/orientation_builder.cs
  33. 266
      com.unity.uiwidgets/Runtime/widgets/overlay.cs
  34. 2
      com.unity.uiwidgets/Runtime/widgets/page_storage.cs
  35. 63
      com.unity.uiwidgets/Runtime/widgets/page_view.cs
  36. 36
      com.unity.uiwidgets/Runtime/widgets/pages.cs
  37. 4
      com.unity.uiwidgets/Runtime/widgets/route_notification_messages.cs
  38. 177
      com.unity.uiwidgets/Runtime/widgets/routes.cs
  39. 10
      com.unity.uiwidgets/Runtime/widgets/safe_area.cs
  40. 39
      com.unity.uiwidgets/Runtime/widgets/sliver_layout_builder.cs
  41. 8
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  42. 11
      engine/src/lib/ui/compositing/scene_builder.cc
  43. 44
      com.unity.uiwidgets/Runtime/cupertino/cupertinodynamiccolor.mixin.gen.cs
  44. 40
      com.unity.uiwidgets/Runtime/cupertino/cupertinodynamiccolor.mixin.njk

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

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

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

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


textScaleFactor: Mathf.Max(textScaleFactor, 1.0f)
),
child: new LayoutBuilder(
builder: (BuildContext _context, Constraints constraints) => {
builder: (BuildContext _context, BoxConstraints constraints) => {
return new Center(
child: new Container(
margin: EdgeInsets.symmetric(vertical: CupertinoDialogUtils._kEdgePadding),

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

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

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

public float getMaxIntrinsicWidth(float height) {
D.assert(() => {
if (height < 0.0) {
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;
});

public float getMinIntrinsicHeight(float width) {
D.assert(() => {
if (width < 0.0) {
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;

public float getMaxIntrinsicHeight(float width) {
D.assert(() => {
if (width < 0.0) {
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;

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

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

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

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

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


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

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

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

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


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(

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


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;

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


public static bool debugCheckHasMediaQuery(BuildContext context) {
D.assert(() => {
if (!(context.widget is MediaQuery) && context.findAncestorWidgetOfExactType<MediaQuery>() == null) {
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)context).debugGetCreatorChain(10) + "\n" +
"Typically, the MediaQuery widget is introduced by the MaterialApp or " +
"WidgetsApp widget at the top of your application widget tree."
);
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;

D.assert(() => {
if (!(context.widget is Directionality) &&
context.findAncestorWidgetOfExactType<Directionality>() == null) {
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) context).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.");
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;

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


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;

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


new DiagnosticsProperty<Animation<float>>("placeholderOpacity", _placeholderOpacityAnimation));
}
}
/*enum FadeInImagePhase {
start,
waiting,
fadeOut,
fadeIn,
completed
}
delegate void _ImageProviderResolverListener();
class _ImageProviderResolver {
public _ImageProviderResolver(
_FadeInImageState state,
_ImageProviderResolverListener listener
) {
this.state = state;
this.listener = listener;
}
readonly _FadeInImageState state;
readonly _ImageProviderResolverListener listener;
FadeInImage widget {
get { return state.widget; }
}
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);
if (_imageStream.key != oldImageStream?.key) {
oldImageStream?.removeListener(_handleImageChanged);
_imageStream.addListener(_handleImageChanged);
}
}
void _handleImageChanged(ImageInfo imageInfo, bool synchronousCall) {
_imageInfo = imageInfo;
listener();
}
public void stopListening() {
_imageStream?.removeListener(_handleImageChanged);
}
}
class _FadeInImageState : TickerProviderStateMixin<FadeInImage> {
_ImageProviderResolver _imageResolver;
_ImageProviderResolver _placeholderResolver;
AnimationController _controller;
Animation<float> _animation;
FadeInImagePhase _phase = FadeInImagePhase.start;
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();
}
public override void didChangeDependencies() {
_resolveImage();
base.didChangeDependencies();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
FadeInImage fadeInImage = oldWidget as FadeInImage;
if (widget.image != fadeInImage.image || widget.placeholder != fadeInImage.placeholder) {
_resolveImage();
}
}
void _resolveImage() {
_imageResolver.resolve(widget.image);
if (_isShowingPlaceholder) {
_placeholderResolver.resolve(widget.placeholder);
}
if (_phase == FadeInImagePhase.start) {
_updatePhase();
}
}
void _updatePhase() {
setState(() => {
switch (_phase) {
case FadeInImagePhase.start:
if (_imageResolver._imageInfo != null) {
_phase = FadeInImagePhase.completed;
}
else {
_phase = FadeInImagePhase.waiting;
}
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);
}
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;
}
break;
case FadeInImagePhase.completed:
// Nothing to do.
break;
}
});
}
public override void dispose() {
_imageResolver.stopListening();
_placeholderResolver.stopListening();
_controller.dispose();
base.dispose();
}
bool _isShowingPlaceholder {
get {
switch (_phase) {
case FadeInImagePhase.start:
case FadeInImagePhase.waiting:
case FadeInImagePhase.fadeOut:
return true;
case FadeInImagePhase.fadeIn:
case FadeInImagePhase.completed:
return false;
}
return true;
}
}
ImageInfo _imageInfo {
get {
return _isShowingPlaceholder
? _placeholderResolver._imageInfo
: _imageResolver._imageInfo;
}
}
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));
}
}*/
}
}

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

28
com.unity.uiwidgets/Runtime/widgets/gesture_detector.cs


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

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;

51
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) {
D.assert(context != null);
D.assert(navigator != null);
Dictionary<object, _HeroState> result = new Dictionary<object, _HeroState> { };

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: "# ")}"
);
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.
heroState.ensurePlaceholderIsHidden();
}
}

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

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

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

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


namespace Unity.UIWidgets.widgets {
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints);
public delegate Widget ConstraintBuilder(BuildContext context, Constraints constraints);
public delegate Widget ConstraintBuilder(BuildContext context, ConstraintType constraints);
public ConstrainedLayoutBuilder(

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


}
else {
typeToResourcesFuture.then(value => {
if (!mounted) {
if (mounted) {
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)) {

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


public readonly OrientationWidgetBuilder builder;
Widget _buildWithConstraints(BuildContext context, Constraints constraints) {
Widget _buildWithConstraints(BuildContext context, BoxConstraints constraints) {
((BoxConstraints)constraints).maxWidth > ((BoxConstraints)constraints).maxHeight ? Orientation.landscape : Orientation.portrait;
constraints.maxWidth > constraints.maxHeight ? Orientation.landscape : Orientation.portrait;
return builder(context, orientation);
}

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


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)
);
}
internal void _markNeedsBuild() {

}
public class Overlay : StatefulWidget {
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.");*/
D.assert(
above == null || below == null,
()=>"Only one of `above` and `below` may be specified."

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

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,
D.assert(skipCount != null);
D.assert(skipCount >= 0);
D.assert(children != null);
D.assert(children.Count() >= skipCount);

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

int skipCount = 0
) {
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();
}
}
Alignment _resolvedAlignment;

//_resolvedAlignment = AlignmentDirectional.topStart.resolve(textDirection);
// TODO: AlignmentDirectional
Alignment al = Alignment.topLeft;
switch (textDirection) {

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();
}
RenderBox _lastOnstageChild {
get { return skipCount == childCount ? null : lastChild; }
int _onstageChildCount {
get { return childCount - skipCount; }
}
public override void redepthChildren() {
if (child != null) {
redepthChild(child);

}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
List<DiagnosticsNode> offstageChildren = new List<DiagnosticsNode>();
List<DiagnosticsNode> onstageChildren = new List<DiagnosticsNode>();
if (this.child != null) {
children.Add(child.toDiagnosticsNode(name: "onstage"));
}
int count = 1;
bool onstage = false;
RenderBox child = firstChild;
RenderBox firstOnstageChild = _firstOnstageChild;
while (child != null) {
if (child == firstOnstageChild) {
onstage = true;
count = 1;
}
if (firstChild != null) {
var child = firstChild;
int count = 1;
while (true) {
children.Add(
if (onstage) {
onstageChildren.Add(
child.toDiagnosticsNode(
name: $"onstage {count}"
)
);
} else {
offstageChildren.Add(
if (child == lastChild) {
break;
}
}
StackParentData childParentData = child.parentData as StackParentData;
child = childParentData.nextSibling;
count += 1;
}
var childParentData = (StackParentData) child.parentData;
child = childParentData.nextSibling;
count += 1;
if (offstageChildren.isNotEmpty()) {
foreach (var stagechild in offstageChildren) {
onstageChildren.Add(stagechild);
children.Add(
DiagnosticsNode.message(
"no offstage children",
style: DiagnosticsTreeStyle.offstage
)
);
onstageChildren.Add(DiagnosticsNode.message(
"no offstage children",
style: DiagnosticsTreeStyle.offstage
));
return children;
}
return onstageChildren;
RenderBox _lastOnstageChild {
get { return skipCount == childCount ? null : lastChild; }
int _onstageChildCount {
get { return childCount - skipCount; }
}
protected internal override float computeMinIntrinsicWidth(float height) {
return RenderStack.getIntrinsicDimension(_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,

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

63
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,
axisDirection: axisDirection,
offset: position,
slivers: new List<Widget> {

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

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

39
com.unity.uiwidgets/Runtime/widgets/sliver_layout_builder.cs


D.assert(() => {
if (!(child is RenderSliver)) {
throw new UIWidgetsError(
"A " + GetType() + " expected a child of type " + typeof(RenderSliver) + " 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 " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + GetType() + " that expected a " + typeof(RenderSliver) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
new List<DiagnosticsNode>() {
new ErrorSummary(
$"A {GetType()} expected a child of type {typeof(RenderSliver)} but received a " +
$"child of type {child.GetType()}."
),
new ErrorDescription(
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol."
),
new ErrorSpacer(),
new DiagnosticsProperty<object>(
$"The {GetType()} that expected a {typeof(RenderSliver)} child was created by",
debugCreator,
style: DiagnosticsTreeStyle.errorProperty
),
new ErrorSpacer(),
new DiagnosticsProperty<dynamic>(
$"The {child.GetType()} that did not match the expected child type " +
"was created by",
child.debugCreator,
style: DiagnosticsTreeStyle.errorProperty
),
}
);
}

8
com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs


});
if (inDebugMode == false) {
throw new UIWidgetsError(
"The inspector should never be used in production mode due to the " +
"negative performance impact."
new List<DiagnosticsNode>() {
new ErrorSummary(
"The inspector should never be used in production mode due to the " +
"negative performance impact."
)
}
);
}
}

11
engine/src/lib/ui/compositing/scene_builder.cc


}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushShaderMask(SceneBuilder* ptr,
Shader* shader, float maskRectLeft, float maskRectRight, float maskRectTop,
float maskRectBottom, int blendMode) {
const auto layer = ptr->pushShaderMask(
shader, maskRectLeft, maskRectRight, maskRectTop,
maskRectBottom, blendMode);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushPhysicalShape(SceneBuilder* ptr, CanvasPath* path,
float elevation, int color, int shadowColor,
int clipBehavior) {

44
com.unity.uiwidgets/Runtime/cupertino/cupertinodynamiccolor.mixin.gen.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.painting;
namespace Unity.UIWidgets.cupertino {
public class DiagnosticableMixinColor : Color, IDiagnosticable {
protected DiagnosticableMixinColor(uint value) :base(value){
}
public virtual string toStringShort() {
return foundation_.describeIdentity(this);
}
public override string ToString() {
return toString();
}
public virtual string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
string fullString = null;
D.assert(() => {
fullString = toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine)
.toString(minLevel: minLevel);
return true;
});
return fullString ?? toStringShort();
}
public virtual DiagnosticsNode toDiagnosticsNode(
string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new DiagnosticableNode<DiagnosticableMixinColor>(
name: name, value: this, style: style
);
}
public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) {
}
}
}

40
com.unity.uiwidgets/Runtime/cupertino/cupertinodynamiccolor.mixin.njk


namespace Unity.UIWidgets.cupertino {
{% macro DiagnosticableMixin(with) %}
{% set className = 'DiagnosticableMixin' + with %}
public class {{className}} : {{with}}, IDiagnosticable {
protected {{className}}() {
}
public virtual string toStringShort() {
return foundation_.describeIdentity(this);
}
public override string ToString() {
return toString();
}
public virtual string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
string fullString = null;
D.assert(() => {
fullString = toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine)
.toString(minLevel: minLevel);
return true;
});
return fullString ?? toStringShort();
}
public virtual DiagnosticsNode toDiagnosticsNode(
string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new DiagnosticableNode<{{className}}>(
name: name, value: this, style: style
);
}
public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) {
}
}
{% endmacro %}
{{ DiagnosticableMixin('Color') }}
}
正在加载...
取消
保存