Как установить высоту индикатора панели вкладок и высоту панели приложений равными в флаттере - PullRequest
0 голосов
/ 27 января 2020

Я новичок, чтобы трепетать. И я хочу установить равную высоту для индикатора TabBar и AppBar. как показано на рисунке ниже

ожидается

Работает, устанавливая предпочтительную высоту, но когда я меняю устройство, высота TabBar и AppBar работает по-другому .

Это код индикатора TabBar

class CustomTabIndicator extends Decoration {

   @override
   _CustomPainter createBoxPainter([VoidCallback onChanged]) {
     return new _CustomPainter(this, onChanged);
   }
 }

class _CustomPainter extends BoxPainter {

  final CustomTabIndicator decoration;
  _CustomPainter(this.decoration, VoidCallback onChanged)
  : assert(decoration != null),
    super(onChanged);
  double indicatorHeight = SizeConfig.blockSizeVertical * 8;  

  @override
  void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
    assert(configuration != null);
    assert(configuration.size != null);

    //offset is the position from where the decoration should be drawn.
    //configuration.size tells us about the height and width of the tab.
    final Rect rect = Offset(offset.dx, (configuration.size.height/2)-indicatorHeight/2 ) & Size(configuration.size.width, indicatorHeight);

    final Paint paint = Paint();
    paint.color = Colors.white;
    paint.style = PaintingStyle.fill;
    canvas.drawRRect(RRect.fromRectAndRadius(rect, Radius.circular(2.0)), paint);
  }
}

Это код размера моего AppBar

 appBar: PreferredSize(
   preferredSize: Size(20, SizeConfig.blockSizeVertical * 4),
   child:AppBar( .....)
...