Sheikhsoft / swipe_button

swipe_button package for Flutter
Other
14 stars 8 forks source link

how to reset after SwipeRight? #1

Open bhanuka96 opened 4 years ago

bhanuka96 commented 4 years ago

I mean, After Swipe Right, Is it possible to reset swipe button?

diegoveloper commented 4 years ago

I added a SwipeController for the SwipeButton , you can use my repo for now :

  swipe_button:
    git: git://github.com/diegoveloper/swipe_button.git

Sample:


 final swipeController = SwipeController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          IconButton(
            icon: Icon(Icons.restore),
            onPressed: () => swipeController.reset(),
          )
        ],
      ),
      body: Container(
        alignment: Alignment.center,
        child: Padding(
          padding: const EdgeInsets.all(24.0),
          child: SwipeButton(
            swipeController: swipeController,
            thumb: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Align(
                    widthFactor: 0.90,
                    child: Icon(
                      Icons.chevron_right,
                      size: 60.0,
                      color: Colors.white,
                    )),
              ],
            ),
            content: Center(
              child: Text(
                'Testing',
                style: TextStyle(color: Colors.white),
              ),
            ),
            onChanged: (result) {
              print(result);
              if (result == SwipePosition.SwipeRight) {
              } else {}
            },
          ),
        ),
      ),
    );
  }