This should be achievable using the sticky_headers plugin.
Lets you place headers on scrollable content that will stick to the
top of the container whilst the content is scrolled.
Here is a simple example on how you can implement this plugin:
import 'package:flutter/material.dart';
import 'package:sticky_headers/sticky_headers.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blueGrey[900],
),
body: ListView.builder(
itemBuilder: (context, index) {
return StickyHeader(
header: Container(
height: 50.0,
color: Colors.blue,
padding: EdgeInsets.symmetric(horizontal: 16.0),
alignment: Alignment.centerLeft,
child: Text(
'Header #$index',
style: const TextStyle(color: Colors.white),
),
),
content: Column(
children: List<int>.generate(5, (index) => index)
.map((item) => Container(
height: 50,
color: Colors.grey[(item + 1) * 100],
))
.toList(),
),
);
},
),
);
}
}
