浏览代码

minor fixes

preferredSize widget is made to be a statefulwidget. it is not the same as in flutter, but works the same. you can refer to the comments for the reason
/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
e8714f54
共有 2 个文件被更改,包括 24 次插入16 次删除
  1. 4
      com.unity.uiwidgets/Runtime/material/scaffold.cs
  2. 36
      com.unity.uiwidgets/Runtime/widgets/preferred_size.cs

4
com.unity.uiwidgets/Runtime/material/scaffold.cs


public readonly Completer _completer;
public Completer closed {
get { return _completer; }
public Future closed {
get { return _completer.future; }
}
public readonly VoidCallback close;

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


Size preferredSize { get; }
}
public abstract class PreferredSizeWidget : StatefulWidget{
public abstract class PreferredSizeWidget : StatefulWidget, SizePreferred {
protected PreferredSizeWidget(Key key = null) : base(key: key) {
}

public class PreferredSize : StatelessWidget{
/**
* In flutter this class inherits StatelessWidget explicitly, in particular, the class inheritance diagram looks like follows:
* PreferredSizeWidget <-- Widget
* | |
* v v
* PreferredSize <-- StatelessWidget
*
* It is hard to implement such a complex inheritance diagram in C#. so we choose to create a slightly different diagram, which is more simple and making every C# code happy:
*
* PreferredSize <-- PreferredSizeWidget <-- StatefulWidget <-- Widget
*
* The bad side is that, we should make all classes that inherit PreferredSizeWidget to be statefulWidget now. Though it is not that bad since a statelessWidget can be made a statefulWidget easily
*
*/
public class PreferredSize : PreferredSizeWidget {
public PreferredSize(
Key key = null,
Widget child = null,

}
public readonly Widget child;
//public override Size preferredSize { get; }
public Size preferredSize { get; }
/*public override State createState() {
public override Size preferredSize { get; }
public override State createState() {
}*/
public override Widget build(BuildContext context) {
return child;
//throw new System.NotImplementedException();
/*class _PreferredSizeState : State<PreferredSize> {
public override Widget build(BuildContext context) {
class _PreferredSizeState : State<PreferredSize> {
public override Widget build(BuildContext buildContext) {
}*/
}
}
正在加载...
取消
保存