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

Skip to content

[Cupertino]: Can't align placeholder of CupertinoTextField with min lines to top #138794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ziqq opened this issue Nov 21, 2023 · 21 comments · May be fixed by #166952
Open

[Cupertino]: Can't align placeholder of CupertinoTextField with min lines to top #138794

ziqq opened this issue Nov 21, 2023 · 21 comments · May be fixed by #166952
Assignees
Labels
a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository found in release: 3.16 Found to occur in 3.16 found in release: 3.17 Found to occur in 3.17 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@ziqq
Copy link
Contributor

ziqq commented Nov 21, 2023

Code sample

Code sample
CupertinoTextField(
  minLines: 5,
  controller: commentController,
  keyboardType: TextInputType.multiline,
  textInputAction: TextInputAction.done,
  placeholder: t.textCommentForOnlyPersonal,
),

Screenshots or Video

Screenshots / Video demonstration image

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.1 23B81 darwin-arm64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.2)
[✓] Connected device (3 available)
[✓] Network resources
@dam-ease dam-ease added the in triage Presently being triaged by the triage team label Nov 22, 2023
@dam-ease
Copy link

Thanks for filing this.
Can you try this #33785 (comment) to see if it works in your case??

@dam-ease dam-ease added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 22, 2023
@ziqq
Copy link
Contributor Author

ziqq commented Nov 22, 2023

Thanks for filing this. Can you try this #33785 (comment) to see if it works in your case??

Hello @dam-ease, i tried, but it not works for my, thx.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 22, 2023
@dam-ease
Copy link

Thanks for your response.
I can see on my end as well that using textAlignVertical: TextAlignVertical.top doesn't seem to align the placeholder to the top.
I'll label this for more insights.

Code Sample Used

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  TextEditingController commentController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey,
      body: SafeArea(
        child: Center(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: CupertinoTextField(
              minLines: 5,
              maxLines: 8,
              textAlignVertical: TextAlignVertical.top,
              controller: commentController,
              keyboardType: TextInputType.multiline,
              textInputAction: TextInputAction.done,
              placeholder: "textCommentForOnlyPersonal",
            ),
          ),
        ),
      ),
    );
  }
}

stable, master flutter doctor -v

[!] Flutter (Channel stable, 3.16.0, on macOS 14.0 23A344 darwin-arm64, locale
    en-NG)
    • Flutter version 3.16.0 on channel stable at
      /Users/damilolaalimi/sdks/flutter
    ! Warning: `dart` on your path resolves to
      /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/damilolaalimi/sdks/flutter.
      Consider adding /Users/damilolaalimi/sdks/flutter/bin to the front of your
      path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (8 days ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/damilolaalimi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)

[!] Android Studio (version unknown)
    • Android Studio at /Users/damilolaalimi/Downloads/Android Studio
      Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.84.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] VS Code (version 1.83.1)
    • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        •
      android-arm64  • Android 14 (API 34) (emulator)
    • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios
      • iOS 17.1.1 21B91
    • iPhone 15 (mobile)          • F17D2919-6D61-4295-8408-1719692FE958 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)             • macos                                •
      darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)                • chrome                               •
      web-javascript • Google Chrome 119.0.6045.159

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
[!] Flutter (Channel master, 3.17.0-15.0.pre.13, on macOS 14.0 23A344 darwin-arm64, locale en-NG)
    • Flutter version 3.17.0-15.0.pre.13 on channel master at /Users/damilolaalimi/fvm/versions/master
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/damilolaalimi/fvm/versions/master. Consider adding /Users/damilolaalimi/fvm/versions/master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 106667eb4b (9 hours ago), 2023-11-22 22:15:57 +0000
    • Engine revision f331e0afaf
    • Dart version 3.3.0 (build 3.3.0-152.0.dev)
    • DevTools version 2.30.0-dev.4
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/damilolaalimi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[!] Android Studio (version unknown)
    • Android Studio at /Users/damilolaalimi/Downloads/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.84.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] VS Code (version 1.83.1)
    • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 14 (API 34) (emulator)
    • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios            • iOS 17.1.1 21B91
    • iPhone 15 (mobile)          • F17D2919-6D61-4295-8408-1719692FE958 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 119.0.6045.159

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

