fixed lint problems
parent
ba1a6e37e7
commit
fe45116beb
|
@ -10,6 +10,6 @@ class MyApp extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(title: _title, home: MyHomePage());
|
return const MaterialApp(title: _title, home: MyHomePage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,17 @@ class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({super.key});
|
const MyHomePage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MyHomePageState createState() => _MyHomePageState();
|
MyHomePageState createState() => MyHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class MyHomePageState extends State<MyHomePage> {
|
||||||
int _selectedIndex = 2;
|
int _selectedIndex = 2;
|
||||||
static final List<Widget> _widgetOptions = <Widget>[
|
static const List<Widget> _widgetOptions = <Widget>[
|
||||||
const MoodPage(),
|
MoodPage(),
|
||||||
const SleepPage(),
|
SleepPage(),
|
||||||
StopWatchTimerPage(),
|
StopWatchTimerPage(),
|
||||||
const RelapsePage(),
|
RelapsePage(),
|
||||||
const SettingsPage(),
|
SettingsPage(),
|
||||||
];
|
];
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
void _onItemTapped(int index) {
|
||||||
|
|
|
@ -3,34 +3,29 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:smoke_cess_app/widgets/timer_button.dart';
|
import 'package:smoke_cess_app/widgets/timer_button.dart';
|
||||||
|
|
||||||
class StopWatchTimerPage extends StatefulWidget {
|
class StopWatchTimerPage extends StatefulWidget {
|
||||||
|
const StopWatchTimerPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_StopWatchTimerPageState createState() => _StopWatchTimerPageState();
|
StopWatchTimerPageState createState() => StopWatchTimerPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
class StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
static const countdownDuration = Duration(minutes: 1);
|
static const countdownDuration = Duration(minutes: 1);
|
||||||
Duration duration = Duration();
|
Duration duration = countdownDuration;
|
||||||
Timer? timer;
|
Timer? timer;
|
||||||
|
|
||||||
bool countDown = true;
|
bool countDown = true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
// TODO: implement initState
|
|
||||||
super.initState();
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
if (countDown) {
|
if (countDown) {
|
||||||
setState(() => duration = countdownDuration);
|
setState(() => duration = countdownDuration);
|
||||||
} else {
|
} else {
|
||||||
setState(() => duration = Duration());
|
setState(() => duration = const Duration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startTimer() {
|
void startTimer() {
|
||||||
timer = Timer.periodic(Duration(seconds: 1), (_) => addTime());
|
timer = Timer.periodic(const Duration(seconds: 1), (_) => addTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTime() {
|
void addTime() {
|
||||||
|
@ -58,7 +53,7 @@ class _StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
buildTime(),
|
buildTime(),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 80,
|
height: 80,
|
||||||
),
|
),
|
||||||
buildButtons()
|
buildButtons()
|
||||||
|
@ -71,11 +66,11 @@ class _StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
final minutes = twoDigits(duration.inMinutes.remainder(60));
|
final minutes = twoDigits(duration.inMinutes.remainder(60));
|
||||||
final seconds = twoDigits(duration.inSeconds.remainder(60));
|
final seconds = twoDigits(duration.inSeconds.remainder(60));
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
),
|
),
|
||||||
buildTimeCard(time: minutes, header: 'MINUTEN'),
|
buildTimeCard(time: minutes, header: 'MINUTEN'),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
),
|
),
|
||||||
buildTimeCard(time: seconds, header: 'SEKUNDEN'),
|
buildTimeCard(time: seconds, header: 'SEKUNDEN'),
|
||||||
|
@ -87,21 +82,21 @@ class _StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white, borderRadius: BorderRadius.circular(20)),
|
color: Colors.white, borderRadius: BorderRadius.circular(20)),
|
||||||
child: Text(
|
child: Text(
|
||||||
time,
|
time,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 50),
|
fontSize: 50),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
),
|
),
|
||||||
Text(header, style: TextStyle(color: Colors.black45)),
|
Text(header, style: const TextStyle(color: Colors.black45)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -111,7 +106,7 @@ class _StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
return isRunning || isCompleted
|
return isRunning || isCompleted
|
||||||
? TimerButton(
|
? TimerButton(
|
||||||
onClicked: stopTimer,
|
onClicked: stopTimer,
|
||||||
icon: Icon(
|
icon: const Icon(
|
||||||
Icons.stop,
|
Icons.stop,
|
||||||
size: 50,
|
size: 50,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
@ -119,7 +114,7 @@ class _StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
color: Colors.red)
|
color: Colors.red)
|
||||||
: TimerButton(
|
: TimerButton(
|
||||||
onClicked: startTimer,
|
onClicked: startTimer,
|
||||||
icon: Icon(
|
icon: const Icon(
|
||||||
Icons.play_arrow,
|
Icons.play_arrow,
|
||||||
size: 50,
|
size: 50,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|
|
@ -12,16 +12,17 @@ class TimerButton extends StatelessWidget {
|
||||||
required this.color})
|
required this.color})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
|
onTap: onClicked,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
backgroundColor: color,
|
backgroundColor: color,
|
||||||
radius: 50,
|
radius: 50,
|
||||||
child: icon,
|
child: icon,
|
||||||
),
|
),
|
||||||
onTap: onClicked,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue