flutterflutter-cupertinoactionsheet

How to change title's background color in CupertinoActionSheet flutter


i am using CupertinoActionSheet for bottomsheet. But i have problem with title's background color, i need title's background to be white. I searched but couldn't find a solution for this. Can you help? is there a way?

"My actionsheet"

This is my action sheet but i want like this;

ActionSheet which i want

My DSActionSheet code: `

return CupertinoActionSheet(
      title: Text(
        widget.title ?? "",
      ),
      message: widget.description != null ? Text(
        widget.description!,
      ) : null,
      actions: widget.actionWidgets,
      cancelButton: CupertinoActionSheetAction(
        onPressed: (){
          Navigator.pop(context);
        }, 
        child: Text(
          AppLocalizations.of(context)!.translate('cancel')!,
          style: const TextStyle(
            fontWeight: FontWeight.bold
          ),
        )
      ),
    );`

I tried wrap title with container and i gived white color to container, but this isnt work. Displayed like this: enter image description here

I tried giving background color to showModalBottomSheet but then the cancel button doesn't stay separate, it didn't work either.


Solution

  • I solved the problem. I gave title as an actionwidget and wrap with container and color is white:

    DSActionSheet(
      actionWidgets: <Widget> [
        Container(
          height: 51,
          color: Colors.white,
          child: CupertinoActionSheetAction(
            child: Text(
              AppLocalizations.of(context)!.translate("update_profile_photo")!,
              style: ThemeConstants().getActionSheetTitleTextStyle(context)
            ),
            onPressed: (){},
          ),
        ),
        Container(
          color: Colors.white,
          child: CupertinoActionSheetAction(
            onPressed: () {
              updateProfilePhoto(fromCamera: true);
            }, 
            child: Text(
              AppLocalizations.of(context)!.translate("select_from_camera")!,
            )
          ),
        ),
        Container(
          color: Colors.white,
          child: CupertinoActionSheetAction(
            onPressed: () {
              updateProfilePhoto(fromCamera: false);
            }, 
            child: Text(
              AppLocalizations.of(context)!.translate("select_from_gallery")!,
            )
          ),
        ),
        Container(
          color: Colors.white,
          child: CupertinoActionSheetAction(
            isDestructiveAction: true,
            onPressed: () {
              deleteProfilePhoto();
            }, 
            child: Text(
              AppLocalizations.of(context)!.translate("delete_profile_photo")!,
            )
          ),
        ),
      ]
    )
    

    Hope it helps someone!