timer_stop_watch

Creator: coderz1093

Last updated:

0 purchases

timer_stop_watch Image
timer_stop_watch Images

Languages

Categories

Add to Cart

Description:

timer stop watch

timer_stop_watch #
You can freely use a timer and a stopwatch.

Installation #
Add this to your package's pubspec.yaml file:
dependencies:
timer_stop_watch:
copied to clipboard
Use #
import 'package:timer_stop_watch/timer_stop_watch.dart'; // Import timer_stop_watch

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
final _timerStopWatch = TimerStopWatch(); // Create timer_stop_watch instance.
late Stream<String> _timer; // Create a timer variable.
late Stream<String> _stopwatch; // Create a Stopwatch variable

@override
void initState() {
super.initState();
_timer = _timerStopWatch.setTimer(hour: 1, minute: 1, seconds: 10, timeFormat: "hh:mm:ss"); // Timer initialization
_stopwatch = _timerStopWatch.setStopwatch(timeFormat: "hh:mm:ss"); // Stopwatch initialization
}

@override
void dispose() {
await _timerStopWatch.dispose(); // Need to call dispose function.
super.dispose();
}

@override
Widget build(BuildContext context) {
...
StreamBuilder( // StreamBuilder must be used.
stream: _timer,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data.toString());
} else if (snapshot.hasError) {
print(snapshot.error);
return SizedBox();
} else {
return CircularProgressIndicator();
}
}),
...
}
}
copied to clipboard
And Timer And Stopwatch Start
ElevatedButton(
onPressed: (){_timerStopWatch.startTimer();},
child: Text("start"),
),
copied to clipboard
ElevatedButton(
onPressed: (){_timerStopWatch.startStopwatch();},
child: Text("start"),
),
copied to clipboard
or To start the timer&stopwatch immediately
_timer = _timerStopWatch.setTimer(hour: 1, minute: 1, seconds: 10, timeFormat: "hh:mm:ss", start: true);
copied to clipboard
_stopwatch = _timerStopWatch.setStopwatch(timeFormat: "hh:mm:ss", start: true);
copied to clipboard
Timer And Stopwatch Pause
ElevatedButton(
onPressed: (){_timerStopWatch.pauseTimer();},
child: Text("pause"),
),
copied to clipboard
ElevatedButton(
onPressed: (){_timerStopWatch.pauseStopwatch();},
child: Text("pause"),
),
copied to clipboard
Timer And Stopwatch Reset
ElevatedButton(
onPressed: (){_timerStopWatch.resetTimer();},
child: Text("Reset"),
),
copied to clipboard
ElevatedButton(
onPressed: (){_timerStopWatch.resetStopwatch();},
child: Text("Reset"),
),

copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.