From 730d866283020179e6af463ee505f218c41ab491 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 18 Dec 2020 09:33:51 +0800 Subject: [PATCH] update extension --- lib/extension/text_extension.dart | 19 +++++++++++++------ lib/extension/text_style_extension.dart | 13 +++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/extension/text_extension.dart b/lib/extension/text_extension.dart index 966fad5..04e97ea 100644 --- a/lib/extension/text_extension.dart +++ b/lib/extension/text_extension.dart @@ -2,12 +2,10 @@ import 'package:flutter/material.dart'; import 'text_style_extension.dart'; extension TextExtension on Text { - Text get bold { - return Text( - this.data, - style: this.style?.bold ?? TextStyle().bold, - ); - } + Text get bold => Text( + this.data, + style: this.style?.bold ?? TextStyle().bold, + ); Text size(double size) { return Text( @@ -22,4 +20,13 @@ extension TextExtension on Text { style: this.style?.colorX(color) ?? TextStyle().colorX(color), ); } + + Text get white => + Text(this.data, style: this.style?.white ?? TextStyle().white); + + Text get black => + Text(this.data, style: this.style?.black ?? TextStyle().black); + + Text get black65 => + Text(this.data, style: this.style?.black65 ?? TextStyle().black65); } diff --git a/lib/extension/text_style_extension.dart b/lib/extension/text_style_extension.dart index d1983dd..acfb956 100644 --- a/lib/extension/text_style_extension.dart +++ b/lib/extension/text_style_extension.dart @@ -1,8 +1,21 @@ +import 'package:ansu_ui/styles/as_colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; extension TextStyleExtension on TextStyle { + ///Bold text TextStyle get bold => this.copyWith(fontWeight: FontWeight.bold); + + ///size TextStyle size(double size) => this.copyWith(fontSize: size.w); + + ///color TextStyle colorX(Color color) => this.copyWith(color: color); + //specific values + + TextStyle get white => this.copyWith(color: kLightTextColor); + + TextStyle get black => this.copyWith(color: kTextColor); + + TextStyle get black65 => this.copyWith(color: kTextSubColor); }