This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static String timeAgoSinceDate(String dateString, {bool numericDates = true}) { | |
| DateTime date = DateTime.parse(dateString); | |
| final date2 = DateTime.now(); | |
| final difference = date2.difference(date); | |
| if ((difference.inDays / 365).floor() >= 2) { | |
| return '${(difference.inDays / 365).floor()} years ago'; | |
| } else if ((difference.inDays / 365).floor() >= 1) { | |
| return (numericDates) ? '1 year ago' : 'Last year'; | |
| } else if ((difference.inDays / 30).floor() >= 2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| class SignaturePainter extends CustomPainter { | |
| SignaturePainter(this.points); | |
| final List<Offset> points; | |
| void paint(Canvas canvas, Size size) { | |
| Paint paint = new Paint() | |
| ..color = Colors.black |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension Array { | |
| func unique<T:Hashable>(by: ((Element) -> (T))) -> [Element] { | |
| var set = Set<T>() //Keep unique list in a Set for fast retrieval | |
| var orderedArray = [Element]() //Keeping the unique list of elements but ordered | |
| for value in self { | |
| if !set.contains(by(value)) { | |
| set.insert(by(value)) | |
| orderedArray.append(value) | |
| } | |
| } |
NewerOlder