-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcontrol_duration.dart
117 lines (107 loc) · 3.27 KB
/
control_duration.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import 'package:flutter/material.dart';
import 'package:slide_countdown/slide_countdown.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: SlideCountdownPage(),
);
}
}
class SlideCountdownPage extends StatefulWidget {
const SlideCountdownPage({super.key});
@override
State<SlideCountdownPage> createState() => _SlideCountdownPageState();
}
class _SlideCountdownPageState extends State<SlideCountdownPage> {
late final StreamDuration _streamDuration;
@override
void initState() {
super.initState();
_streamDuration = StreamDuration(
config: const StreamDurationConfig(
countDownConfig: CountDownConfig(
duration: Duration(days: 2),
),
),
);
}
@override
void dispose() {
_streamDuration.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: const Text('Slide Countdown Page'),
),
body: Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(
color:
theme.buttonTheme.colorScheme?.primary ?? Colors.purpleAccent,
),
borderRadius: BorderRadius.circular(10),
),
padding: const EdgeInsets.all(20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
const Text('Control Duration'),
const SizedBox(height: 10),
SlideCountdown(
streamDuration: _streamDuration,
decoration: BoxDecoration(
color: theme.buttonTheme.colorScheme?.primary,
borderRadius: BorderRadius.circular(5),
),
),
const SizedBox(height: 20),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () => _streamDuration.subtract(
const Duration(seconds: 10),
),
child: const Text('- 10 seconds'),
),
const SizedBox(
width: 10,
),
FloatingActionButton.small(
child: const Icon(Icons.pause_rounded),
onPressed: () => _streamDuration.pause(),
),
FloatingActionButton.small(
child: const Icon(Icons.play_arrow_rounded),
onPressed: () => _streamDuration.resume(),
),
const SizedBox(
width: 10,
),
TextButton(
onPressed: () => _streamDuration.add(
const Duration(seconds: 10),
),
child: const Text('+ 10 seconds'),
),
],
),
],
),
),
),
);
}
}