Skip to content

Instantly share code, notes, and snippets.

@JannieT
Last active October 8, 2024 11:34
Show Gist options
  • Save JannieT/1f214b4142bbc5b5eb3152f99421cef5 to your computer and use it in GitHub Desktop.
Save JannieT/1f214b4142bbc5b5eb3152f99421cef5 to your computer and use it in GitHub Desktop.
Signal Issue
import 'package:flutter/material.dart';
import 'package:signals/signals_flutter.dart';
void main() {
runApp(const CheckApp());
}
class CheckApp extends StatelessWidget {
const CheckApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: WatchDemo(),
);
}
}
class WatchDemo extends StatefulWidget {
const WatchDemo({super.key});
@override
State<WatchDemo> createState() => _WatchDemoState();
}
class _WatchDemoState extends State<WatchDemo> {
int _count = 0;
@override
Widget build(BuildContext context) {
return Watch(
(_) => Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
setState(() {
_count++;
});
},
child: Text('$_count'),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment