Skip to content

Instantly share code, notes, and snippets.

@bltavares
Last active July 5, 2022 23:05
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 bltavares/ce15a1323e978be7105c17a07571d8ea to your computer and use it in GitHub Desktop.
Save bltavares/ce15a1323e978be7105c17a07571d8ea to your computer and use it in GitHub Desktop.
elegant-sparkle-3214

elegant-sparkle-3214

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(),
body: const MyWidget(),
),
);
}
}
class NoisyText extends StatefulWidget {
final String text;
const NoisyText(this.text, {super.key});
@override
State<NoisyText> createState() => _NoisyTextState();
}
class _NoisyTextState extends State<NoisyText> {
@override
void initState() {
super.initState();
print(widget.text);
}
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
padding: const EdgeInsets.all(50),
child: Text(widget.text,
style: Theme.of(context).textTheme.caption!.copyWith(
color: Colors.red,
)),
);
}
}
class MyWidget extends StatelessWidget {
const MyWidget({Key? key}) : super(key: key);
ScrollController get scroll => ScrollController();
@override
Widget build(BuildContext context) {
return CustomScrollView(
controller: scroll,
slivers: [
SliverList(
delegate: SliverChildListDelegate(
[
ListView.builder(
shrinkWrap: true,
controller: scroll,
itemCount: 1000,
itemBuilder: (context, index) => NoisyText('Hello $index'),
)
],
))
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment