From 52b5ab3d178e55da68b1050a9e5eb6a928bfe732 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Mon, 16 Dec 2024 13:53:15 +0100
Subject: [PATCH] Fix autosize text in buttons

---
 CHANGELOG.md                   |  4 +++
 lib/widgets/styled_button.dart | 63 +++++++++++++++++-----------------
 pubspec.yaml                   |  3 +-
 3 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 867cbdb..34944b9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.1
+
+-   Fix autosized text in styled buttons
+
 ## 0.8.0
 
 -   Allow multiline parameter item
diff --git a/lib/widgets/styled_button.dart b/lib/widgets/styled_button.dart
index 2b07991..a940d0e 100644
--- a/lib/widgets/styled_button.dart
+++ b/lib/widgets/styled_button.dart
@@ -2,8 +2,6 @@ import 'dart:math';
 
 import 'package:flutter/material.dart';
 
-import 'package:auto_size_text/auto_size_text.dart';
-
 import 'package:flutter_custom_toolbox/utils/color_extensions.dart';
 
 class StyledButton extends StatelessWidget {
@@ -27,35 +25,38 @@ class StyledButton extends StatelessWidget {
     required String caption,
     required Color color,
   }) {
-    final Widget captionWidget = AutoSizeText(
-      caption,
-      maxLines: 1,
-      style: TextStyle(
-        inherit: true,
-        fontWeight: FontWeight.w900,
-        color: color.darken(60),
-        shadows: [
-          Shadow(
-            blurRadius: 5.0,
-            color: color.lighten(60),
-            offset: const Offset(2, 2),
-          ),
-          Shadow(
-            blurRadius: 5.0,
-            color: color.lighten(60),
-            offset: const Offset(2, -2),
-          ),
-          Shadow(
-            blurRadius: 5.0,
-            color: color.lighten(60),
-            offset: const Offset(-2, 2),
-          ),
-          Shadow(
-            blurRadius: 5.0,
-            color: color.lighten(60),
-            offset: const Offset(-2, -2),
-          ),
-        ],
+    final Widget captionWidget = FittedBox(
+      fit: BoxFit.scaleDown,
+      child: Text(
+        caption,
+        style: TextStyle(
+          inherit: true,
+          fontSize: 99,
+          fontWeight: FontWeight.w900,
+          color: color.darken(60),
+          shadows: [
+            Shadow(
+              blurRadius: 5.0,
+              color: color.lighten(60),
+              offset: const Offset(2, 2),
+            ),
+            Shadow(
+              blurRadius: 5.0,
+              color: color.lighten(60),
+              offset: const Offset(2, -2),
+            ),
+            Shadow(
+              blurRadius: 5.0,
+              color: color.lighten(60),
+              offset: const Offset(-2, 2),
+            ),
+            Shadow(
+              blurRadius: 5.0,
+              color: color.lighten(60),
+              offset: const Offset(-2, -2),
+            ),
+          ],
+        ),
       ),
     );
 
diff --git a/pubspec.yaml b/pubspec.yaml
index d98c827..8707a1a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@ description: "Flutter custom toolbox for org.benoitharrault.* projects."
 
 publish_to: "none"
 
-version: 0.8.0
+version: 0.8.1
 
 homepage: https://git.harrault.fr/android/flutter-toolbox
 
@@ -16,7 +16,6 @@ dependencies:
     sdk: flutter
 
   # base
-  auto_size_text: ^3.0.0
   easy_localization: ^3.0.1
   equatable: ^2.0.5
   flutter_bloc: ^8.1.1
-- 
GitLab