浏览代码

add disposable_build_context.cs

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
d0e395ed
共有 5 个文件被更改,包括 69 次插入4 次删除
  1. 4
      Samples/UIWidgetsSamples_2019_4/Packages/manifest.json
  2. 4
      Samples/UIWidgetsSamples_2019_4/ProjectSettings/ProjectVersion.txt
  3. 57
      com.unity.uiwidgets/Runtime/widgets/disposable_build_context.cs
  4. 8
      Samples/UIWidgetsSamples_2019_4/Logs/Packages-Update.log

4
Samples/UIWidgetsSamples_2019_4/Packages/manifest.json


"com.unity.collab-proxy": "1.2.16",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.2.1",
"com.unity.uiwidgets": "file:../../../com.unity.uiwidgets",
"com.unity.test-framework": "1.1.14",
"com.unity.test-framework": "1.1.16",
"com.unity.uiwidgets": "file:../../../com.unity.uiwidgets",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

4
Samples/UIWidgetsSamples_2019_4/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.2f1
m_EditorVersionWithRevision: 2019.4.2f1 (f997fc5c673b)
m_EditorVersion: 2019.4.10f1
m_EditorVersionWithRevision: 2019.4.10f1 (a819905b7a01)

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


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.widgets {
public class DisposableBuildContext<T> where T : State{
/// Creates an object that provides access to a [BuildContext] without leaking
/// a [State].
///
/// Creators must call [dispose] when the [State] is disposed.
///
/// The [State] must not be null, and [State.mounted] must be true.
public DisposableBuildContext(T state) {
D.assert(_state != null);
D.assert(_state.mounted, () => "A DisposableBuildContext was given a BuildContext for an Element that is not mounted.");
}
T _state;
/// Provides safe access to the build context.
///
/// If [dispose] has been called, will return null.
///
/// Otherwise, asserts the [_state] is still mounted and returns its context.
public BuildContext context {
get {
D.assert(_debugValidate());
if (_state == null) {
return null;
}
return _state.context;
}
}
/// Called from asserts or tests to determine whether this object is in a
/// valid state.
///
/// Always returns true, but will assert if [dispose] has not been called
/// but the state this is tracking is unmounted.
public bool _debugValidate() {
D.assert(
_state == null || _state.mounted,() =>
"A DisposableBuildContext tried to access the BuildContext of a disposed " +
"State object. This can happen when the creator of this " +
"DisposableBuildContext fails to call dispose when it is disposed."
);
return true;
}
/// Marks the [BuildContext] as disposed.
///
/// Creators of this object must call [dispose] when their [Element] is
/// unmounted, i.e. when [State.dispose] is called.
void dispose() {
_state = null;
}
}
}

8
Samples/UIWidgetsSamples_2019_4/Logs/Packages-Update.log


=== Mon Jan 11 10:42:38 2021
Packages were changed.
Update Mode: updateDependencies
The following packages were updated:
com.unity.test-framework from version 1.1.14 to 1.1.16
正在加载...
取消
保存