From e9bf1faebf5977fb172c778d73c5022574f5fad4 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 17 Dec 2020 16:58:55 +0800 Subject: [PATCH] add extension on Text --- lib/extension/text_extension.dart | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/extension/text_extension.dart diff --git a/lib/extension/text_extension.dart b/lib/extension/text_extension.dart new file mode 100644 index 0000000..b64c32a --- /dev/null +++ b/lib/extension/text_extension.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +extension TextExtension on Text { + Text get bold { + return Text( + this.data, + style: this.style.copyWith(fontWeight: FontWeight.bold), + ); + } + + Text size(double size) { + return Text( + this.data, + style: this.style.copyWith(fontSize: size.w), + ); + } + + Text color(Color color) { + return Text( + this.data, + style: this.style.copyWith(color: color), + ); + } +}