When I start with a very short duration, such as 1 second, and then use Get to switch the time to a longer duration, SlideCountdown will not be displayed. If the initial time is relatively long, such as 10 seconds, SlideCountdown will work.
Did I do something wrong?
class TestCountdownController extends GetxController {
// set to a short time like 2, when get update, it's not working
// set to a long time, like 10, when get update, it's working well
int seconds = 3;
@override
void onInit() {
Future.delayed(Duration(seconds: 5), () {
print('set to long time');
seconds = 9999;
update();
});
super.onInit();
}
}
class TestCountdown extends StatelessWidget {
const TestCountdown({super.key});
Hi, there
When I start with a very short duration, such as 1 second, and then use Get to switch the time to a longer duration, SlideCountdown will not be displayed. If the initial time is relatively long, such as 10 seconds, SlideCountdown will work. Did I do something wrong?
`import 'package:flutter/material.dart'; import 'package:get/get.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: TestCountdown(), ); } }
class TestCountdownController extends GetxController { // set to a short time like 2, when get update, it's not working // set to a long time, like 10, when get update, it's working well int seconds = 3;
@override void onInit() { Future.delayed(Duration(seconds: 5), () { print('set to long time'); seconds = 9999; update(); }); super.onInit(); } }
class TestCountdown extends StatelessWidget { const TestCountdown({super.key});
@override Widget build(BuildContext context) { return Scaffold( body: GetBuilder(
init: TestCountdownController(),
global: false,
builder: () {
return Container(
width: 400,
height: 400,
child: Center(
child: SlideCountdown(
duration: Duration(seconds: .seconds),
),
),
);
},
),
);
}
}
`