Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Input decoration vertical alignment is broken with isDense: true #86093

@creativecreatorormaybenot

Description

Bug

Using a very simple TextField setup, the visuals are broken on web, i.e. the text is too high vertically / not center aligned.

This means there is a very easily provable discrepancy between Flutter web and Flutter for mobile.

Screenshots

Mobile (correct) Web (broken)
image image
image image

Reproducible sample

This is the exact code I ran on web and on mobile:

Click to expand snippet
import 'package:flutter/material.dart';

void main() {
  runApp(const Bug());
}

class Bug extends StatelessWidget {
  const Bug({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(32),
            child: DecoratedBox(
              decoration: BoxDecoration(
                color: Theme.of(context).colorScheme.onSurface.withAlpha(0x1a),
                borderRadius: BorderRadius.circular(8),
              ),
              child: SizedBox(
                height: 44,
                child: TextField(
                  cursorColor: Theme.of(context).accentColor,
                  textAlign: TextAlign.left,
                  textAlignVertical: TextAlignVertical.center,
                  style: Theme.of(context).textTheme.bodyText2,
                  decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: 'Hint :)',
                    isDense: true,
                    hintStyle: Theme.of(context).textTheme.subtitle2,
                    prefixIcon: const Icon(Icons.search),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Versions

[✓] Flutter (Channel origin/stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1052], locale en-150)
    • Flutter version 2.2.3Framework revision f4abaa0735 (7 days ago), 2021-07-01 12:46:11 -0700Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 91.0.4472.124

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: qualityA truly polished experiencea: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.found in release: 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions