Example #1
0
        public override Widget build(BuildContext context, float shrinkOffset, bool overlapsContent)
        {
            float?visibleMainHeight = maxExtent - shrinkOffset - topPadding;
            float toolbarOpacity    = !pinned || (!floating && bottom != null)
                ? ((visibleMainHeight - _bottomHeight) / material_.kToolbarHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
                : 1.0f;
            Widget appBar = FlexibleSpaceBar.createSettings(
                minExtent: minExtent,
                maxExtent: maxExtent,
                currentExtent: Mathf.Max(minExtent ?? 0.0f, maxExtent ?? 0.0f - shrinkOffset),
                toolbarOpacity: toolbarOpacity,
                child: new AppBar(
                    leading: leading,
                    automaticallyImplyLeading: automaticallyImplyLeading,
                    title: title,
                    actions: actions,
                    flexibleSpace: flexibleSpace,
                    bottom: bottom,
                    elevation: forceElevated || overlapsContent ||
                    (pinned && shrinkOffset > maxExtent - minExtent)
                        ? elevation ?? 4.0f
                        : 0.0f,
                    backgroundColor: backgroundColor,
                    brightness: brightness,
                    iconTheme: iconTheme,
                    textTheme: textTheme,
                    primary: primary,
                    centerTitle: centerTitle,
                    titleSpacing: titleSpacing,
                    shape: shape,
                    toolbarOpacity: toolbarOpacity,
                    bottomOpacity: pinned
                        ? 1.0f
                        : (visibleMainHeight / _bottomHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
                    )
                );

            return(floating ? new _FloatingAppBar(child: appBar) : appBar);
        }
Example #2
0
        public override Widget build(BuildContext context, float shrinkOffset, bool overlapsContent)
        {
            float?visibleMainHeight = this.maxExtent - shrinkOffset - this.topPadding;
            float toolbarOpacity    = this.pinned && !this.floating
                ? 1.0f
                : ((visibleMainHeight - this._bottomHeight) / Constants.kToolbarHeight)?.clamp(0.0f, 1.0f) ?? 0.0f;
            Widget appBar = FlexibleSpaceBar.createSettings(
                minExtent: this.minExtent,
                maxExtent: this.maxExtent,
                currentExtent: Mathf.Max(this.minExtent ?? 0.0f, this.maxExtent ?? 0.0f - shrinkOffset),
                toolbarOpacity: toolbarOpacity,
                child: new AppBar(
                    leading: this.leading,
                    automaticallyImplyLeading: this.automaticallyImplyLeading,
                    title: this.title,
                    actions: this.actions,
                    flexibleSpace: this.flexibleSpace,
                    bottom: this.bottom,
                    elevation: this.forceElevated || overlapsContent ||
                    (this.pinned && shrinkOffset > this.maxExtent - this.minExtent)
                        ? this.elevation ?? 4.0f
                        : 0.0f,
                    backgroundColor: this.backgroundColor,
                    brightness: this.brightness,
                    iconTheme: this.iconTheme,
                    textTheme: this.textTheme,
                    primary: this.primary,
                    centerTitle: this.centerTitle,
                    titleSpacing: this.titleSpacing,
                    toolbarOpacity: toolbarOpacity,
                    bottomOpacity: this.pinned
                        ? 1.0f
                        : (visibleMainHeight / this._bottomHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
                    )
                );

            return(this.floating ? new _FloatingAppBar(child: appBar) : appBar);
        }