iampawan / VelocityX

A minimalist Flutter framework for rapidly building Flutter apps.
https://velocityx.dev
MIT License
1.43k stars 190 forks source link

AutoSizeText not working as expected #199

Open tyler-jewell opened 9 months ago

tyler-jewell commented 9 months ago

Describe the bug min/maxFontSize not working as expected.

  1. See screenshots below on how it's not working as expected.
  2. From following the code, this all depends on the _isIntrinsic field in VxTextBuilder.
/// lib/src/flutter/text.dart
bool _isIntrinsic = false;

and then there is this for the getter:

/// lib/src/flutter/text.dart (line 86)
/// [LayoutBuilder] does not support using IntrinsicWidth or IntrinsicHeight.
///
/// Note: Use it only for few widgets like [DataTable], [IntrinsicWidth] or
/// [IntrinsicHeight] etc which doesn't work well with Vx
/// but using [isIntrinsic] will disable [AutoSizeText].
VxTextBuilder get isIntrinsic => this.._isIntrinsic = true;

I'm not entirely sure what is going on here. How exactly is it decided if _isIntrinsic?

To Reproduce Steps to reproduce the behavior:

class MyPage extends StatelessWidget {
  /// Create the view.
  const MyPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Container(
        color: Vx.amber400,
        height: 300,
        width: 200,
        child: '123 y'.text.minFontSize(20).maxFontSize(100).makeCentered(),
      ),
    );
  }
}

image

Expected behavior I would expect that the text would have a font size of 100.

class MyPage extends StatelessWidget {
  /// Create the view.
  const MyPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Container(
        color: Vx.amber400,
        height: 300,
        width: 200,
        child: '123 y'.text.size(100).makeCentered(),
      ),
    );
  }
}

image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.