import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.green, // Set the app's primary theme color
),
debugShowCheckedModeBanner: false,
title: 'CustomScrollView Example',
home: CustomScrollViewExample(),
);
}
}
class CustomScrollViewExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('CustomScrollView Example'),
),
body: CustomScrollView(
slivers: <Widget>[
// SliverAppBar
SliverAppBar(
expandedHeight: 200.0,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
title: Text(
'CustomScrollView', // Title text for the SliverAppBar
style: TextStyle(color: Colors.black, fontSize: 15),
),
background: Image.network(
'https://static.startuptalky.com/2021/06/GeeksforGeeks-StartupTalky.jpg', // Replace with your image URL
fit: BoxFit.cover, // Ensure the image covers the entire space
),
),
),
// SliverList
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return ListTile(
title: Text('Item $index'), // Display list item with index
);
},
childCount: 50, // Number of list items
),
),
],
),
);
}
}