Flutter Sliver Tabbar
import 'package:flutter/material.dart';
//Shohel Rana Shanto
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({ Key? key }) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length:4 ,
child: Scaffold(
body: NestedScrollView(headerSliverBuilder: (context,_){
return [
SliverAppBar(
pinned: true,
title: Text('Sliver TabBar'),
backgroundColor: Colors.black87,
bottom: TabBar(tabs: [
Tab(text: 'Grid',),
Tab(text: 'List',),
Tab(text: 'Images',),
Tab(text: 'Color',),
]),
)
];
},
body: TabBarView(children: [
Container(color: Colors.green,child: GridView.count(crossAxisCount: 3,
children:
List.generate(100, (index) =>
Card(color: Colors.amber,child: Text('Grid$index'),)
)
),),
Container(color: Colors.red,child: ListView.builder(
itemCount: 6,
itemBuilder: (context,index){
return Card(
child: ListTile(
title: Text('List$index'),
),
);
}),),
Container(color: Colors.yellow,),
Container(color: Colors.blue,),
]),
),
),
);
}
}
Angry Alpaca