Last active
January 27, 2020 15:51
-
-
Save isacjunior/1b2b450bd769123ff920bc380cfc24f4 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/widgets.dart'; | |
void main() => runApp(TopWidget()); | |
class TopWidget extends StatefulWidget { | |
@override | |
_TopWidgetState createState() => _TopWidgetState(); | |
} | |
class _TopWidgetState extends State<TopWidget> { | |
int counter = 0; | |
void increment() { | |
setState(() { | |
counter++; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: MiddleWidget(counter), | |
); | |
} | |
} | |
class MiddleWidget extends StatelessWidget { | |
MiddleWidget(this.counter); | |
final int counter; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: BottomWidget(counter), | |
); | |
} | |
} | |
class BottomWidget extends StatelessWidget { | |
BottomWidget(this.counter); | |
final int counter; | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
child: Text(counter.toString()), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment