TextField inside CupertinoAlertDialog

230

Please Wrap your cupertinoAlertDialog inside ShowDialog as it has Material Widget property.

showDialog<bool>(
              context: context,
              builder: (context) {
                return CupertinoAlertDialog(
                  title: Text('Cupertino dialog'),
                  content: Card(
                    elevation: 10.0,
                    child: Column(
                      children: <Widget>[
                        TextField(
                          decoration: InputDecoration(
                              labelText: "Name",
                              filled: true,
                              fillColor: Colors.grey
                          ),
                        ),
                      ],
                    ),
                  ),
                );
              },
            );
Share:
230
Hoangdz
Author by

Hoangdz

Updated on November 27, 2022

Comments

  • Hoangdz
    Hoangdz over 1 year

    I'm making a dialog, which has a text field to get input from user, by using CupertinoAlertDialog. However, it keeps saying No Mater Widget Found. I searched and tried with some solution from the Internet but it didn't work. Here is my code

    showCupertinoDialog(
       context: context,
       builder: (context) {
        return CupertinoAlertDialog(
         content: Scaffold(
         body: TextField(
         controller: cubit.textEditingController,
         ),
        ),
       );
     }
    );
    

    I have tried to replace Material with Card, Scaffold and Container but it didn't work as well.

    Please help me

    • Jahidul Islam
      Jahidul Islam almost 3 years
      please add your code, not image
    • Hoangdz
      Hoangdz almost 3 years
      Yes, I added it
    • Swaminathan V
      Swaminathan V almost 3 years
      You are trying this in iOS or Android ?
    • Hoangdz
      Hoangdz almost 3 years
      I'm trying this in Android
    • Hoangdz
      Hoangdz almost 3 years
      Sorry Jahidul Islam, I don't get your point about passing context where I call the function. Isn't it context : context in my code?
    • Nassar
      Nassar almost 3 years
      Could you provide the full class code please to be able to help you?
  • Rohit Sainik
    Rohit Sainik almost 3 years
    please mark the solution as correct if it works for you @Hoangdz