0

The Drawer work perfectly, but after I add tab bar in the main page. The navigator from drawer to other page get error 'noSuchMethodError: the method '*' was called on null'. I mean, when click the listTile from drawer. It lead to that error.

This is my code

    @override
Widget build(BuildContext context) {
        return Scaffold(
            appBar: AppBar(
              backgroundColor: getTitleFontColor(),
              centerTitle: true,
              title: appBarTitle,
            ),
            drawer: new Drawer(
              child: 
                _drawerLeft(context),
            ),
            body: 
              new DefaultTabController(
              length: 3,
              child: new Scaffold(
                appBar: new AppBar(
                  actions: <Widget>[],
                  title:
                    TabBar(
                      isScrollable: true,
                      unselectedLabelColor: Colors.white.withOpacity(0.3),
                      indicatorColor: Colors.white,
                      tabs: [
                        Tab(
                          child: Text('A'),
                        ),
                        Tab(
                          child: Text('B'),
                        ),
                        Tab(
                          child: Text('C'),
                        ),
                      ]
                    ),
                ),
                body: TabBarView(
                  children: <Widget>[
                    Container(
                      //A,
                    ),
                    Container(
                      child: ListView(
                        children:<Widget>[
                            Column(children: <Widget>[
                              // B,
                            ],)
                        ])
                    ),
                    Container(
                      child: ListView(
                        children:<Widget>[
                            Column(children: <Widget>[
                              // C
                            ],)
                        ])
                    ),                   
                  ],
            ),
          )
        ),
        // ),
      );
    }

My _drawerLeft()

return Column(
    mainAxisSize: MainAxisSize.min,
    mainAxisAlignment: MainAxisAlignment.spaceAround,
    crossAxisAlignment: CrossAxisAlignment.start,
    children: <Widget>[
         ListTile(
              leading: Icon(Icons.credit_card,color: getTitleFontColor()),
              title: Text(
                "A",
                style: TextStyle(
                  color: getTitleFontColor(), fontSize: 16
                )
              ),
              onTap: () => {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => APage()),
              ),
              },
      ),

])

Is it I use the navigator wrong? Can someone help please.

syareen
  • 328
  • 2
  • 4
  • 15

0 Answers0