Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Created August 18, 2023 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtmuller5/013b30bec64c2ec58855e6bfcbecce06 to your computer and use it in GitHub Desktop.
Save jtmuller5/013b30bec64c2ec58855e6bfcbecce06 to your computer and use it in GitHub Desktop.
xenial-performance-6792

xenial-performance-6792

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CustomScrollView(slivers: [
SliverMainAxisGroup(
slivers: [
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'Hello, World!',
style: TextStyle(fontSize: 12),
),
),
),
SliverPersistentHeader(
pinned: true,
floating: false,
delegate: HeaderDelegate(ListTile(
tileColor: darkBlue,
title: Text('Look at these numbers'),
),
),
),
SliverList.builder(
itemCount: 200,
itemBuilder: (context, index) {
return ListTile(title: Text(index.toString()));
}),
SliverToBoxAdapter(
child: Divider(
height: 2,
thickness: 1,
color: Colors.grey.shade300,
),
),
SliverToBoxAdapter(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8),
child: Text('Hello Again!',
style: Theme.of(context).textTheme.bodySmall),
),
),
],
)
]);
}
}
class HeaderDelegate extends SliverPersistentHeaderDelegate {
const HeaderDelegate(this.child);
final Widget child;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return child;
}
@override
double get maxExtent => minExtent;
@override
double get minExtent => 48;
@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment