time_difference 0.1.3+1 copy "time_difference: ^0.1.3+1" to clipboard
time_difference: ^0.1.3+1 copied to clipboard

Plugin returns time interval as 1 min ago, 2 hours ago, 2 days ago and Dec 20, 2020 for more than 2 days.

example/lib/example.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Time Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
          child: Column(children: [
        Text(DateTime.now().toString()),
        SizedBox(width: 12.0),

        //This time format is the default format (2020-12-08 13:29:54.47452) of DateTime.now()
        //Store in same format and later Compare on same format
        Text(timeAgo("2020-12-08 13:29:54.47452"))
      ])),
    );
  }
}
7
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Plugin returns time interval as 1 min ago, 2 hours ago, 2 days ago and Dec 20, 2020 for more than 2 days.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

cupertino_icons, flutter, intl

More

Packages that depend on time_difference