timestamp_time_ago 0.0.2 copy "timestamp_time_ago: ^0.0.2" to clipboard
timestamp_time_ago: ^0.0.2 copied to clipboard

Convert timestamp type data to time ago and time later.

timestamp_time_ago #

Example #

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:timestamp_time_ago/timestamp_time_ago.dart';
import 'package:firebase_core/firebase_core.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Sohbet',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primarySwatch: Colors.cyan),
      home: MyHomePage(),
    );
  }
}


class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: StreamBuilder<QuerySnapshot>(
        stream: FirebaseFirestore.instance.collection('hello').snapshots(),
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            return new GridView.builder(
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    childAspectRatio: (1 / 1), crossAxisCount: 2),
                itemCount: snapshot.data.docs.length,
                itemBuilder: (context, index) {
                  return Container(
                  margin: EdgeInsets.all(5),                   
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓                                                
                        TimeStampTimeAgo(
                          timeStampData:
                              snapshot.data.docs[index].data()['activitytime'],
                        ),
                        //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
                      ],
                    ),
                    padding: EdgeInsets.all(10),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(10),
                      color: Colors.cyan,
                    ),
                  );
                });
          } else {
            return Center(child: CircularProgressIndicator());
          }
        },
      ),
    );
  }
}

Use this Widget #

                     TimeStampTimeAgo(
                          timeStampData:
                              snapshot.data.docs[index].data()['activitytime'],
                        ),

Output #

Others #

                    TimeStampTimeAgo(
                          timeStampData: snapshot.data.docs[index].data()['activitytime'],
                          yearAgo: 'yıl önce',
                          monthAgo: 'ay önce',
                          dayAgo: 'gün önce',
                          hourAgo: 'saat önce',
                          minuteAgo: 'dakika önce',
                          minuteLater: 'dakika sonra',
                          hourLater: 'saat sonra',
                          dayLater: 'gün sonra',
                          monthLater: 'ay sonra',
                          yearLater: 'yıl sonra',
                          textFontSize: 20,
                          textColor: Colors.purple,
                          textFontWeight: FontWeight.bold,
                          fontFamily: 'Klavika',
                        ),

Output #

2
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Convert timestamp type data to time ago and time later.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on timestamp_time_ago