<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      flutter tabbar指示器indicator寬度高度自定義

      在tabbar中indicator寬度是無法修改的,所以需要咱們去自定義indicator。

      下面是自定義的代碼,直接拷貝使用,已做好修改。

      // Copyright 2018 The Chromium Authors. All rights reserved.
      // Use of this source code is governed by a BSD-style license that can be
      // found in the LICENSE file.
      
      import 'package:flutter/material.dart';
      import 'package:flutter/widgets.dart';
      
      /// Used with [TabBar.indicator] to draw a horizontal line below the
      /// selected tab.
      ///
      /// The selected tab underline is inset from the tab's boundary by [insets].
      /// The [borderSide] defines the line's color and weight.
      ///
      /// The [TabBar.indicatorSize] property can be used to define the indicator's
      /// bounds in terms of its (centered) widget with [TabIndicatorSize.label],
      /// or the entire tab with [TabIndicatorSize.tab].
      class TabSizeIndicator extends Decoration {
      
        final double wantWidth;//傳入的指示器寬度,默認20
      
      
        /// Create an underline style selected tab indicator.
        ///
        /// The [borderSide] and [insets] arguments must not be null.
        const TabSizeIndicator({
          this.borderSide = const BorderSide(width: 2.0, color: Colors.blue),
          this.insets = EdgeInsets.zero,
          this.wantWidth = 20
        }) : assert(borderSide != null),
              assert(insets != null),
              assert(wantWidth != null);
      
        /// The color and weight of the horizontal line drawn below the selected tab.
        final BorderSide borderSide;//指示器高度以及顏色 ,默認高度2,顏色藍
      
        /// Locates the selected tab's underline relative to the tab's boundary.
        ///
        /// The [TabBar.indicatorSize] property can be used to define the
        /// tab indicator's bounds in terms of its (centered) tab widget with
        /// [TabIndicatorSize.label], or the entire tab with [TabIndicatorSize.tab].
        final EdgeInsetsGeometry insets;
      
        @override
        Decoration lerpFrom(Decoration a, double t) {
          if (a is UnderlineTabIndicator) {
            return UnderlineTabIndicator(
              borderSide: BorderSide.lerp(a.borderSide, borderSide, t),
              insets: EdgeInsetsGeometry.lerp(a.insets, insets, t),
            );
          }
          return super.lerpFrom(a, t);
        }
      
        @override
        Decoration lerpTo(Decoration b, double t) {
          if (b is TabSizeIndicator) {
            return TabSizeIndicator(
              borderSide: BorderSide.lerp(borderSide, b.borderSide, t),
              insets: EdgeInsetsGeometry.lerp(insets, b.insets, t),
            );
          }
          return super.lerpTo(b, t);
        }
      
        @override
        _MyUnderlinePainter createBoxPainter([ VoidCallback onChanged ]) {
          return _MyUnderlinePainter(this,wantWidth, onChanged);
        }
      }
      
      class _MyUnderlinePainter extends BoxPainter {
        final double wantWidth;
        _MyUnderlinePainter(this.decoration, this.wantWidth,VoidCallback onChanged)
            : assert(decoration != null),
              super(onChanged);
      
        final TabSizeIndicator decoration;
      
        BorderSide get borderSide => decoration.borderSide;
        EdgeInsetsGeometry get insets => decoration.insets;
      
        Rect _indicatorRectFor(Rect rect, TextDirection textDirection) {
          assert(rect != null);
          assert(textDirection != null);
          final Rect indicator = insets.resolve(textDirection).deflateRect(rect);
      
          //希望的寬度
          // double wantWidth = 20;
          //取中間坐標
          double cw = (indicator.left + indicator.right) / 2;
          return Rect.fromLTWH(cw - wantWidth / 2,
              indicator.bottom - borderSide.width, wantWidth, borderSide.width);
        }
      
        @override
        void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
          assert(configuration != null);
          assert(configuration.size != null);
          final Rect rect = offset & configuration.size;
          final TextDirection textDirection = configuration.textDirection;
          final Rect indicator = _indicatorRectFor(rect, textDirection).deflate(borderSide.width / 2.0);
          final Paint paint = borderSide.toPaint()..strokeCap = StrokeCap.square;
          canvas.drawLine(indicator.bottomLeft, indicator.bottomRight, paint);
        }
      }

      將源碼拷貝過來進行修改。以上代碼就是修改好的。下面是使用方式。

      TabBar(
                          indicator: TabSizeIndicator(wantWidth:     
                                           15,borderSide: BorderSide(width: 
                                                  2.0,color: Colors.red)),//TabSizeIndicator已有默認值,寬度默認20,顏色藍色,高度2,不需要修改的可以不傳參數
                                               //TabSizeIndicator();即可                                                              isScrollable:
      true, controller: _tabController, unselectedLabelStyle: TextStyle( fontSize: 13, fontWeight: FontWeight.bold), labelStyle: TextStyle( fontWeight: FontWeight.bold, fontSize: 13), tabs:_tabbarItem() ),

       

      posted @ 2021-02-16 12:06  淡然吖  閱讀(5290)  評論(1)    收藏  舉報
      主站蜘蛛池模板: 亚洲精品中文综合第一页| 厨房与子乱在线观看| 亚洲国产超清无码专区| 亚洲精品人妻中文字幕| 成人无码午夜在线观看| 亚洲日本欧洲二区精品| 蜜臀av一区二区精品字幕| 2020国产成人精品视频| 久久精品国产99久久美女| 日韩av中文字幕有码| 合肥市| 国产精品无码免费播放| 亚洲欧美在线综合一区二区三区| 亚洲韩国精品无码一区二区三区| 青草成人精品视频在线看| 国产欧美精品一区aⅴ影院| 自拍偷自拍亚洲精品熟妇人| 欧美大胆老熟妇乱子伦视频| 蜜臀久久精品亚洲一区| 精品激情视频一区二区三区| 国产精品欧美福利久久| 激情综合网激情五月激情| 手机看片AV永久免费| 日本高清中文字幕免费一区二区| 国产玖玖视频| 亚洲精品久久久久久下一站| 给我播放片在线观看| 99久久99这里只有免费费精品| 国产成人av乱码在线观看| 老熟女熟妇一区二区三区| 亚洲国产在一区二区三区| 日韩人妻无码精品久久| 日韩高清砖码一二区在线| 野花社区视频www官网| 亚洲色欲在线播放一区二区三区 | 国产免费高清69式视频在线观看| 大渡口区| 国产伦精品一区二区亚洲| 亚洲精品无amm毛片| 日韩熟妇中文色在线视频| 97欧美精品系列一区二区|