Flutter:如何解决选项卡视图中出现的错误?

时间:2018-09-17 13:46:28

标签: flutter flutter-layout

引发了另一个异常:'package:flutter / src / rendering / object.dart':失败的断言:2798行pos 14:'_debugUltimatePreviousSiblingOf(after,equals:_firstChild)':不正确。

我的标签正在工作,但有时会显示此错误。...我的代码在下面

mytab类

class MyTabs {
  final String title;
  final IconData icon;
  final Color color;
  MyTabs({this.title,this.color,this.icon});
}


final List<MyTabs> _tabs = [new MyTabs(title: "Learn",color: Colors.teal[200],icon: Icons.school),
  new MyTabs(title: "Play",color: Colors.blueGrey,icon: Icons.school,),
  new MyTabs(title: "Acitvity Feed",color: Colors.green,icon: Icons.school),
  new MyTabs(title: "Q&A Discussions",color: Colors.orange[200])
  ];
  MyTabs _myHandler ;
  TabController _controller ;
  void initState() {
    super.initState();
    _controller = new TabController(length: 5, vsync: this);
    _myHandler = _tabs[0];
    _controller.addListener(_handleSelected);


 void _handleSelected() {
    setState(() {
      _myHandler= _tabs[_controller.index];
    });
  }

  TabController controller;

我的小部件

bottom: new TabBar(
          controller: _controller,
          tabs: [
            new Tab(icon: new Icon(Icons.school)),
            new Tab(icon: new Icon(Icons.flash_on)),
            new Tab(icon: new Icon(Icons.home)),
            new Tab(icon: new Icon(Icons.message))
          ],
        ),
      ),

      body: new TabBarView(
        controller: _controller,
        children: [
          new learn.Learn(useremail: _useremail,),
          new play.Play(currentuserid: id,currentuseremail: _useremail,currentusername: _username,currentuserimage: _userimage,),
          new Activity.ActivityFeed(currentuserimage: _userimage,currentusername: _username,currrentuserid: id,currentuseremail: _useremail,),
          new qa.QADiscussion(currentusername: _username,currentuseremail: _useremail,currentuserimage: _userimage,uid: id,)
        ],
      ),

    );

我的学习页面代码...它包含一个文本字段...当键盘打开时,尝试转到另一个选项卡,它向我显示错误

 @override
  Widget build(BuildContext context) {

    return new Scaffold(
      resizeToAvoidBottomPadding: false,
        body: Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              IconButton(icon: Icon(Icons.search), onPressed: () {
               setState(() {
                 _text1 = searchController.text.isNotEmpty
                     ? searchController.text
                     : null;
               });
              }),

              Flexible(child: TextField(
                controller: searchController,
                maxLines: 1,
                decoration: new InputDecoration(
                    hintText: "Search", border: InputBorder.none),
              ),),
              searchController != null ? IconButton(
                  icon: Icon(Icons.close), onPressed: (){
                    searchController.clear();
                    setState(() {
                      _text1=searchController.text.isEmpty?null:null;
                    });
              }) : new Container(),

              IconButton(icon:Stack(
                  children: <Widget>[
                    new Icon(
                      Icons.bookmark_border,
                      size: 30.0,
                    ),
                    new Positioned(
                      right: 0.0,
                      top: 0.0,
                      child:
                      numberofitem > 0
                          ?
                      new CircleAvatar(
                        child: new Text(
                          number,
                          style: new TextStyle(
                              fontSize: 11.0, color: Colors.white),
                        ),
                        backgroundColor: Colors.red,
                        radius: 9.0,
                      )
                          : new Container(),
                    ),
                  ]
              ), onPressed: () {
                Navigator.of(context).push(new MaterialPageRoute(builder: (context)=>new BookmarkPage(currentUser: widget.useremail,)));
              }),

            ],
          ),
          new Expanded(
              child: _text1!=null?SecondList(listcategory: _text1.toUpperCase(),):FilstList()
          ),


        ],
      ),
      //floating

    );
  }
}

0 个答案:

没有答案