Skip to content

AutoSizeText not working as expected #199

Open
@tyler-jewell

Description

@tyler-jewell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions