Skip to content

Instantly share code, notes, and snippets.

@romanejaquez
Created March 17, 2022 23:46
Show Gist options
  • Save romanejaquez/73eef48cb76900b88c3726b1f8acade0 to your computer and use it in GitHub Desktop.
Save romanejaquez/73eef48cb76900b88c3726b1f8acade0 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class Data {
void save() {}
void load() {}
}
void main() {
runApp(
MaterialApp(
home: Game()
)
);
}
class Game extends StatefulWidget
{
Game({Key? key}) : super(key: key);
static Data data = Data();
static int counter = 0;
@override
_GameState createState() => _GameState();
}
class _GameState extends State<Game>
{
int counter2 = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Meh',
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(Game.counter.toString(), ),
Text(counter2.toString(), ),
OutlinedButton(
onPressed: () {
counter2++;
Game.counter++;
print(counter2);
print(Game.counter);
Game.data.save();
setState(() {});
},
child: Text("SAVE"),
),
OutlinedButton(
onPressed: () {
Game.data.load();
setState(() {});
},
child: Text("LOAD"),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment