Created with <3 with dartpad.dev.
Created
July 5, 2022 23:06
-
-
Save bltavares/ff10c4c8cefa6dd67cbe7fca61f47ba7 to your computer and use it in GitHub Desktop.
elegant-sparkle-3214
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: SliverChildBuilderDelegate( | |
(context, index) => NoisyText('Hello $index'), | |
childCount: 1000, | |
)) | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment