Giter VIP home page Giter VIP logo

Comments (9)

hirschmann avatar hirschmann commented on July 23, 2024 1

It only happens on Flutter Desktop.
I have only tried the rolling switch yet, so I can't tell anything about the other switches.

I can reproduce the error with this example:

// ...
Padding(
  padding: EdgeInsets.symmetric(vertical: kIsDesktop ? 9.0 : 15.0, horizontal: 0),
  child: AspectRatio(
    aspectRatio: 2,
    child: AnimatedToggleSwitch<ThemeMode>.rolling(
      current: _themeMode,
      iconRadius: 7,
      selectedIconRadius: 7,
      animationDuration: Duration(milliseconds: 400),
      borderWidth: 1,
      minTouchTargetSize: 100,
      values: [ThemeMode.light, ThemeMode.dark],
      onChanged: (m) => widget.switchThemeAction(),
      iconBuilder: (ThemeMode m, Size s, bool b) => m == ThemeMode.dark
          ? Icon(Icons.dark_mode, size: s.longestSide, color: Color.fromARGB(255, 171, 182, 196))
          : Icon(Icons.light_mode, size: s.longestSide, color: Color.fromARGB(255, 228, 206, 164)),
    ),
  ),
)
// ...

It seems like the issue occurs because I wrapped AnimatedToggleSwitch in an AspectRatio widget.

Flutter 2.10.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7e9793dee1 (7 weeks ago) • 2022-03-02 11:23:12 -0600
Engine • revision bd539267b4
Tools • Dart 2.16.1 • DevTools 2.9.2

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024 1

The fix is now available with version 0.5.1 on pub.dev

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

I'm sorry for the late reply. I can't reproduce this error. Is this error thrown only with Flutter Desktop? Actually, no value should be passed at this point in the code that causes a RangeError.
And is this error thrown only with certain switches or with all of them when using Flutter Desktop?

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

Thank you for the detailed answer. I would just like to understand the cause of this error. If I can't figure it out, I'll apply your fix, though that will fix the symptom rather than the problem.
I'll have a look tomorrow with Desktop, since I unfortunately don't have the possibility to test it with Desktop at the moment.

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

I have not been able to reproduce the error, but I have found the cause. Unfortunately, this is my error due to my implementation. The widget currently does not support tight BoxConstraints as passed by AspectRatio. You have to control the size via the attributes. I should refactor that. I'm sorry you had problems because of that. So currently the fix is probably to only pass BoxConstraints to the widget that are not tight. Otherwise the widget works very bad.

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

@hirschmann After all, it was only a few lines that I had to add. If you can confirm that the problem is fixed in version 0.5.0, this issue can be closed. Thanks for reporting and the pull request, even if it probably won't be merged.

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

@hirschmann Sorry, I wanted to upload the new version for a while anyway, which is why I did it too fast. If version 0.5.0 didn't fix your problem, then maybe 309ccab. It would be nice if you could let me know if one of the two versions fixes your problem :)

from animated_toggle_switch.

hirschmann avatar hirschmann commented on July 23, 2024

Indeed, 0.5.0 didn't fix the issue, but 309ccab does.
Thank you very much for your fast response and the fast fix as well :)

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

@hirschmann No problem :)
I still wouldn't use AspectRatio with this widget, because it forces it to a shape, which doesn't always look the way you want it to as a user.
I wish you a lot of fun with this package.

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.