From 80d919f5dfa73fa89d6ea4ffea85d85767b98716 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 17 Dec 2020 16:49:04 +0800 Subject: [PATCH] add text extension --- lib/ansu_ui.dart | 1 + lib/extension/string_extension.dart | 4 ++++ lib/extension/text_style_extension.dart | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100644 lib/extension/text_style_extension.dart diff --git a/lib/ansu_ui.dart b/lib/ansu_ui.dart index 194a57a..0c2adb5 100644 --- a/lib/ansu_ui.dart +++ b/lib/ansu_ui.dart @@ -48,6 +48,7 @@ export 'utils/screen_adapter.dart'; export 'extension/num_extension.dart'; export 'extension/widget_extension.dart'; export 'extension/string_extension.dart'; +export 'extension/text_style_extension.dart'; //`BOTTOM` is external lib export 'package:flutter_screenutil/flutter_screenutil.dart'; diff --git a/lib/extension/string_extension.dart b/lib/extension/string_extension.dart index 37749d8..d950fce 100644 --- a/lib/extension/string_extension.dart +++ b/lib/extension/string_extension.dart @@ -1,3 +1,5 @@ +import 'package:flutter/material.dart'; + extension PhoneExt on String { List get _parsePhone { if (this.length < 11) @@ -28,4 +30,6 @@ extension PhoneExt on String { else return '${_parsePhone[0]}****${_parsePhone[2]}'; } + + Widget get text => Text(this); } diff --git a/lib/extension/text_style_extension.dart b/lib/extension/text_style_extension.dart new file mode 100644 index 0000000..8cc887c --- /dev/null +++ b/lib/extension/text_style_extension.dart @@ -0,0 +1,8 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +extension TextStyleExtension on TextStyle { + TextStyle get bold => this.copyWith(fontWeight: FontWeight.bold); + TextStyle size(double size) => this.copyWith(fontSize: size.w); + TextStyle color(Color color) => this.copyWith(color: color); +}