time_parser 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new56

A Dart libraty that parses a time string and returns a time object in order to easily access hours and minutes

Format #

A valid time string has the format:


Usage #

A simple usage example:

Parsing a valid time string

import 'package:time_parser/time_parser.dart';

void main() {
  var time = Time.parse('15:30');
  print('hours: ${time.hours}, minutes: ${time.minutes}');
  // => hours: 15, minutes: 30

An Exception is thrown when time string is not valid

import 'package:time_parser/time_parser.dart';

void main() {
   try {
  } catch(TimeParseException) {
    // => TimeParseException: invalid timeString: xx:xx

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.1.0 2020-01-16 #

  • Add Time.toString
  • Update README.md with a description and update examples

1.0.0 2020-01-14 #

  • TimeParser parses a string of the format HH:MM an return a Time object containing the value for hours and minutes. Both with type int.
  • TimeParser validates input and throws an TimeParseException in case the time string is not a valid time.


import 'package:time_parser/time_parser.dart';

void main() {
  var time = TimeParser.parse('15:30');
  print('hours: ${time.hours}, minutes: ${time.minutes}');

  // invalid time strings cause an TimeParseException
  try {
  } catch(e) {
    print(e); // TimeParseException: invalid timeString: xx:xx

Use this package as a library

1. Depend on it

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

  time_parser: ^1.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:time_parser/time_parser.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Format lib/src/time_parser_base.dart.

Run dartfmt to format lib/src/time_parser_base.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.9.0
test ^1.6.0