Search code examples
flutterslidelisttile

How to customize SlidableAction to look like a round button in flutter?


I was able to add rounded corners but could not figure out how to reduce the default padding and make it a round button.

      SlidableAction(
            onPressed: (context) {
              // do something
            },
            autoClose: true, // I need this functionality
            icon: FeatherIcons.copy,
          ),

Current Output (SlidableAction) enter image description here

Required Output(Container in Slidable children) enter image description here


Solution

  • You could try and use ElevatedButton instead of Slidable Action , I will share example code

     ActionPane(
                    motion: ScrollMotion(),
                    children: [
                  
                      Builder(
                        builder: (cont) {
                          return ElevatedButton(
                            onPressed: () {
                              Slidable.of(cont)!.close();
                            },
                            style: ElevatedButton.styleFrom(
                              shape: CircleBorder(),
                              backgroundColor: Colors.red,
                              padding: EdgeInsets.all(10),
                            ),
                            child: const Icon(
                              Icons.delete,
                              color: Colors.white,
                              size: 25,
                            ),
                          );
                        },
                      ),
                    ],
                  ),