Last active
July 2, 2021 15:18
-
-
Save esDotDev/4604534400907cf52230fb7c62cbc3c5 to your computer and use it in GitHub Desktop.
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 'dart:async'; | |
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatefulWidget { | |
@override | |
_MyWidgetState createState() => _MyWidgetState(); | |
} | |
class _MyWidgetState extends State<MyWidget> { | |
@override | |
void initState() { | |
super.initState(); | |
Timer.periodic(Duration(seconds: 1), (_) => setState(() {})); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Column(children: [ | |
const SomeWidget(), | |
SomeWidget(), | |
]); | |
} | |
} | |
class SomeWidget extends StatelessWidget { | |
const SomeWidget(); | |
@override | |
Widget build(BuildContext context) => Container( | |
height: 100, | |
color: Colors.red.withOpacity( | |
Random().nextDouble(), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment