update extension

null_safety
小赖 4 years ago
parent 074b48181e
commit 730d866283

@ -2,12 +2,10 @@ import 'package:flutter/material.dart';
import 'text_style_extension.dart'; import 'text_style_extension.dart';
extension TextExtension on Text { extension TextExtension on Text {
Text get bold { Text get bold => Text(
return Text( this.data,
this.data, style: this.style?.bold ?? TextStyle().bold,
style: this.style?.bold ?? TextStyle().bold, );
);
}
Text size(double size) { Text size(double size) {
return Text( return Text(
@ -22,4 +20,13 @@ extension TextExtension on Text {
style: this.style?.colorX(color) ?? TextStyle().colorX(color), 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);
} }

@ -1,8 +1,21 @@
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
extension TextStyleExtension on TextStyle { extension TextStyleExtension on TextStyle {
///Bold text
TextStyle get bold => this.copyWith(fontWeight: FontWeight.bold); TextStyle get bold => this.copyWith(fontWeight: FontWeight.bold);
///size
TextStyle size(double size) => this.copyWith(fontSize: size.w); TextStyle size(double size) => this.copyWith(fontSize: size.w);
///color
TextStyle colorX(Color color) => this.copyWith(color: 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);
} }

Loading…
Cancel
Save