VelocityX icon indicating copy to clipboard operation
VelocityX copied to clipboard

AutoSizeText not working as expected

Open tyler-jewell opened this issue 1 year ago • 0 comments

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):

  • OS: macos
  • Browser chrome
  • Version velocity_x: ^4.1.2, vxstate: ^2.3.0

Additional context Add any other context about the problem here.

tyler-jewell avatar Jan 26 '24 02:01 tyler-jewell