You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.9 KiB

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/utils.dart';
3 months ago
/// 图片消息的图片URL的HOST
const String chatImageHost = "http://skk8mlm5b.hn-bkt.clouddn.com/";
3 months ago
/// socket的host和port端口
//47.93.216.24:9090 线上 192.168.10.200/192.168.10.129:9090 测试
1 week ago
const String socketHost = kDebugMode ? '192.168.10.200' : '47.93.216.24';
const int socketPort = 9090;
3 months ago
/// 小程序接口的请求地址
1 week ago
const localMiniBaseUrl = "http://192.168.10.54:8765/app/"; ///本地
///线上
/// app接口的请求地址
const serviceMiniBaseUrl = "https://pos.api.yixinhuixiang.com/app/";
///线下
3 months ago
/// app接口的请求地址
1 week ago
const localBaseUrl = "http://192.168.10.54:8766/app/"; ///本地
///线上
const serviceBaseUrl = "https://pos.platform.yixinhuixiang.com/app/";
4 months ago
/// 线上
3 months ago
/// 对list进行分组
4 months ago
Map<S, List<T>> groupBy<S, T>(Iterable<T> values, S Function(T) key) {
var map = <S, List<T>>{};
for (var element in values) {
(map[key(element)] ??= []).add(element);
}
return map;
}
3 months ago
/// 对list进行分组计数
4 months ago
Map<String, int> groupCount<S, T>(Map<S, List<T>> values) {
var map = <String, int>{};
for (var element in values.keys) {
map["$element"] = values[element]?.length ?? 0;
}
return map;
}
3 months ago
/// 对list进行分组并取最大值
Map<String, T> groupItem<S, T>(Map<S, List<T>> values, {int Function(T)? key}) {
4 months ago
var map = <String, T>{};
for (var element in values.keys) {
if (values[element] == null) {
continue;
}
if (values[element]!.isEmpty) {
continue;
}
map["$element"] =
key == null ? values[element]!.first : values[element]!.lMax(key);
4 months ago
}
return map;
}
3 months ago
/// 最大值
4 months ago
T max<T>(Iterable<T> list, int Function(T) key) {
T? tt;
4 months ago
for (T t in list) {
if (tt == null) {
tt = t;
}
if (key(tt!) < key(t)) {
4 months ago
tt = t;
}
}
return tt!;
4 months ago
}
4 months ago
extension ListExtension<S, T> on Iterable<T> {
Map<S, List<T>> lGroupBy(S Function(T) key) {
return groupBy(this, key);
}
4 months ago
T lMax(int Function(T) key) {
return max(this, key);
}
4 months ago
}
extension MapExtension<S, T> on Map<S, List<T>> {
Map<String, int> get mGroupCount => groupCount(this);
Map<String, T> mGroupItem({int Function(T)? key}) {
4 months ago
return groupItem(this, key: key);
}
}
4 months ago
extension StrExtension<S, T> on String {
void get toast => SmartDialog.showToast(
this,
alignment: Alignment.center,
nonAnimationTypes: [
SmartNonAnimationType.continueLoading_nonAnimation,
SmartNonAnimationType.continueKeepSingle,
],
);
void get loading => SmartDialog.showLoading(
msg: this,
displayTime: 25000.milliseconds,
nonAnimationTypes: [
SmartNonAnimationType.continueLoading_nonAnimation,
SmartNonAnimationType.continueKeepSingle,
],
);
void get print => debugPrint(this);
4 months ago
}