Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a TextField on a Card

Tags:

flutter

How can i create a TextField on a Card. In a Function i return a Card. Here i needed to implement a TextField. This is my Code:

return new Card(
        color: Colors.white70,
        child: new Container(
          padding: EdgeInsets.all(10.0),
          child: new Column(
            children: <Widget>[
              new Row(
                children: <Widget>[
                  new Expanded(child: new Text("Bemerkung", style: style,)),
                  new TextField(

                  ),
                ],
              ),
            ],
          ),
        ),
      );

everytime i wanted to debug, this Exception was thrown:

I/flutter (17588): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (17588): The following assertion was thrown during performLayout():
I/flutter (17588): BoxConstraints forces an infinite width.
I/flutter (17588): These invalid constraints were provided to RenderRepaintBoundary's layout() function by the
I/flutter (17588): following function, which probably computed the invalid constraints in question:
I/flutter (17588):   _RenderDecoration._layout.layoutLineBox (package:flutter/src/material/input_decorator.dart:747:11)
I/flutter (17588): The offending constraints were:
I/flutter (17588):   BoxConstraints(w=Infinity, 0.0<=h<=Infinity)

i dont know why it didn't work.

like image 833
Anton Schrage Avatar asked Oct 18 '25 15:10

Anton Schrage


1 Answers

Just wrap TextField with Expanded widget,

new Card(
        color: Colors.white70,
        child: new Container(
          padding: EdgeInsets.all(10.0),
          child: new Column(
            children: <Widget>[
              new Row(
                children: <Widget>[
                  new Expanded(child: new Text("Bemerkung",)),
                  new Expanded(
                    child: new TextField(

                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      );
like image 140
Vinoth Kumar Avatar answered Oct 21 '25 21:10

Vinoth Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!