skip to Main Content

I want to try put TextFormField in the row expanded widget, but I can’t seem to put TextFormField anywhere there

Column(
    children: [
      ListTile(
        title: Text('Full Name'),
        subtitle: TextFormField(
          decoration: const InputDecoration(
            border: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(8))),
            hintText: 'Full Name',
          ),
        ),
      ),
      SizedBox(
        height: 5,
      ),
      Row(
        children: [
          Expanded(
            child: ListTile(
        title: Text('Department'),
        subtitle: TextFormField(
              decoration: const InputDecoration(
                border: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(8))),
                hintText: '  Department',
              ),
            ),),
          ),
          SizedBox(
            width: 5,
          ),
          Expanded(
            child:ListTile(
        title: Text('Year Of Study'),
        subtitle:  TextFormField(
              decoration: const InputDecoration(
                border: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(8))),
                hintText: '  Year Of Study',
              ),
            ),),
          ),
        ],
      )
    ],
  ),

This is one example of the code I find to put TextFormFields side by side, but got this error:

The constructor being called isn't a const constructor.
Try removing 'const' from the constructor invocation.

TextFormField‘s constructor isn’t being invoked with const in this case. How do I fix this error?

2

Answers


  1. You likely have a parent Widget with a const keyword; check the Column‘s parents and remove any const until the issue is resolved.

    Login or Signup to reply.
  2. You can try this code your problem will be resolved you were using the one ListTile outside the row that is why that problem was occurring.

    Column(
        children: [
          const SizedBox(
            height: 50
          ),
          Row(
    
            children: [
          
           Expanded(
           child: ListTile(
            title: const Text('Full Name'),
            subtitle: TextFormField(
              decoration: const InputDecoration(
                border: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(8))),
                hintText: 'Full Name',
              ),
            ),
          ),
           ),
          
              Expanded(
                child: ListTile(
            title: const Text('Department'),
            subtitle: TextFormField(
                  decoration: const InputDecoration(
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(8),),),
                    hintText: 'Department',
                  ),
                ),),
              ),
              const SizedBox(
                width: 5
              ),
              Expanded(
                child:ListTile(
            title: const Text('Year Of Study',style: TextStyle(fontSize: 14.5,fontWeight: FontWeight.w400),),
            subtitle:  TextFormField(
                  decoration: const InputDecoration(
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(8))),
                    hintText: '  Year Of Study',
                  ),
                ),),
              ),
            ],
          )
        ],
      ), 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search