Comments (9)
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.
The fix is now available with version 0.5.1 on pub.dev
from animated_toggle_switch.
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.
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.
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.
@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.
@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.
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.
@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 (20)
- Point releases should not have breaking changes HOT 3
- Change icon or text color HOT 4
- translation example HOT 3
- foreground icon and background icon do mismatch by a few pixel HOT 2
- onchanged property always remains false HOT 9
- Indicator hide DecoratedBox hide while dragging HOT 12
- Feature Request: Ability to disable toggle switch HOT 2
- Ability to initialize with null/unselected value HOT 5
- [Feature request] Add the possibility to toggle off the switch HOT 8
- Why is there no option to add an indicatorGradient in ToggleStyle? HOT 2
- problems with backgroundGradient and backgroundColor
- Theme switching occurs with a delay HOT 7
- Option to execute custom code after completion of animation HOT 2
- Setstate() called after dispose
- indicatorSize can't be changed HOT 2
- Indicator boxShadow is clipped HOT 4
- backgroundColor is displayed inaccurately. HOT 4
- Accessibility TalkBack for Android covers other switches, unable to read other tabs or select them. HOT 1
- Sometimes the toggle gets triggered two times HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from animated_toggle_switch.