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_screenutil/flutter_screenutil.dart';
import 'text_style_extension.dart';
extension TextExtension on Text {
Text get bold {
return Text(
this.data,
style: this.style.copyWith(fontWeight: FontWeight.bold),
style: this.style?.bold ?? TextStyle().bold,
);
}
Text size(double size) {
return Text(
this.data,
style: this.style.copyWith(fontSize: size.w),
style: this.style?.size(size) ?? TextStyle().size(size),
);
}
Text color(Color color) {
return Text(
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 {
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);
TextStyle colorX(Color color) => this.copyWith(color: color);
}

Loading…
Cancel
Save