Created with <3 with dartpad.dev.
Last active
July 5, 2022 23:05
-
-
Save bltavares/ce15a1323e978be7105c17a07571d8ea 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: 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