@dam-ease dam-ease changed the title [Cupertino]: CupertinoTextField with min lines align placeholder on center, how to align to top? [Cupertino]: Can't align placeholder of CupertinoTextField with min lines to top Nov 23, 2023
@dam-ease dam-ease added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team found in release: 3.16 Found to occur in 3.16 found in release: 3.17 Found to occur in 3.17 and removed in triage Presently being triaged by the triage team labels Nov 23, 2023
@HansMuller HansMuller added P2 Important issues not at the top of the work list triaged-design Triaged by Design Languages team labels Nov 29, 2023
@HansMuller
Copy link
Contributor

CC @LongCatIsLooong

@LongCatIsLooong
Copy link
Contributor

The placeholder should be baseline-aligned with the text, right now it has to be center-aligned to avoid running into some existing asserts during intrinsic size calculation. I'm working on a fix.

@LeoAiolia
Copy link

same issue!

@kevtechi
Copy link

What's frustrating is that it was working and all of a sudden broke.

In the mean time, a workaround is to add newlines to the placeholder \n until it is at the right height.

@ziqq
Copy link
Contributor Author

ziqq commented Feb 22, 2024

In the mean time, a workaround is to add newlines to the placeholder \n until it is at the right height.

It's bad variant.

Any news about this issue?

@AdrianP25
Copy link

Same issue here, any progress on this 🙂?

@ybrelax
Copy link

ybrelax commented May 29, 2024

maybe you can try it.
Widget textInputArea() {
return Expanded(
child: CupertinoTextField(
placeholder: "please input",
textAlign: !textRightToLeft ? TextAlign.start : TextAlign.end,
controller: contentInputController,
padding: const EdgeInsets.only(left: 16, right: 16, top: 10),
cursorColor: Consts.themeColor,
style: const TextStyle(fontSize: 18, height: 1.8),
autofocus: true,
maxLines: 500,
minLines: 1,
textAlignVertical: TextAlignVertical.top,
decoration: const BoxDecoration(border: null),
),
);
}

@Yorkzero
Copy link

I think you can change minLines: 5, to minLines: 1,, and add maxLines: 5, to your code

@ziqq
Copy link
Contributor Author

ziqq commented Jul 9, 2024

I think you can change minLines: 5, to minLines: 1,, and add maxLines: 5, to your code

No. This is stretchable behaviour. This is not the behaviour I need.

image

@ziqq
Copy link
Contributor Author

ziqq commented Jul 9, 2024

Same issue here, any progress on this 🙂?

No.

@guopeng1994
Copy link

almost 1 year...

@kevtechi
Copy link

TextField placeholder position is broken without a fix for this...

@witwash
Copy link

witwash commented Jan 8, 2025

Any progress on this?

@dcalsky
Copy link

dcalsky commented Jan 15, 2025

SizedBox(
  height: 100,
  child: CupertinoTextField(
    maxLines: 6,
    minLines: 1,
    placeholder: 'Placeholder text will appear here...',
    controller: _textController,
    keyboardType: TextInputType.multiline,
    textAlignVertical: TextAlignVertical.top,
    style: TextStyle(fontSize: 14),
  ),
)

It works for me.

@WolfMobileDev
Copy link

Any progress on this?

@ziqq
Copy link
Contributor Author

ziqq commented Feb 14, 2025

Any progress on this?

Yes. U can try use crossAxisAlignment option from CupertinoTextField .

@Crepiks
Copy link

Crepiks commented Mar 26, 2025

Same for me, nothing above helped 😔

@kevtechi
Copy link

A bit of a hacky fix, but you can add a bit of padding inside and it works

@victorsanni victorsanni self-assigned this Apr 8, 2025
@victorsanni victorsanni removed their assignment Apr 15, 2025
@victorsanni victorsanni self-assigned this May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository found in release: 3.16 Found to occur in 3.16 found in release: 3.17 Found to occur in 3.17 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.