Code Monkey home page Code Monkey logo

Comments (5)

letsar avatar letsar commented on May 26, 2024 4

I forgot to mention you should use the Slidable.builder constructor and SlideActionBuilderDelegates, otherwise you will end up with the same context as the Slidable. This is why Slidable.of(context) is null.

from flutter_slidable.

letsar avatar letsar commented on May 26, 2024

Hi,
I thought we could do this with Scrollable.of but we cannot use this after a dialog show.
I will try to implement some kind of controller, and see if we can use this.

from flutter_slidable.

letsar avatar letsar commented on May 26, 2024

Oh I succeeded to do what you want by getting the state before showing the AlertDialog.
The code below is what I put in the tap callback of my slide action:

onTap: () async {
                  var state = Slidable
                      .of(context);
                  var dismiss = await showDialog<bool>(
                    context: context,
                    builder: (context) {
                      return new AlertDialog(
                        title: new Text('Delete'),
                        content: new Text('Item will be deleted'),
                        actions: <Widget>[
                          new FlatButton(
                            child: new Text('Cancel'),
                            onPressed: () => Navigator.of(context).pop(false),
                          ),
                          new FlatButton(
                            child: new Text('Ok'),
                            onPressed: () => Navigator.of(context).pop(true),
                          ),
                        ],
                      );
                    },
                  );

                  if (dismiss) {
                    state.dismiss();
                  }
                },

from flutter_slidable.

CedSW avatar CedSW commented on May 26, 2024

thank you for you reply, but unfortunately I didn't manage to reproduce your solution.
Error is: NoSuchMethodError: The method 'dismiss' was called on null. I manage to come up with workaround using streams, but I still wonder where is the problem :/

here is my code

    SlideAction(
      onTap: () async {
        var state = Slidable
            .of(context);
        var dismiss = await showDialog<bool>(
          context: context,
          builder: (context) {
            return AlertDialog(
              title: Text(S.of(context).confirmDeletion),
              content: Text(S.of(context).deletionDescription),
              actions: <Widget>[
                FlatButton(
                  child: Text(S.of(context).cancel),
                  onPressed: () => Navigator.of(context).pop(false),
                ),
                FlatButton(
                  child: Text(S.of(context).ok),
                  onPressed: () =>  Navigator.of(context).pop(true),
                )
              ],
            );
          },
        );

        if (dismiss) {
          state.dismiss();
        }
      },
      color: _tag.color,
      child: Icon(Icons.delete, color: Colors.white,),
    )
  ],

from flutter_slidable.

fullflash avatar fullflash commented on May 26, 2024

I forgot to mention you should use the Slidable.builder constructor and SlideActionBuilderDelegates, otherwise you will end up with the same context as the Slidable. This is why Slidable.of(context) is null.

there are no examples with SlideActionBuilderDelegates and Slidable.builder.

also in version 2 we dont have this builder method.

how to achive a working result with slidablecontroller dismiss method without A dismissed Slidable widget is still part of the tree.

from flutter_slidable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.