Search code examples
flutterwidgetcomponentsbox

how to create separate box for each category in flutter


I am creating a employee bio data page, for this i have 4 to 5 categories e.g. Personal data, family info, skills, employee history.

my output should be like this enter image description here

for all categories, how i can create it in flutter.

i have done this

enter image description here

and want to convert it to like above design.

---------------EDITED QUESTION--------------------------------

I did the below code but it is not meeting my requirement.

 Padding(padding: EdgeInsets.fromLTRB(15, 5,50, 0),
           child:Container(decoration: BoxDecoration(
                border: Border.all(color: Colors.blueAccent,width: 100) 
                   
            ),
            child:Padding(padding: EdgeInsets.fromLTRB(15, 5,50, 0),
            child: TextField(
              
              decoration: InputDecoration(border: InputBorder.none),
            ),
            
           ))

here is its output

enter image description here

please help if anyone know the name of widget or how to create it.


Solution

  • You can get this layout by using Stack, Containers and Column

    Stack(
           children: <Widget>[
                          Container(
                            margin: EdgeInsets.symmetric(
                                vertical: 20, horizontal: 20),
                            decoration: BoxDecoration(
                              border: Border.all(color: Colors.black, width: 2),
                            ),
                            child: Padding(
                              padding: const EdgeInsets.all(20.0),
                              child: Column(
                                children: [
                                  TextFormField(
                                    controller: _addressController,
                                    keyboardType: TextInputType.text,
                                    decoration: InputDecoration(
                                      hintText: "Enter Address",
                                      prefixIcon: Icon(
                                        Icons.home,
                                        color: Colors.grey,
                                      ),
                                      hintStyle: TextStyle(
                                          fontStyle: FontStyle.normal,
                                          fontSize: 13,
                                          color: Colors.grey),
                                      enabledBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                      focusedBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    height: 10,
                                  ),
                                  TextFormField(
                                    controller: _addressController,
                                    keyboardType: TextInputType.text,
                                    decoration: InputDecoration(
                                      hintText: "Enter Address",
                                      prefixIcon: Icon(
                                        Icons.home,
                                        color: Colors.grey,
                                      ),
                                      hintStyle: TextStyle(
                                          fontStyle: FontStyle.normal,
                                          fontSize: 13,
                                          color: Colors.grey),
                                      enabledBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                      focusedBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    height: 10,
                                  ),
                                  TextFormField(
                                    controller: _addressController,
                                    keyboardType: TextInputType.text,
                                    decoration: InputDecoration(
                                      hintText: "Enter Address",
                                      prefixIcon: Icon(
                                        Icons.home,
                                        color: Colors.grey,
                                      ),
                                      hintStyle: TextStyle(
                                          fontStyle: FontStyle.normal,
                                          fontSize: 13,
                                          color: Colors.grey),
                                      enabledBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                      focusedBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    height: 10,
                                  ),
                                  TextFormField(
                                    controller: _addressController,
                                    keyboardType: TextInputType.text,
                                    decoration: InputDecoration(
                                      hintText: "Enter Address",
                                      prefixIcon: Icon(
                                        Icons.home,
                                        color: Colors.grey,
                                      ),
                                      hintStyle: TextStyle(
                                          fontStyle: FontStyle.normal,
                                          fontSize: 13,
                                          color: Colors.grey),
                                      enabledBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                      focusedBorder: new OutlineInputBorder(
                                        borderSide: new BorderSide(
                                            color: Colors.black, width: 3),
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    height: 10,
                                  ),
                                  TextButton(
                                    onPressed: () {},
                                    child: Text(
                                      'Submit',
                                      style: TextStyle(
                                        fontSize: 13,
                                      ),
                                    ),
                                    style: ButtonStyle(
                                      side: MaterialStateProperty.all(
                                        BorderSide(
                                            width: 2, color: Colors.black),
                                      ),
                                      foregroundColor:
                                          MaterialStateProperty.all(
                                              Colors.black),
                                      padding: MaterialStateProperty.all(
                                          EdgeInsets.symmetric(
                                              vertical: 2, horizontal: 30)),
                                      textStyle: MaterialStateProperty.all(
                                        TextStyle(fontSize: 30),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                          Positioned(
                            left: 30,
                            top: 10,
                            child: Container(
                              padding: EdgeInsets.symmetric(
                                horizontal: 3,
                                vertical: 2,
                              ),
                              color: Colors.white,
                              child: Text(
                                'Personal Data',
                                style: TextStyle(
                                    color: Colors.black, fontSize: 12),
                              ),
                            ),
                          ),
                        ],
                      ),
    

    Output: