From db242632c1e9ae35ef506948f1dd8860e2774c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDaniel?= <“dgarcia@biblioeteca.com”> Date: Tue, 21 Dec 2021 10:25:35 +0100 Subject: [PATCH] I have added the functionality to change the styles of the text under the button --- lib/swipebuttonflutter.dart | 16 +++++++++++----- pubspec.lock | 10 +++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/swipebuttonflutter.dart b/lib/swipebuttonflutter.dart index 4812703..1cfb081 100644 --- a/lib/swipebuttonflutter.dart +++ b/lib/swipebuttonflutter.dart @@ -20,6 +20,7 @@ class SwipingButton extends StatefulWidget { final Color backgroundColor; final Color iconColor; TextStyle? buttonTextStyle; + TextStyle? insideTextStyle; final EdgeInsets padding; /// The decimal percentage of swiping in order for the callbacks to get called, defaults to 0.75 (75%) of the total width of the children. @@ -35,6 +36,7 @@ class SwipingButton extends StatefulWidget { this.padding = const EdgeInsets.fromLTRB(0, 0, 0, 0), this.iconColor = Colors.white, this.buttonTextStyle, + this.insideTextStyle, this.swipePercentageNeeded, }) : super(key: key); @@ -47,7 +49,8 @@ class SwipingButton extends StatefulWidget { swipeButtonColor: this.swipeButtonColor, backgroundColor: this.backgroundColor, iconColor: this.iconColor, - buttonTextStyle: this.buttonTextStyle); + buttonTextStyle: this.buttonTextStyle, + insideTextStyle: this.insideTextStyle); } class StateSwipingButton extends State { @@ -63,6 +66,7 @@ class StateSwipingButton extends State { final Color backgroundColor; final Color iconColor; TextStyle? buttonTextStyle; + TextStyle? insideTextStyle; final EdgeInsets padding; StateSwipingButton({ @@ -75,6 +79,7 @@ class StateSwipingButton extends State { this.backgroundColor = Colors.black, this.iconColor = Colors.white, this.buttonTextStyle, + this.insideTextStyle, }); @override @@ -83,6 +88,10 @@ class StateSwipingButton extends State { buttonTextStyle = TextStyle( fontSize: 16.0, fontWeight: FontWeight.w800, color: Colors.white); } + if (insideTextStyle == null) { + insideTextStyle = TextStyle( + fontSize: 16.0, fontWeight: FontWeight.w800, color: Colors.white); + } return Container( width: MediaQuery.of(context).size.width, padding: padding, @@ -96,10 +105,7 @@ class StateSwipingButton extends State { child: new Center( child: Text( text.toUpperCase(), - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w800, - color: Colors.white), + style: insideTextStyle, maxLines: 1, overflow: TextOverflow.ellipsis, ), diff --git a/pubspec.lock b/pubspec.lock index 49a0ce6..8077d23 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -73,7 +73,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: @@ -92,7 +92,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -127,7 +127,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.2" typed_data: dependency: transitive description: