Skip to content

Instantly share code, notes, and snippets.

@faust45
Last active January 24, 2021 10:10
Show Gist options
  • Save faust45/5d7e67a533df542b8fa5f2a01d48a991 to your computer and use it in GitHub Desktop.
Save faust45/5d7e67a533df542b8fa5f2a01d48a991 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'menu/app_drawer.dart';
import 'state.dart';
import 'package:get/get.dart';
void main() {
runApp(MyApp());
}
class AState {
// static List masters = [].obs;
//static List customers = [].obs;
static var counter = 0.obs;
static void inc() {
counter++;
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter UnReal',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
drawer: AppDrawer(),
appBar: AppBar(
title: Text('BooKy'),
),
body: fooWidget(context),
floatingActionButton: FloatingActionButton(
onPressed: () => AState.inc(),
tooltip: 'Increment',
child: Icon(Icons.add),
),
)
);
}
}
var fooWidget = (context) =>
Obx(() =>
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('You have pushed the button this many times:'),
Text("${AState.counter}",
style: Theme.of(context).textTheme.headline4,
),
],
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment