fix text extension issue

null_safety
小赖 4 years ago
parent 71fb40a28e
commit 074b48181e

@ -1,25 +1,25 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'text_style_extension.dart';
extension TextExtension on Text { extension TextExtension on Text {
Text get bold { Text get bold {
return Text( return Text(
this.data, this.data,
style: this.style.copyWith(fontWeight: FontWeight.bold), style: this.style?.bold ?? TextStyle().bold,
); );
} }
Text size(double size) { Text size(double size) {
return Text( return Text(
this.data, this.data,
style: this.style.copyWith(fontSize: size.w), style: this.style?.size(size) ?? TextStyle().size(size),
); );
} }
Text color(Color color) { Text color(Color color) {
return Text( return Text(
this.data, this.data,
style: this.style.copyWith(color: color), style: this.style?.colorX(color) ?? TextStyle().colorX(color),
); );
} }
} }

@ -4,5 +4,5 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
extension TextStyleExtension on TextStyle { extension TextStyleExtension on TextStyle {
TextStyle get bold => this.copyWith(fontWeight: FontWeight.bold); TextStyle get bold => this.copyWith(fontWeight: FontWeight.bold);
TextStyle size(double size) => this.copyWith(fontSize: size.w); TextStyle size(double size) => this.copyWith(fontSize: size.w);
TextStyle color(Color color) => this.copyWith(color: color); TextStyle colorX(Color color) => this.copyWith(color: color);
} }

Loading…
Cancel
Save