Bottom Sheet Scroll

edited December 2021 in Flutter

Example Code:

showModalBottomSheet(
    isScrollControlled: true,
    context: context,
    elevation: 10.0,
    backgroundColor: white,
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0)),
    ),
    builder: (context) {
       return StatefulBuilder(
          builder: (BuildContext context, StateSetter setState) {
      return SingleChildScrollView(
        physics: const BouncingScrollPhysics(),
        child: Container(
          padding: EdgeInsets.only(
                  bottom: MediaQuery.of(context).viewInsets.bottom),
          child: Padding(
            padding: const EdgeInsets.all(10.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                const Text(
                  "Edit Profile",
                  style: TextStyle(
                      color: black,
                      fontWeight: FontWeight.w700,
                      fontSize: 18.0),
                  textAlign: TextAlign.center,
                ),
                const Divider(
                  color: grey,
                  height: 1.0,
                ),
                headingTextWidget("Name"),
                RoundedTextField(
                    controller: _nameController, hint: "Enter Your Name"),
                const SizedBox(
                  height: 10.0,
                ),
                headingTextWidget("Mobile Number"),
                Container(
                  width: double.infinity,
                  height: 45,
                  padding: const EdgeInsets.symmetric(horizontal: 10.0),
                  alignment: Alignment.centerLeft,
                  decoration: BoxDecoration(
                      color: textFieldColor,
                      borderRadius: BorderRadius.circular(10.0)),
                  child: Text(
                    "+91 $mobile",
                    style: const TextStyle(
                        color: grey,
                        fontWeight: FontWeight.w600,
                        fontSize: 17.0),
                  ),
                ),
                const SizedBox(
                  height: 10.0,
                ),
                headingTextWidget("Email d"),
                RoundedTextField(
                    controller: _emailController, hint: "Enter your email"),
                const SizedBox(
                  height: 30.0,
                ),
                RoundedButton(
                    text: "save",
                    press: () {
                      if (_nameController.text.toString().trim().isEmpty ||
                          _emailController.text.toString().trim().isEmpty) {
                        showToast(enterAllFields);
                      } else if (!RegExp(emailRegex).hasMatch(
                          _emailController.text.toString().trim())) {
                        showToast(validEmail);
                      } else {
                        updateProfileDetails(
                            _nameController.text.toString().trim(),
                            _emailController.text.toString().trim(),
                            setState);
                      }
                    },
                    buttonColor: buttonColor,
                    textColor: white)
              ],
            ),
          ),
        ),
      );
       });
    });


Sign In or Register to comment.