nisrulz / flutter-examples

[Examples] Simple basic isolated apps, for budding flutter devs.
https://nisrulz.com/flutter-examples/
Apache License 2.0
6.91k stars 1.66k forks source link

what if we want the data to add on tabbar; #46

Closed Ashbuhrz closed 4 years ago

Ashbuhrz commented 4 years ago

i need the parsed json data to display it on tabbar; can i use listview builder there

nisrulz commented 4 years ago

I don't understand your question. Can you elaborate?

Ashbuhrz commented 4 years ago

I don't understand your question. Can you elaborate?

I want to add data from json to tab bar widget. The json data also conatain nested data which i want to display on the body of the tab bar

nisrulz commented 4 years ago

Not sure what you mean still :man_shrugging:

Based on wild guess, you can do whatever you want when you have parsed the JSON.

For TabBar:

class TabBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: AppBar(
            bottom: TabBar(
              tabs: [
                Tab(icon: Icon(Icons.directions_car)),
                Tab(icon: Icon(Icons.directions_transit)),
                Tab(icon: Icon(Icons.directions_bike)),
              ],
            ),
            title: Text('Tabs Demo'),
          ),
          body: TabBarView(
            children: [
              Text(json[key1]),
              Text(json[key2]),
             Text(json[key3]),
            ],
          ),
        ),
      ),
    );
  }
}

Notice the part where I use Text(json[key1]). Haven't tested this, but this is what I would do.