如下可见,它实现了 PreferredSizeWidget 类: 如下所示,PreferredSizeWidget 是一个抽象类,其中定义了 preferredSize 抽象 get 方法,返回 Size 也就是说该族的组件是需要预先设定尺寸的: abstract class PreferredSizeWidget implements Widget { Size get preferredSize; } ---- 所以 AppBar 既然实现 PreferredSizeWidget,就必然实现 preferredSize 方法,返回尺寸。 所以根据这个线索可以知道高度是如何确定的:AppBar 中定义了 preferredSize 成员,所以抽象的 get 方法,将获取该成员: 在 AppBar 构造方法中,preferredSize 其中 toolbarHeight 如果为空,会取 kToolbarHeight, 值为 56 : ---->[AppBar]---- @override final Size preferredSize
) { return RenderCustomPaint( painter: painter, foregroundPainter: foregroundPainter, preferredSize 在创建 RenderCustomPaint 对象时,size 被作为 preferredSize 入参,初始化 RenderCustomPaint 中的 _preferredSize 成员。 ? ? 在 performResize 中,size 被赋值为 constraints.constrain(preferredSize) 。 RenderCustomPaint#performResize]---- @override void performResize() { size = constraints.constrain(preferredSize 当前 preferredSize 由于未设置,默认为 Size(0,0),那接下来看一下 constrain 方法做了什么。 ?
小组件作为一个抽象接口类,主要用于返回该小部件在不受其他限制的情况下设定的较理想的大小;若没有进行约束高度,则会使用 PreferredSizeWidget 指定的高度;而 TabBar 就是实现了 preferredSize 方法,用于设置高度,和尚尝试调整 preferredSize 即可调整 TabBar 默认高度; @override Size get preferredSize { for (final Widget
Widget build(BuildContext context) { return IgnorePointer(child: child); } @override Size get preferredSize => child.preferredSize; } 然后,我们需要更新JobApplicationFlow ,让TabBar 成为ReadOnlyTabBar的child。
backgroundColor, child: this.child, ); } @override double get maxExtent => this.child.preferredSize.height ; @override double get minExtent => this.child.preferredSize.height; @override bool shouldRebuild
), ); 或者 SizedBox( width: 100, // specific value child: RaisedButton(...) ) 设置AppBar的height 使用PreferredSize BuildContext context) { return MaterialApp( title: 'Example', home: Scaffold( appBar: PreferredSize ( preferredSize: Size.fromHeight(50.0), // here the desired height child: AppBar(
child: InkWell( onTap: onTap, child: SizedBox.fromSize( size: preferredSize ], ), ), ), ), ); } @override Size get preferredSize
appBar: PreferredSize( child: AppBar( title: Row(children: <Widget>[ Text('标题栏高度测试- 80.0'), Expanded(flex: 1, child: Icon(Icons.add)) ])), preferredSize: Size.fromHeight(80.0
AppBar 的 bottom 默认支持 TabBar, 也就是常见的顶部 Tab 的效果,这其实是因为TabBar 实现了 PreferredSizeWidget 的 preferredSize。 所以只要你的控件实现了 preferredSize,就可以放到 AppBar 的 bottom 中使用。比如下图搜索栏,这是TabView下的页面又实用了AppBar。
AppBar 的 bottom 默认支持 TabBar, 也就是常见的顶部 Tab 的效果,这其实是因为TabBar 实现了 PreferredSizeWidget 的 preferredSize。 所以只要你的控件实现了 preferredSize,就可以放到 AppBar 的 bottom 中使用。比如下图搜索栏,这是TabView下的页面又实用了AppBar。 ?
var pos = d.globalPosition; balls.add(new Draw(pos.dx, pos.dy - appBar.preferredSize.height (d) { var pos = d.globalPosition; balls.add(new Draw(pos.dx, pos.dy - appBar.preferredSize.height ) { _downX = d.globalPosition.dx; _downY = d.globalPosition.dy - appBar.preferredSize.height onPanUpdate: (d) { _upX = d.globalPosition.dx; _upY = d.globalPosition.dy - appBar.preferredSize.height
SliverPersistentHeader( pinned: true, delegate: CustomStickyHeader( child: PreferredSize ( preferredSize: Size.fromHeight(45.0), child: Container( ..
/MinSize/PreferredSize Vertical Fit:高度如何控制Unconstrained/MinSize/PreferredSize 描述: Content Size Fitter
START_OVER 播放完从头再次播放,REVERSE 从无到有从有到无; d. duration 可设置动画播放时长;当设置无限重复时不生效;其余根据重复频率使单次动画时长均分; e. preferredSize
Horizontal Fit和Vertical Fit均为UI.ContentSizeFitter.FitMode枚举类型,有三个值可选:Unconstrained,MinSize,PreferredSize
用来在 Toolbar 标题下面显示一个 Tab 导航栏 bottom: PreferredSize( child: Text('bottom区间'), preferredSize: Size.fromHeight
mForm.Width; cR.Height = mForm.Height; cR.Left = 0; cR.Top = 0; cR.Width = mForm.PreferredSize.Width ; cR.Height = mForm.PreferredSize.Height; oldCtrl.Add(cR);//第一个为"窗体本身",只加入一次即可
layout=java.awt.GridBagLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize layout=java.awt.GridBagLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize layout=java.awt.GridBagLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize ,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize layout=java.awt.GridBagLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize
NSMutableArray alloc] init]; if ([_user[@"isteacher"] boolValue]) { _teacherIconNode.style.preferredSize teacherIconNode]; [mainStackContent addObject:teacherIconSpec]; } _volumnNode.style.preferredSize 8.5, 50); _volumnNode.style.layoutPosition = CGPointMake(5, 20); _bottomBackgroundNode.style.preferredSize
contentHeight = mediaQuery.size.height - mediaQuery.padding.top - mediaQuery.padding.bottom - appbar.preferredSize.height