Reputation: 13
Here's a flutter package called circular_countdown_timer , I want to change its timer state by giving a custom variable, to make it clear I've created a simple page which containing just the very widget and a button to change its state ! For testing also I've put a color changer which is working fine but the timer variable is not changing. Could you please teach me more on how to resolve this kind of issue? Thank you in advance
import 'package:circular_countdown_timer/circular_countdown_timer.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Color fillColor = Colors.black;
int duration = 500;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularCountDownTimer(
isReverse: true,
textStyle: TextStyle(fontSize: 40),
strokeWidth: 13,
width: 200,
height: 200,
duration: duration,
fillColor: fillColor,
ringColor: Colors.blue),
Padding(
padding: const EdgeInsets.all(28.0),
child: ElevatedButton(
onPressed: () {
setState(() {
fillColor = fillColor == Colors.redAccent
? Colors.black
: Colors.redAccent;
duration = duration == 800 ? 500 : 800;
});
},
child: Text('Press !')),
)
],
),
),
);
}
}
Upvotes: 0
Views: 40