| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import 'package:flutter/services.dart';
- import 'package:location/resource/assets.gen.dart';
- import '../data/consts/payment_type.dart';
- /// 截取后几位
- String stringExpand(String phone) {
- if (phone.length < 4) {
- return phone;
- }
- return phone.substring(phone.length - 4);
- }
- ///截取前几位
- String stringShort(String phone) {
- if (phone.length < 4) {
- return phone;
- }
- return phone.substring(0, 4);
- }
- String userNickName(String? remark, String phoneNumber, bool isIntercept) {
- if (remark != null && remark.isNotEmpty) {
- return isIntercept ? stringShort(remark) : remark;
- } else {
- return isIntercept ? stringExpand(phoneNumber) : phoneNumber;
- }
- }
- String time2TimeDesc(int? timeMillis) {
- if (timeMillis == 0 || timeMillis == null) {
- return "未知";
- }
- int currentTimeMillis = DateTime.now().millisecondsSinceEpoch;
- int timeDiff = currentTimeMillis - timeMillis;
- if (timeDiff < 0) {
- return "刚刚";
- }
- int minute = timeDiff ~/ 60 ~/ 1000;
- if (minute < 60) {
- if (minute == 0) {
- return "刚刚";
- }
- return "$minute分钟前";
- }
- int hour = minute ~/ 60;
- if (hour < 24) {
- return "$hour小时前";
- }
- int day = hour ~/ 24;
- if (day < 30) {
- return "$day天前";
- }
- int month = day ~/ 30;
- if (month < 12) {
- return "$month月前";
- }
- int year = month ~/ 12;
- return "$year年前";
- }
- String addressCheck(String? address) {
- if (address == null || address.isEmpty) {
- return "未开启定位";
- }
- return address;
- }
- void copyToClipboard(String content) {
- Clipboard.setData(ClipboardData(text: content));
- }
|