inclination_time_rus 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

inclination_time_rus #

Package для склонения времени и получения разницы во времени

Использование #

Модель

class TimerCustom{
  int day;
  int hour;
  int minutes;
  int seconds;
  TimerCustom(this.day, this.hour, this.minutes,this.seconds);
}

Основные методы #

Получение разницы во времени(eventStartDate - дата начала события). Возвращает TimerCustom.

TimerCustom getDifferenceTime(DateTime eventStartDate)

Используется для получения строки - дней/дня/день:

String getStrDay(int day)

Для склонения часов:

String getStrHours(int hours)

Для склонения минут:

String getStrMinute(int minut)

Для склонения секунд:

String getStrSeconds(int sec)

Пример

[0.0.1] - Release.

  • TODO: Describe initial release.

[0.0.2] - Fix description.

  • TODO: Fix description.

example/example.dart

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

void main() {
  runApp(
    Timer(),
  );
}

//Inclinator can be used to create a reverse timer

class Timer extends StatefulWidget {
  @override
  _TimerState createState() => _TimerState();
}

class _TimerState extends State<Timer> with TickerProviderStateMixin {
  AnimationController _animationController;

  TimerCustom timer;

  DateTime _eventStartDate = DateTime.utc(2019, 8, 24, 00, 00, 00);
  Duration getDifference() =>
      _eventStartDate.difference(DateTime.now().toUtc());

  void updateTimer() async {
    while (mounted) {
      await Future<void>.delayed(Duration(minutes: 1), () {
        if (mounted) {
          setState(() {
            createTimer();
          });
        }
      });
    }
  }

  void createTimer() {
    setState(() {
      if(timer.getDifferenceTime(_eventStartDate).seconds < 0){
        timer = TimerCustom(00,00,00,00);
      }else{
        timer = timer.getDifferenceTime(_eventStartDate);
      }
    });
  }

  @override
  void initState() {
    super.initState();
    _animationController =
        AnimationController(vsync: this, duration: Duration(seconds: 1));
    _animationController.addStatusListener((status) {
      if (status == AnimationStatus.completed) {
        _animationController.reverse();
      } else if (status == AnimationStatus.dismissed) {
        _animationController.forward();
      }
    });
    _animationController.forward();
    createTimer();
    updateTimer();
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: Column(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 54),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Column(
                    children: <Widget>[
                      Text(
                        '${timer.day}',
                        style: TextStyle(
                          fontSize: 44,
                          color: Colors.blue,
                        ),
                      ),
                      Text(
                        '${getStrDay(timer.day)}',
                        style: TextStyle(
                          fontSize: 14,
                          color: Colors.blue,
                        ),
                      ),
                    ],
                  ),
                  SizedBox(width: 5),
                  FadeTransition(
                    opacity: _animationController,
                    child: Transform.translate(
                      offset: Offset(0, -8),
                      child: Text(':',
                        style: TextStyle(
                          fontSize: 38,
                          color: Colors.blue,
                        )
                      ),
                    ),
                  ),
                  SizedBox(width: 5),
                  Column(
                    children: <Widget>[
                      Text(
                        '${timer.hour}',
                        style: TextStyle(
                          fontSize: 44,
                          color: Colors.blue,
                        ),
                      ),
                      Text('${getStrHours(timer.hour)}',
                        style: TextStyle(
                          fontSize: 14,
                          color: Colors.blue,
                        )
                      ),
                    ],
                  ),
                  SizedBox(width: 5),
                  FadeTransition(
                    opacity: _animationController,
                    child: Transform.translate(
                      offset: Offset(0, -8),
                      child: Text(':',
                        style: TextStyle(
                          fontSize: 38,
                          color: Colors.blue,
                        )
                      ),
                    ),
                  ),
                  SizedBox(width: 5),
                  Column(
                    children: <Widget>[
                      Text(
                        '${timer.minutes}',
                        style: TextStyle(
                          fontSize: 44,
                          color: Colors.blue,
                        ),
                      ),
                      Text('${getStrMinute(timer.minutes)}',
                        style: TextStyle(
                          fontSize: 14,
                          color: Colors.blue,
                        )
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  inclination_time_rus: ^0.0.2

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:inclination_time_rus/inclination_time_rus.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

We analyzed this package on Oct 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

17 out of 17 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.

Format lib/inclination_time_rus.dart.

Run flutter format to format lib/inclination_time_rus.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the 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.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test