Skip to content

Instantly share code, notes, and snippets.

@isacjunior
Last active January 27, 2020 15:51
Show Gist options
  • Save isacjunior/1b2b450bd769123ff920bc380cfc24f4 to your computer and use it in GitHub Desktop.
Save isacjunior/1b2b450bd769123ff920bc380cfc24f4 to your computer and use it in GitHub Desktop.
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