otp_timer 0.0.6 copy "otp_timer: ^0.0.6" to clipboard
otp_timer: ^0.0.6 copied to clipboard

Help you to create timer base features like otp. work with id so it change handle multiple timers.

otp_timer #

Help you to create timer base features like otp. work with id so it change handle multiple timers.

Getting started #

To use this plugin, add otp_timer as a dependency in your pubspec.yaml file.

Usage #

Example


class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const OtpTimerWrapper(
        child: MyHomePage(title: 'Flutter Demo Home Page'),
      ),
    );
  }
}


...

OtpTimer(
    id: id,
    builder: (remainTime) => Text(remainTime.toMinuteAndSecond),
    action: TextButton(
    onPressed: isLoading ? null : _startTimer,
    child: isLoading
        ? const Padding(
            padding: EdgeInsets.all(4),
            child: CircularProgressIndicator.adaptive(),
            )
        : const Text('Start timer'),
    ),
),

...

 void _startTimer() async {
    OtpUtils.timerDuration = Duration(seconds: 10 + Random().nextInt(110));
    setState(() {
      isLoading = true;
    });
    await Future.delayed(const Duration(milliseconds: 2000));
    if (!mounted) return;
    setState(() {
      isLoading = false;
      id = 'ABC';
    });
    context.startTimer(id!);
  }

4
likes
150
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

Help you to create timer base features like otp. work with id so it change handle multiple timers.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bloc, equatable, flutter, flutter_bloc

More

Packages that depend on otp_timer