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