-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.17Found to occur in 3.17Found to occur in 3.17frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Wrap a
TextFieldwithIntrinsicWidth. - Use
prefixIconorsuffixIcon. - optional: use
suffixso it is easier to tell the the input is too wide.
Expected results
The TextField should be the correct width. When suffix is used, the suffix should be right next to the input's content.
Actual results
The TextField is too wide. When suffix is used, the suffix has extra space between it and the input's content (as it does if you don't use prefixIcon or suffixIcon.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter App!!',
theme: ThemeData(
colorSchemeSeed: Colors.indigo,
useMaterial3: true,
brightness: Brightness.light,
),
darkTheme: ThemeData(
colorSchemeSeed: Colors.blue,
useMaterial3: true,
brightness: Brightness.dark,
),
home: const MyHomePage(title: 'Flutter Example App'),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool showPrefixIcon = true;
bool showPrefix = true;
bool showSuffix = true;
bool showSuffixIcon = true;
TextEditingController textController =
TextEditingController(text: "Input Text");
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Padding(
padding: EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text('Show Prefix Icon', style: theme.textTheme.titleLarge),
Checkbox(
value: showPrefixIcon,
onChanged: (value) => setState(() {
showPrefixIcon = value ?? false;
}),
),
],
),
Row(
children: [
Text('Show Prefix', style: theme.textTheme.titleLarge),
Checkbox(
value: showPrefix,
onChanged: (value) => setState(() {
showPrefix = value ?? false;
}),
),
],
),
Row(
children: [
Text('Show Suffix', style: theme.textTheme.titleLarge),
Checkbox(
value: showSuffix,
onChanged: (value) => setState(() {
showSuffix = value ?? false;
}),
),
],
),
Row(
children: [
Text('Show Suffix Icon', style: theme.textTheme.titleLarge),
Checkbox(
value: showSuffixIcon,
onChanged: (value) => setState(() {
showSuffixIcon = value ?? false;
}),
),
],
),
IntrinsicWidth(
child: TextField(
controller: textController,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Input',
hintText: 'Input',
prefixIcon: showPrefixIcon ? Icon(Icons.add) : null,
prefix: showPrefix ? Text("\$") : null,
suffix: showSuffix ? Text("kg") : null,
suffixIcon: showSuffixIcon ? Icon(Icons.clear) : null,
),
),
),
],
),
),
);
}
}Screenshots or Video
Logs
No response
Flutter Doctor output
Doctor output
✓] Flutter (Channel stable, 3.13.9, on Pop!_OS 22.04 LTS 6.5.6-76060506-generic, locale en_US.UTF-8)
• Flutter version 3.13.9 on channel stable at /home/work/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d211f42860 (12 days ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /home/work/Android/Sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[✓] VS Code (version 1.84.0)
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • Pop!_OS 22.04 LTS 6.5.6-76060506-generic
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories.
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.17Found to occur in 3.17Found to occur in 3.17frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team



