Unverified Commit ffbb335e authored by liyuqian's avatar liyuqian Committed by GitHub

Error message for setting shaderWarmUp too late (#30145)

Developers may get confused by setting PaintingBinding.shaderWarmUp in
the wrong place. The added assert and error message help avoid that.
parent 1bfa2f23
...@@ -53,7 +53,20 @@ mixin PaintingBinding on BindingBase, ServicesBinding { ...@@ -53,7 +53,20 @@ mixin PaintingBinding on BindingBase, ServicesBinding {
/// See also: /// See also:
/// ///
/// * [ShaderWarmUp], the interface of how this warm up works. /// * [ShaderWarmUp], the interface of how this warm up works.
static ShaderWarmUp shaderWarmUp = const DefaultShaderWarmUp(); static ShaderWarmUp get shaderWarmUp => _shaderWarmUp;
static set shaderWarmUp(ShaderWarmUp value) {
assert(_instance == null,
'PaintingBinding.shaderWarmUp should only be set before the '
'PaintingBinding singleton instance is initialized.\n\n'
'Setting it after init would not affect how shaders are warmed up.\n\n'
'To fix this, try to change PaintingBinding.shaderWarmUp before:\n'
' 1. runApp\n'
' 2. WidgetsFlutterBinding.ensureInitialized\n'
' 3. enableFlutterDriverExtension\n'
);
_shaderWarmUp = value;
}
static ShaderWarmUp _shaderWarmUp = const DefaultShaderWarmUp();
/// The singleton that implements the Flutter framework's image cache. /// The singleton that implements the Flutter framework's image cache.
/// ///
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment