Skip to content

App highlights / selects trailing whitespaces in a multi-line textfield. #174689

Closed

Description

@feimenggo

Steps to reproduce

Watch video demonstration.

Expected results

.

Actual results

.

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 Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(child: TextField(maxLines: null)),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen_recording_20250829_171051.mp4

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Flutter 3.35.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 05db968908 (4 days ago) • 2025-08-25 10:21:35 -0700
Engine • hash abb725c9a5211af2a862b83f74b7eaf2652db083 (revision a8bfdfc394) (6 days ago) • 2025-08-22 23:51:12.000Z
Tools • Dart 3.9.0 • DevTools 2.48.0

Activity

  1. darshankawar commented on Aug 29, 2025

    @darshankawar
    Member

    I was able to replicate the reported behavior. The issue is, for multiline textfield, selecting the text in first line also highlights the trailing whitespace in accordance to next line's length, as shown below:

    Image

    While if we try to select the next line's text if length of it is less than first line, it doesn't highlight the trailing whitespace:

    Image

    Above behavior occurs Android, iOS and desktop if we pass a value to maxLines or also adding minLines, but not in web, wherein, it doesn't highlight the trailing whitespace of first line:

    Image

    I checked the native behavior on Android and iOS using Samsung / Notes app and there, it doesn't highlight the whitespace:

    Image

    I tried to find if this is an existing issue filed already but couldn't find an obvious / similar issue or if I missed to find it if already present.

    Based on my findings above, keeping the issue open for team's tracking.

    stable: 3.35.2
    master : 3.36.0-1.0.pre-305
    
  2. changed the title [-]TextSelection Error[/-] [+]App highlights / selects trailing whitespaces in a multi-line textfield.[/+] on Aug 29, 2025
  3. added
    a: text inputEntering text in a text field or keyboard related problems
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-androidAndroid applications specifically
    platform-iosiOS applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on Aug 29, 2025
  4. added
    P3Issues that are less important to the Flutter project
    P2Important issues not at the top of the work list
    and removed
    P3Issues that are less important to the Flutter project
    on Sep 18, 2025
  5. loic-sharma commented on Sep 18, 2025

    @loic-sharma
    Member
  6. anazr9 commented on Apr 18, 2026

    @anazr9
    Contributor

    Opened PR: #185239

  7. justinmc commented on Apr 21, 2026

    @justinmc
    Contributor

    CC @Renzo-Olivares from triage.

    I'm curious about how this behaves on all of our platforms.

  8. added a commit that references this issue on Oct 9, 2026
    103d780
  9. github-actions commented on Oct 23, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Oct 23, 2026
  11. added a commit that references this issue on Oct 29, 2026
    bc40d0b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsfound in release: 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyplatform-iosiOS applications specificallyteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions