50 lines
1.6 KiB
Dart
50 lines
1.6 KiB
Dart
/// 自定义公共样式
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class FStyle {
|
|
// 模拟Badge
|
|
static badge(int count, {
|
|
Color color = Colors.red,
|
|
bool isdot = false,
|
|
double height = 16.0,
|
|
double width = 16.0
|
|
}) {
|
|
final num = count > 99 ? '99+' : count;
|
|
return Container(
|
|
alignment: Alignment.center,
|
|
height: isdot ? height / 2 : height,
|
|
width: isdot ? width / 2 : width,
|
|
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(100.00)),
|
|
child: isdot ? null : Text('$num', style: const TextStyle(color: Colors.white, fontSize: 10.0,)),
|
|
);
|
|
}
|
|
// 边框
|
|
static const border = Divider(color: Color(0xFFBBBBBB), height: 1.0, thickness: .5,);
|
|
|
|
// 颜色
|
|
static const backgroundColor = Color(0xFFEEEEEE);
|
|
static const primaryColor = Color(0xFFFF5000);
|
|
static const white = Colors.white;
|
|
static const c999 = Color(0xFF999999);
|
|
|
|
// 间距
|
|
static mt(double v) => EdgeInsets.only(top: v);
|
|
static mb(double v) => EdgeInsets.only(bottom: v);
|
|
static ml(double v) => EdgeInsets.only(left: v);
|
|
static mr(double v) => EdgeInsets.only(right: v);
|
|
static mlr(double v) => EdgeInsets.symmetric(horizontal: v);
|
|
static mtb(double v) => EdgeInsets.symmetric(vertical: v);
|
|
static margin(double v) => EdgeInsets.all(v);
|
|
|
|
// 自定义iconfont图标
|
|
static iconfont(int codePoint, {double size = 16.0, Color? color}) {
|
|
return Icon(
|
|
IconData(codePoint, fontFamily: 'iconfont', matchTextDirection: true),
|
|
size: size,
|
|
color: color,
|
|
);
|
|
}
|
|
}
|