From 50535d42e25becbe52208634e91500dfa4f9d110 Mon Sep 17 00:00:00 2001 From: BobFactory Date: Wed, 29 May 2024 18:33:11 +0530 Subject: [PATCH 1/2] added base textstyle and tap gesture for rich text --- .../src/screens/rich_text_plus_screen.dart | 18 +++++++++++----- lib/src/widgets/src/rich_text_plus.dart | 21 ++++++++++++++++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/example/lib/src/screens/rich_text_plus_screen.dart b/example/lib/src/screens/rich_text_plus_screen.dart index bee3dc7..6d922f9 100755 --- a/example/lib/src/screens/rich_text_plus_screen.dart +++ b/example/lib/src/screens/rich_text_plus_screen.dart @@ -34,36 +34,44 @@ class RichTextPlusScreen extends StatelessWidget { Widget _buildExample() { return RichTextPlus( + fontSize: 30, texts: [ TextPlus( 'Flutter ', color: Colors.black, fontWeight: FontWeight.normal, - fontSize: 30, ), TextPlus( 'Plus ', color: Colors.red, fontWeight: FontWeight.bold, - fontSize: 30, ), TextPlus( '!', color: Colors.blue, fontWeight: FontWeight.bold, - fontSize: 30, ), TextPlus( '!', color: Colors.green, fontWeight: FontWeight.bold, - fontSize: 30, ), TextPlus( '!', color: Colors.orange, fontWeight: FontWeight.bold, - fontSize: 30, + ), + TextPlus( + '--->>>', + color: Colors.orange, + fontWeight: FontWeight.bold, + textDecorationPlus: TextDecorationPlus( + textDecoration: TextDecoration.underline, + color: Colors.orange, + ), + onTap: (() { + snackBarPlus.show(child: TextPlus("Flutter Plus is Awesome")); + }), ), ], ); diff --git a/lib/src/widgets/src/rich_text_plus.dart b/lib/src/widgets/src/rich_text_plus.dart index c4a4248..d33b488 100755 --- a/lib/src/widgets/src/rich_text_plus.dart +++ b/lib/src/widgets/src/rich_text_plus.dart @@ -1,3 +1,4 @@ +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -27,6 +28,11 @@ class RichTextPlus extends StatelessWidget { final bool? softWrap; final TextAlign? textAlign; + // These are applied as the base style for all children texts. + final Color? color; + final FontWeight? fontWeight; + final double? fontSize; + RichTextPlus({ Key? key, this.maxLines, @@ -37,6 +43,9 @@ class RichTextPlus extends StatelessWidget { this.overflow, this.softWrap = true, this.textAlign, + this.color, + this.fontWeight, + this.fontSize, // this.mainTextStyleX, }) : super(key: key); @@ -67,12 +76,18 @@ class RichTextPlus extends StatelessWidget { textAlign: textAlign ?? TextAlign.start, text: TextSpan( text: '', + style: TextStyle( + color: color, + fontSize: fontSize, + fontWeight: fontWeight, + ), children: texts! .map( (richTextPlus) => TextSpan( - text: richTextPlus.text, - style: richTextPlus.textStyle, - ), + text: richTextPlus.text, + style: richTextPlus.textStyle, + recognizer: TapGestureRecognizer() + ..onTap = richTextPlus.onTap), ) .toList(), ), From 5770c7ed9ca685190f862083dd136973e331b0f5 Mon Sep 17 00:00:00 2001 From: BobFactory Date: Wed, 29 May 2024 20:43:40 +0530 Subject: [PATCH 2/2] bumped intl version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f504c96..a060719 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: flutter: sdk: flutter - intl: ^0.17.0 + intl: ^0.19.0 diacritic: ^0.1.3 shared_preferences: ^2.0.6 path: ^1.8.0