otp_count_down 1.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

otp_count_down #

Easily implement the count down timer in Flutter Application.

Usage #

Import package:otp_count_down/otp_count_down.dart

Example:

import 'package:otp_count_down/otp_count_down.dart';

OTPCountDown _otpCountDown; // create instance
final int _otpTimeInMS = 1000 * 5 * 60;  // time in milliseconds for count down

_otpCountDown = OTPCountDown.startOTPTimer(
    timeInMS: _otpTimeInMS, // time in milliseconds
    currentCountDown: (String countDown) {
        print("Count down : $countDown"); // shows current count down time
    },
    onFinish: () {
        print("Count down finished!"); // called when the count down finishes.
    },
);

You will find links to the API docs on the pub page.

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

[1.0.6] - initial release. #

  • FIXED minor bugs
  • Added Licence

[1.0.5] - initial release. #

  • Added README

[1.0.4] - initial release. #

  • Added example

[1.0.3] - initial release. #

  • Added onFinish callback

[1.0.2] - initial release. #

  • Improved stability

[1.0.1] - initial release. #

  • Added option for cancelling timer.

[1.0.0] - initial release. #

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:otp_count_down/otp_count_down.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'OTP Count Down Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _countDown;
  OTPCountDown _otpCountDown;
  final int _otpTimeInMS = 1000 * 5 * 60;

  @override
  void initState() {
    _startCountDown();
    super.initState();
  }

  void _startCountDown() {
    _otpCountDown = OTPCountDown.startOTPTimer(
      timeInMS: _otpTimeInMS,
      currentCountDown: (String countDown) {
        _countDown = countDown;
        setState(() {});
      },
      onFinish: () {
        print("Count down finished!");
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text("OTP Count Down"),
      ),
      body: Center(
        child: Text(
          _countDown,
          style: TextStyle(
            color: Colors.black,
            fontSize: MediaQuery.of(context).size.height * 0.04,
            fontWeight: FontWeight.bold,
          ),
        ),
      ), 
    );
  }

  @override
  void dispose() {
    _otpCountDown.cancelTimer();
    super.dispose();
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  otp_count_down: ^1.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:otp_count_down/otp_count_down.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

4 out of 4 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test