Qries

Subscribe Us

Advertisement

Edit address

Edit Address 1

code: 

import 'package:flutter/material.dart';

import 'package:flutter_svg/svg.dart';

class ProfileBody extends StatefulWidget {
  @override
  _ProfileBodyState createState() => _ProfileBodyState();
}

class _ProfileBodyState extends State<ProfileBody> {
  bool nameEdit;
  bool addressEdit;
  bool cityEdit;
  bool stateEdit;
  bool mobileNoEdit;

  final TextEditingController nameProfileController =
      new TextEditingController();
  final TextEditingController addressProfileController =
      new TextEditingController();
  final TextEditingController cityProfileController =
      new TextEditingController();
  final TextEditingController stateProfileController =
      new TextEditingController();
  final TextEditingController mobileNoProfileController =
      new TextEditingController();

  @override
  void initState() {
    nameEdit = false;
    addressEdit = false;
    cityEdit = false;
    stateEdit = false;
    mobileNoEdit = false;
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          _buildHeader(context),
          SizedBox(height: 10.0),
          _buildInfo(context),
        ],
      ),
    );
  }

  Widget _buildHeader(BuildContext context) {
    return Stack(
      children: <Widget>[
        Ink(
          height: 230,
          color: Colors.deepOrangeAccent.shade200,
        ),
        Container(
          width: double.infinity,
          margin: const EdgeInsets.only(top: 20),
          child: Column(
            children: <Widget>[
              Card(
                elevation: 2,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(100),
                ),
                // color: Colors.deepOrange.shade200,
                child: Container(
                  width: 100,
                  height: 100,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(100),
                    border: Border.all(
                      color: Colors.white,
                      width: 6.0,
                    ),
                  ),
                  child: ClipRRect(
                    borderRadius: BorderRadius.circular(80),
                    child: SvgPicture.asset(
                      "QAssets/logo_y.svg",
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
              ),
              _buildMainInfo(context)
            ],
          ),
        ),
        Container(
          margin: const EdgeInsets.only(top: 180),
          child: _buildInfoCard(context),
        )
      ],
    );
  }

  Widget _buildInfoCard(context) {
    return Column(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(top: 20, left: 30, right: 30),
          child: Card(
            elevation: 5.0,
            color: Colors.white,
            child: Padding(
              padding: const EdgeInsets.only(
                  top: 16.0, bottom: 16.0, right: 10.0, left: 10.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  new Column(
                    mainAxisSize: MainAxisSize.max,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      new Text(
                        'Cart Details',
                        style: new TextStyle(
                            fontSize: 18.0,
                            color: Colors.black,
                            fontWeight: FontWeight.w400),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 6.0),
                        child: new Text(
                          '5',
                          style: new TextStyle(
                              fontSize: 18.0,
                              color: Color(0Xffde6262),
                              fontWeight: FontWeight.w600),
                        ),
                      ),
                    ],
                  ),
                  new Column(
                    children: <Widget>[
                      new Text(
                        'Order',
                        style: new TextStyle(
                            fontSize: 18.0,
                            color: Colors.black,
                            fontWeight: FontWeight.w400),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 6.0),
                        child: new Text(
                          '3',
                          style: new TextStyle(
                              fontSize: 18.0,
                              color: Color(0Xffde6262),
                              fontWeight: FontWeight.w600),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ),
      ],
    );
  }

  Widget _buildMainInfo(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: const EdgeInsets.all(10),
      alignment: AlignmentDirectional.center,
      child: Column(
        children: <Widget>[
          Text('Maherban',
              style: TextStyle(
                  fontSize: 20,
                  color: Colors.yellow,
                  fontWeight: FontWeight.bold)),
          SizedBox(height: 10),
          Text('Flutter',
              style: TextStyle(
                  color: Colors.grey.shade50, fontStyle: FontStyle.italic))
        ],
      ),
    );
  }

  Widget _buildInfo(BuildContext context) {
    return Container(
        child: Card(
      color: Colors.white,
      child: Container(
        alignment: Alignment.topLeft,
        padding: EdgeInsets.only(
          left: 15,
          bottom: 25,
        ),
        child: Column(
          children: <Widget>[
            //////name
            ListTile(
              trailing: IconButton(
                icon: Icon(
                  nameEdit ? Icons.save : Icons.edit,
                  color: Colors.black,
                ),
                onPressed: () {
                  setState(() {
                    nameEdit = !nameEdit;
                  });
                },
              ),
              leading:
                  Icon(Icons.account_circle, color: Colors.deepOrangeAccent),
              title: Text(
                "Full Name",
                style: TextStyle(fontSize: 18, color: Colors.black),
              ),
              subtitle: nameEdit
                  ? TextFormField(
                      controller: nameProfileController,
                      decoration: InputDecoration(
                        hintText: "Your Name",
                      ),
                    )
                  : Text(nameProfileController.text,
                      style: TextStyle(fontSize: 18, color: Colors.black)
                      // (() {
                      //   if (profileNameController.text == null) {
                      //     return profileNameController.text;
                      //   }
                      //   return profileNameController.text;
                      // })(),
                      ),
            ),
            Divider(),

            ///address
            ListTile(
              trailing: IconButton(
                icon: Icon(
                  addressEdit ? Icons.save : Icons.edit,
                  color: Colors.black,
                ),
                onPressed: () {
                  setState(() {
                    addressEdit = !addressEdit;
                  });
                },
              ),
              leading: Icon(Icons.list, color: Colors.deepOrangeAccent),
              title: Text(
                "Address",
                style: TextStyle(fontSize: 18, color: Colors.black),
              ),
              subtitle: addressEdit
                  ? TextFormField(
                      controller: addressProfileController,
                      decoration: InputDecoration(
                        hintText: "Your Address",
                      ),
                    )
                  : Text(addressProfileController.text,
                      style: TextStyle(fontSize: 18, color: Colors.black)),
            ),
            Divider(),

            ///city
            ListTile(
              trailing: IconButton(
                icon: Icon(
                  cityEdit ? Icons.save : Icons.edit,
                  color: Colors.black,
                ),
                onPressed: () {
                  setState(() {
                    cityEdit = !cityEdit;
                  });
                },
              ),
              leading: Icon(Icons.map, color: Colors.deepOrangeAccent),
              title: Text(
                "City",
                style: TextStyle(fontSize: 18, color: Colors.black),
              ),
              subtitle: cityEdit
                  ? TextFormField(
                      controller: cityProfileController,
                      decoration: InputDecoration(
                        hintText: "Your City",
                      ),
                    )
                  : Text(cityProfileController.text,
                      style: TextStyle(fontSize: 18, color: Colors.black)),
            ),
            Divider(),

            ///state
            ListTile(
              trailing: IconButton(
                icon: Icon(
                  stateEdit ? Icons.save : Icons.edit,
                  color: Colors.black,
                ),
                onPressed: () {
                  setState(() {
                    stateEdit = !stateEdit;
                  });
                },
              ),
              leading:
                  Icon(Icons.location_city, color: Colors.deepOrangeAccent),
              title: Text(
                "State",
                style: TextStyle(fontSize: 18, color: Colors.black),
              ),
              subtitle: stateEdit
                  ? TextFormField(
                      controller: stateProfileController,
                      decoration: InputDecoration(
                        hintText: "Your State",
                      ),
                    )
                  : Text(stateProfileController.text,
                      style: TextStyle(fontSize: 18, color: Colors.black)),
            ),
            Divider(),
            //////mobileNo.
            ListTile(
              trailing: IconButton(
                icon: Icon(
                  mobileNoEdit ? Icons.save : Icons.edit,
                  color: Colors.black,
                ),
                onPressed: () {
                  setState(() {
                    mobileNoEdit = !mobileNoEdit;
                  });
                },
              ),
              leading: Icon(Icons.call, color: Colors.deepOrangeAccent),
              title: Text(
                "Mobile No.",
                style: TextStyle(fontSize: 18, color: Colors.black),
              ),
              subtitle: mobileNoEdit
                  ? TextFormField(
                      controller: mobileNoProfileController,
                      decoration: InputDecoration(
                        hintText: "Your Mobile No.",
                      ),
                    )
                  : Text(mobileNoProfileController.text,
                      style: TextStyle(fontSize: 18, color: Colors.black)),
            ),
          ],
        ),
      ),
    ));
  }
}

Post a Comment

0 Comments