You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
877 B

2 years ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:my_flutter_puzzle/providers.dart';
  4. class TimerTestScreen extends ConsumerWidget {
  5. const TimerTestScreen({Key? key}) : super(key: key);
  6. @override
  7. Widget build(BuildContext context, WidgetRef ref) {
  8. final state = ref.watch(timerNotifierProvider);
  9. return Scaffold(
  10. body: Column(
  11. mainAxisAlignment: MainAxisAlignment.center,
  12. children: [
  13. Text(state),
  14. ElevatedButton(
  15. onPressed: () => ref.read(timerNotifierProvider.notifier).startTimer(),
  16. child: const Text('Start timer'),
  17. ),
  18. ElevatedButton(
  19. onPressed: () => ref.read(timerNotifierProvider.notifier).stopTimer(),
  20. child: const Text('Stop timer'),
  21. ),
  22. ],
  23. ),
  24. );
  25. }
  26. }