Skip to content

Instantly share code, notes, and snippets.

@pavittarx
Created October 5, 2020 09:06
Show Gist options
  • Save pavittarx/f19da3d75bda0e05d6e0f976864ec9b2 to your computer and use it in GitHub Desktop.
Save pavittarx/f19da3d75bda0e05d6e0f976864ec9b2 to your computer and use it in GitHub Desktop.
Flutter State
// 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