在运行时动态更新TabController列表

时间:2019-03-29 10:39:35

标签: dart flutter

我使用Flutter创建Pomodoro计时器应用程序。主页上有日期TabController。

我记录用户第一次使用应用程序的日期到本地JSON文件。当应用启动时,检查JSON文件并获取记录。并计算今天之间的间隔天数,然后我要更新tabcontroller。

结果是正确的日期,我将初始索引设置为list.lenght - 1,但是我设置了任何数字,例如29、4、5、6,下划线是正确的,但综合浏览量不正确。

我认为问题在于在setState中更新tabController,但是我已经尝试了很多次,但都无法正常工作。

有人可以帮我看看出了什么问题吗?感谢您的帮助。

我有这样的代码,但无法正常工作。 Dynamically Updating TabControl Content at Runtime

void initState() {
    super.initState();

    jsonFileHelper = new JsonFileHelper();

    myList.add(DateTime(today.year, today.month, today.day));
    tabController = new TabController(
      length: myList.length,
      vsync: this,
    );

jsonFileHelper.readToFile().then((res) {

        firstDate = DateTime.fromMillisecondsSinceEpoch(res['firstDate']);

        difference = DateTime(today.year, today.month, today.day)
            .difference(firstDate)
            .inDays;

        setState(() {
          myList.clear();
        });

        List<DateTime> tempList = new List();

        for (int i = 0; i <= difference; i++) {
          tempList.add(DateTime(today.year, today.month, today.day - i));
        }

        tempList.forEach((date) {
          myList.insert(0, date);
        });

        setState(() {
          tabController = new TabController(
              length: myList.length,
              vsync: this,
              initialIndex: myList.length - 1);

          tabController.addListener(() {
            animationController.reverse();
          });
        });
      }
    });
}
  // this is build tab function.
_buildTabs(List<DateTime> data) {
  List<Widget> listWidget = new List();

    data.forEach((date) {
      var widget = Container(
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: <Widget>[
              Text(DateFormat('EEE').format(date)),
              Text(
                date.day.toString(),
                style: TextStyle(
                  fontSize: 20.0,
                  color: Colors.black87,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ],
          ),
        ),
      );
      listWidget.add(widget);
    });

    return listWidget;
  }

我希望输出显示在最后一天,但是实际输出是2019-03-01(我设置的第一条记录是2019-2-28)。

enter image description here

enter image description here

I/flutter ( 8122): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 8122): The following assertion was thrown building RawGestureDetector(state:
I/flutter ( 8122): RawGestureDetectorState#dc79e(gestures: [tap], behavior: opaque)):
I/flutter ( 8122): Multiple widgets used the same GlobalKey.
I/flutter ( 8122): The key [GlobalKey#82017] was used by multiple widgets. The parents of those widgets were:
I/flutter ( 8122): - Padding(padding: EdgeInsets(16.0, 0.0, 16.0, 0.0), dependencies: [Directionality], renderObject:
I/flutter ( 8122):   RenderPadding#2875b NEEDS-LAYOUT NEEDS-PAINT DETACHED)
I/flutter ( 8122): - Padding(padding: EdgeInsets(16.0, 0.0, 16.0, 0.0), dependencies: [Directionality], renderObject:
I/flutter ( 8122):   RenderPadding#2f066 NEEDS-LAYOUT NEEDS-PAINT)
I/flutter ( 8122): A GlobalKey can only be specified on one widget at a time in the widget tree.
I/flutter ( 8122): 
I/flutter ( 8122): When the exception was thrown, this was the stack:
I/flutter ( 8122): #0      GlobalKey._debugReserveFor.<anonymous closure> (package:flutter/src/widgets/framework.dart:182:11)
I/flutter ( 8122): #1      GlobalKey._debugReserveFor (package:flutter/src/widgets/framework.dart:200:6)
I/flutter ( 8122): #2      Element.updateChild.<anonymous closure> (package:flutter/src/widgets/framework.dart:2730:13)
I/flutter ( 8122): #3      Element.updateChild (package:flutter/src/widgets/framework.dart:2733:6)
I/flutter ( 8122): #4      SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 8122): #5      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
I/flutter ( 8122): #6      Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
I/flutter ( 8122): #7      SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 8122): #8      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
I/flutter ( 8122): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
I/flutter ( 8122): #10     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4659:32)
I/flutter ( 8122): #11     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #13     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #14     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #15     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #17     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #19     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #20     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #21     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #22     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #23     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #24     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #25     StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #26     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #27     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #28     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #29     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #31     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter ( 8122): #32     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #33     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #34     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #35     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #36     ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #38     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #40     StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #41     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #42     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #43     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #44     ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #45     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #46     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #47     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #48     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #49     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #50     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #51     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #52     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #53     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #54     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #55     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #56     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #57     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #58     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #59     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #60     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #61     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #62     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #63     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #64     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #65     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #66     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #67     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #68     ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #69     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #70     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #71     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #72     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #73     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #74     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #75     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #76     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #77     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #78     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #79     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #80     StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #81     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #82     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #83     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #84     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #85     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #86     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #87     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #88     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #89     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #90     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #91     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #92     StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #93     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #94     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #95     Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #96     StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #97     Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #98     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter ( 8122): #99     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #100    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #101    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #102    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #103    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #104    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #105    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #106    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #107    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #108    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #109    StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #110    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #111    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #112    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #113    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #114    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #115    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #116    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #117    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #118    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #119    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #120    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #121    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #122    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #123    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #124    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #125    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #126    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #127    StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #128    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #129    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #130    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #131    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #132    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #133    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #134    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #135    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): home page datetime: 2019-02-28T00:00:00.000
D/        ( 8122): HostConnection::get() New Host Connection established 0xebd99480, tid 8185
D/EGL_emulation( 8122): eglMakeCurrent: 0xf10dcf60: ver 3 0 (tinfo 0xebd832c0)
I/flutter ( 8122): #136    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #137    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #138    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #139    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #140    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #141    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #142    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #143    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #144    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #145    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #146    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #147    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #148    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #149    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #150    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #151    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #152    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #153    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #154    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #155    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #156    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #157    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #158    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #159    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #160    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #161    RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter ( 8122): #162    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #163    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #164    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #165    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #166    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #167    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #168    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #169    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #170    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #171    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #172    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #173    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #174    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #175    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #176    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #177    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #178    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #179    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #180    StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #181    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #182    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #183    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #184    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #185    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #186    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #187    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #188    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #189    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #190    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #191    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #192    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #193    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #194    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #195    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #196    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #197    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #198    ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #199    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #200    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #201    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #202    StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #203    Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #204    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #205    Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #206    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2273:33)
I/flutter ( 8122): #207    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter ( 8122): #208    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter ( 8122): #209    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter ( 8122): #210    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter ( 8122): #211    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:749:7)
I/flutter ( 8122): #220    _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter ( 8122): #221    _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter ( 8122): #222    _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter ( 8122): (elided 8 frames from package dart:async)
I/flutter ( 8122): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 8122): Another exception was thrown: A RenderFlex overflowed by 99896 pixels on the bottom.

1 个答案:

答案 0 :(得分:0)

我也无法重新定义TabController的长度。

解决方案是仅在TabControllerinitState中创建dispose一次(也仅创建一次)-假装TabController length只是最大长度,如果您认为自己的应用最大数量为100,则使用固定的100。

Please take a look in this answer