Last active
July 12, 2023 09:35
-
-
Save your-diary/3c753f7f4e07cfa87182f77c7f0e7c05 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData( | |
brightness: Brightness.dark, | |
primaryColor: Colors.blueGrey, | |
useMaterial3: true), | |
home: Scaffold(body: W()), | |
debugShowCheckedModeBanner: false, | |
); | |
} | |
} | |
class W extends StatefulWidget { | |
const W({ | |
super.key, | |
}); | |
@override | |
State<W> createState() => _WState(); | |
} | |
class _WState extends State<W> { | |
List<Widget> l = []; | |
@override | |
void initState() { | |
super.initState(); | |
Stream<int> f() async* { | |
for (int i = 0; i < 100; ++i) { | |
await Future.delayed(Duration(seconds: 1)); | |
yield i; | |
} | |
} | |
f().listen((d) { | |
setState( | |
() => this.l.add(Card(child: ListTile(title: Text(d.toString()))))); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
print('build(): ${this.l.length}'); | |
return ListView(children: this.l); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment