import 'dart:math'; import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Material App', home: Home(), ); } } final random = Random(); class Home extends StatelessWidget { const Home({super.key}); @override Widget build(BuildContext context) { return DefaultTabController( length: 3, child: Scaffold( drawer: const Drawer(), appBar: AppBar(), body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverList( delegate: SliverChildListDelegate( [ Container(color: Colors.red, height: 100), Container(color: Colors.blue, height: 100), Container(color: Colors.green, height: 100), Padding( padding: const EdgeInsets.all(8.0), child: Material( color: Colors.black, child: TabBar( tabs: [ 'Tab 1', 'Tab 2', 'Tab 3', ].map((e) => Tab(text: e)).toList(), ), ), ), ], ), ), ]; }, body: TabBarView( children: [ 'Tab 1', 'Tab 2', 'Tab 3', ].map( (e) { return Center(child: Text(e)); }, ).toList(), ), )), ); } }