Search code examples
flutterflutter-layouttextfieldtextformfield

How to solve Flutter TextField exception?


I get this error while trying to put TextField inside my app:

'package:flutter/src/widgets/binding.dart': Failed assertion: line 858 pos 12: '!debugBuildingDirtyElements': is not true.

Here is a screenshot of the error. I even tried to use TextFormField but I got the same error:

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Row(
          children: [
            Column(
              children: const [
                TextField(),
              ],
            )
          ],
        ),
      ),
    );
  }
}

enter image description here


Solution

  • Wrap your Column with Expanded to get available space inside Row.

    body: Row(
      children: [
        Expanded(
          child: Column(
            children: [
              TextField(),
            ],
          ),
        )
      ],
    )
    

    You can check unbounded-height/width video