Giter VIP home page Giter VIP logo

Comments (9)

maeddin avatar maeddin commented on July 4, 2024

I apologize for the late reply.
When exactly is the wrong value passed into onChanged? Can you provide a reproducible example?
onChanged is basically only called when the user changes the value and not when the state changes.

from animated_toggle_switch.

santosh81066 avatar santosh81066 commented on July 4, 2024
 AnimatedToggleSwitch<bool>.dual(
                current:false,
                first: false,
                second: true,
                dif: 50.0,
                borderColor: Colors.transparent,
                borderWidth: 5.0,
                height: 55,
                boxShadow: const [
                  BoxShadow(
                    color: Colors.black26,
                    spreadRadius: 1,
                    blurRadius: 2,
                    offset: Offset(0, 1.5),
                  ),
                ],
                onChanged: (b) => setState(() => positive = b),
                colorBuilder: (b) => b ? Colors.red : Colors.green,
                iconBuilder: (value) => value
                    ? Icon(Icons.coronavirus_rounded)
                    : Icon(Icons.tag_faces_rounded),
                textBuilder: (value) => value
                    ? Center(child: Text('Oh no...'))
                    : Center(child: Text('Nice :)')),
              ),

in thie above code current is false so I expect b in onchange should be false while I change the switch it should be true but on change returns false while changing the switch

from animated_toggle_switch.

maeddin avatar maeddin commented on July 4, 2024

I took this code and always get back true when changing the switch. I do not see the error.

from animated_toggle_switch.

santosh81066 avatar santosh81066 commented on July 4, 2024

by changing the switch it is changing to true but if my current value is true then I expect false on changing not true

from animated_toggle_switch.

maeddin avatar maeddin commented on July 4, 2024

Yes, but with your code above, your current value is never true because you explicitly inserted false for current.
I'm sorry, but I don't understand the problem or the error.

from animated_toggle_switch.

santosh81066 avatar santosh81066 commented on July 4, 2024

just change the current value to true and print value in on change eg..print(b) in this situation I expect output as false

from animated_toggle_switch.

maeddin avatar maeddin commented on July 4, 2024

I'm really sorry, but I've tried both now: With value: false it always returns true in onChange and with value: true it always returns false in onChange. I can't reconstruct or understand the problem.

from animated_toggle_switch.

santosh81066 avatar santosh81066 commented on July 4, 2024

from animated_toggle_switch.

maeddin avatar maeddin commented on July 4, 2024

I'm closing the issue since there was no more response. If the error still occurs, you can reopen it.

from animated_toggle_switch.

Related Issues (19)

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.