'At Flutter When the new category button is clicked, I want it to first get a category name and then create a new button with that name

I'm very new to Flutter and I'm trying to learn. When the new category button is clicked, I want it to first get a category name and then create a new button with that name. In short, . [I want the user to create and name the categories as in the picture][1]

      [1]: https://i.stack.imgur.com/WVlWm.png

```
import 'package:flutter/material.dart';

//widget

class Categoriespage extends StatefulWidget {
const Categoriespage({Key? key}) : super(key: key);

@override
State<Categoriespage> createState() => _CategoriespageState();
}

class _CategoriespageState extends State<Categoriespage> {
TextEditingController CategoryNameController = 
TextEditingController();
var category;
@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text(
      'Kategoriler',
      style: TextStyle(color: Colors.white),
    ),
    centerTitle: true,
  ),

//body container

  body: Container(
    alignment: Alignment.center,
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [

        SizedBox(
          height: 20,
        ),

//

        RaisedButton(
          shape: RoundedRectangleBorder(
              borderRadius: 
   BorderRadius.all(Radius.circular(10.0))),
          onPressed: () {
            showModalBottomSheet(
                context: context,
                builder: (context) {
                  return Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[ //textfield and button
                      Container(
                        padding: const EdgeInsets.fromLTRB(10, 5, 
          10, 0),
                        child: TextField(
                          controller: CategoryNameController,
                          decoration: const InputDecoration(
                            border: OutlineInputBorder(),
                            labelText: 'Kategori Adı',
                          ),
                        ),
                      ),

//Onpressed will be filled later

                      Container(
                        child: ElevatedButton(
                            onPressed:() {},
                          child: const Text('Oluştur'),) ,

                      ),


                    ],
                  );
                });
          },

          padding:
          EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 
          15),
          color: Colors.pink,
          child: Text(
            '+ Kategori Ekle',
            style: TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.w600,
                letterSpacing: 0.6),
          ),
        ),
        ],
        ),
        ),
        );
        }
        }
    ```

        
      



       
        
       


Solution 1:[1]

Then you can use a ModalBottomSheet or a AlertDialog . You can a make input fields inside these widgets and if the proper values are provided then you can create your desired widget for the list.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Satendra Pal