Skip to content

IntrinsicHeight around Wrap(Text) is incorrect #63302

@mehmetf

Description

@mehmetf

b/163101099

Intrinsic Height calculation for Wrap() widgets with overflowing text is incorrect, causing clipping/renderflex overflows.

This occurs in our app when we have maximum accessibility text size.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  State createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var useIntrinsicHeight = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'IntrinsicHeight',
      theme: ThemeData(primarySwatch: Colors.blue),
      darkTheme: ThemeData(primarySwatch: Colors.blue),
      home: MediaQuery(
        data: MediaQueryData(textScaleFactor: 3.2),
        child: Scaffold(
          appBar: AppBar(title: Text('IntrinsicHeight Test')),
          body: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              _wrapWidget(
                Wrap(
                  children: [
                    Text('Longer text 12345678'),
                    Text('Longer text 12345678'),
                  ],
                ),
              ),
              Center(
                child: RaisedButton(
                  onPressed: () =>
                      setState(() => useIntrinsicHeight = !useIntrinsicHeight),
                  child: Text('Toggle wrapping'),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }

  Widget _wrapWidget(Widget child) {
    if (!useIntrinsicHeight) {
      return Container(
        color: Colors.blue,
        child: child,
      );
    }

    return Container(
      color: Colors.green,
      child: IntrinsicHeight(child: child),
    );
  }
}

The expectation is that there should be no difference in height when IntrinsicHeight is toggled on or off.

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: typographyText rendering, possibly libtxtcustomer: money (g3)frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions