Created
October 5, 2020 09:06
-
-
Save pavittarx/f19da3d75bda0e05d6e0f976864ec9b2 to your computer and use it in GitHub Desktop.
Flutter State
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
// View in DartPad: https://dartpad.dev/f19da3d75bda0e05d6e0f976864ec9b2 | |
import 'package:flutter/material.dart'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: TestWidget(), | |
), | |
), | |
); | |
} | |
} | |
class TestWidget extends StatefulWidget { | |
@override | |
_TestWidgetState createState() => _TestWidgetState(); | |
} | |
class _TestWidgetState extends State<TestWidget> { | |
int _count = 100; | |
@override | |
Widget build(BuildContext context) { | |
return TextButton( | |
child: Text("Hello Stooart!! $_count"), | |
onPressed: () { | |
setState(() { | |
this._count -= 1; | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment