Как я могу реализовать контроллер вкладок на странице с другим компонентом во Flutter? - PullRequest
0 голосов
/ 28 июня 2018

Я хочу добавить контроллер вкладок на страницу с другими компонентами в моем приложении флаттера. как я могу это сделать? когда я добавляю TabBar, все нормально, но когда я добавляю TabBarView, он не работает. Я приложил скриншот страницы. Я хочу сделать это. Как я могу сделать это в приложении флаттера .?

class Details extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
  body: new Center(
    child: new Column(
      children: <Widget>[
        new DropdownButton<String>(
          items: <String>['USD', 'EUR', 'LTC'].map((String value) {
            return new DropdownMenuItem<String>(
              value: value,
              child: new Text(value),
            );
          }).toList(),
          onChanged: (_) {},
          value: 'USD',
        ),
        new Text(
            '\$6,146.76',
          style: new TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 40.0,
            color: Theme.of(context).accentColor,
          ),
        ),
        new Text('Last Updated at'),
        new DefaultTabController(
            length: 2,
            child: new Container(
              child: new Column(
                children: <Widget>[
                  new TabBar(
                    labelColor: Theme.of(context).accentColor,
                      tabs: [
                        new Tab(text: 'General'),
                        new Tab(text: 'Mining'),
                      ]
                  ),
                  new TabBarView(
                    children: [
                      new Tab(child: new General()),
                      new Tab(child: new Mining()),
                    ],
                  ),

                ],
              ),
            )
        )
      ],
    ),
  ),
);
}
}

i want to do like this

1 Ответ

0 голосов
/ 23 мая 2019
          Text("Controls above tabs"),
          DefaultTabController(
            length: 2,
            child: SizedBox(
              height: 100.0,
              child: Column(
                children: <Widget>[
                  TabBar(
                    tabs: <Widget>[
                      Tab(
                        text: "tab1",
                      ),
                      Tab(
                        text: "tab2",
                      )
                    ],
                  ),
                  Expanded(
                    child: TabBarView(
                      children: <Widget>[
                        Container(
                          color: Colors.green,
                        ),
                        Container(
                          color: Colors.yellow,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
...