Skip to content

Wrong Border Panting In InputDecoration  #111086

@Peng-Qian

Description

@Peng-Qian

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Tap on the first form field to see the correct border painting after floating the label
  3. Tap on the second form field to see the incorrect border painting after floating the label

Expected results:
The border should not change its position and size

Actual results:
The border will change its position and size when the border is only rounded on top.

Code sample
import 'package:flutter/material.dart';

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

const BorderSide blueBorderSide = BorderSide(color: Colors.blue);

const BorderSide redBorderSide = BorderSide(color: Colors.red);

const OutlineInputBorder roundedAllBorder = OutlineInputBorder(borderSide: blueBorderSide);

const OutlineInputBorder roundedTopBorder = OutlineInputBorder(
  borderSide: blueBorderSide,
  borderRadius: BorderRadius.vertical(top: Radius.circular(4), bottom: Radius.zero),
);

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => FocusScope.of(context).unfocus(),
      child: Scaffold(
        appBar: AppBar(
          title: const Text('Demo'),
        ),
        body: GridPaper(
          divisions: 4,
          subdivisions: 4,
          color: Colors.red.withOpacity(0.7),
          interval: 128,
          child: Center(
            child: Padding(
              padding: const EdgeInsets.all(32.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  TextFormField(
                    decoration: const InputDecoration(
                      labelText: 'Label',
                      floatingLabelBehavior: FloatingLabelBehavior.auto,
                      border: roundedAllBorder,
                      disabledBorder: roundedAllBorder,
                      enabledBorder: roundedAllBorder,
                      errorBorder: roundedAllBorder,
                      focusedBorder: roundedAllBorder,
                      focusedErrorBorder: roundedAllBorder,
                    ),
                  ),
                  const SizedBox(
                    height: 50,
                  ),
                  TextFormField(
                    decoration: const InputDecoration(
                      labelText: 'Label',
                      floatingLabelBehavior: FloatingLabelBehavior.auto,
                      border: roundedTopBorder,
                      disabledBorder: roundedTopBorder,
                      enabledBorder: roundedTopBorder,
                      errorBorder: roundedTopBorder,
                      focusedBorder: roundedTopBorder,
                      focusedErrorBorder: roundedTopBorder,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
Logs
Analyzing bug_demo...                                                   
No issues found! (ran in 1.9s)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5.1 21G83 darwin-x64, locale
    en-NZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.69.0)
[✓] Connected device (2 available)
    ! Error: Qian’s iPhone is not connected. Xcode will continue when Qian’s
      iPhone is connected. (code -13)
[✓] HTTP Host Availability

• No issues found!

Video

bug_demo.mp4

Image

Simulator Screen Shot - iPhone 13 Pro Max - 2022-09-08 at 01 03 26

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsc: renderingUI glitches reported at the engine/skia or impeller rendering levelf: material designflutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions