pub fn new(f: impl Fn(&mut Env, &T) + 'static, child: W) -> EnvScope<T, W> {
        EnvScope {
            f: Box::new(f),
            child: WidgetPod::new(child),
        }
    }
/// Create a widget that updates the environment for its descendants.
///
/// Accepts a closure that sets Env values.
///
/// This is available as [`WidgetExt::env_scope`] for convenience.
///
/// # Examples
/// ```
/// # use druid::{theme, Widget};
/// # use druid::piet::{Color};
/// # use druid::widget::{Label, EnvScope};
/// # fn build_widget() -> impl Widget<String> {
/// EnvScope::new(
///     |env, data| {
///         env.set(theme::TEXT_COLOR, Color::WHITE);
///     },
///     Label::new("White text!")
/// )
///
/// # }
/// ```
///
/// [`WidgetExt::env_scope`]: ../trait.WidgetExt.html#method.env_scope
Create a widget that updates the environment for its descendants.
Accepts a closure that sets Env values.

This is available as [`WidgetExt::env_scope`] for convenience.
Create a widget that updates the environment for its descendants . Accepts a closure that sets Env values . This is available as [ ` WidgetExt :: env_scope ` ] for convenience .
pub fn new(f: impl Fn(&mut Env, &T) + 'static, child: W) -> EnvScope<T, W> {
        EnvScope {
            f: Box::new(f),
            child: WidgetPod::new(child),
        }
    }
pub fn new ( f : impl Fn ( & mut Env , & T ) + ' static , child : W ) -> EnvScope < T , W > { EnvScope { f : Box :: new ( f ) , child : WidgetPod :: new ( child ) , } }
Create a widget that updates the environment for its descendants.
Create a widget that updates the environment for its descendants .
f
impl Fn(&mut Env, &T) + 'static
child
W
f
impl Fn(&mut Env, &T) + 'static
child
W
examples
None
use druid::{theme, widget};
None
use druid::piet::{color};
None
use druid::widget::{label, envscope};
None
fn build_widget() -> impl widget<string> {
:new(
|env, data| {
env.set(theme::TEXT_COLOR, Color::WHITE);
},
Label::new("White text!")
)
: new ( |env data| { env . set ( theme :: TEXT_COLOR Color :: WHITE ) ; } Label :: new ( " White text! " ) )
}
None