Comments (12)
and the DecoratedBox indicator not showing on first start up applications
from animated_toggle_switch.
I'll take a look at it in a few hours. Where is SPAColor
and SPAColorSet
implemented?
from animated_toggle_switch.
It is a custom colour library,it just turn the hex code into colour, convert two different colour into gradient
from animated_toggle_switch.
I'll take a closer look at the bug, but for your use case, doesn't it make more sense to use my other package action_slider?
from animated_toggle_switch.
Actually I want a switch button that have tap and dragging event , thanks for the advice anyway
from animated_toggle_switch.
I've fixed the problem. You have to use double.infinity
instead of double.maxFinite
for dif
and set the current version in your pubspec.yaml
:
animated_toggle_switch:
git: https://github.com/SplashByte/animated_toggle_switch.git
It would be great if you verify that the problem is indeed fixed.
from animated_toggle_switch.
Here is an optimized version of your widget. I have added a transition between the texts:
class _HomePageSliderState extends State<HomePageSlider> {
bool tripStart = false;
@override
Widget build(BuildContext context) {
return CustomAnimatedToggleSwitch<bool>(
current: tripStart,
values: [false, true],
dif: double.infinity,
iconArrangement: IconArrangement.overlap,
// left right 3
padding: const EdgeInsets.symmetric(horizontal: 3.0),
indicatorSize: const Size.square(42.0),
animationDuration: const Duration(milliseconds: 200),
animationCurve: Curves.linear,
onChanged: (b) => setState(() => tripStart = b),
// Container for The Another Side Not in used
iconBuilder: (context, local, global) {
return Center(
child: Opacity(
opacity: local.value ? 1.0 - global.position : global.position,
child: Text(
local.value ? '立即Call車' : '截車中',
style: TextStyle(
color: Colors.white,
//Color.lerp(Colors.black, Colors.white, global.position),
fontSize: 16.0,
fontFamily: 'NotoSansHK',
fontWeight: FontWeight.w600,
),
),),
);
},
defaultCursor: SystemMouseCursors.click,
onTap: () => setState(() => tripStart = !tripStart),
iconsTappable: false,
// container for the Switch Button
foregroundIndicatorBuilder: (context, global) {
return SizedBox.fromSize(
size: global.indicatorSize,
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
//Color.lerp(Colors.white, Colors.blue, global.position),
borderRadius: BorderRadius.all(Radius.circular(24.0)),
),
child: AnimatedContainer(
// top 5 left 5 bottom 5 right 6
padding: const EdgeInsets.fromLTRB(5.0, 5.0, 6.0, 5.0),
duration: const Duration(milliseconds: 200),
child: Icon(
tripStart ? Icons.close : Icons.arrow_forward_ios,
color: Color.lerp(Colors.blue, Colors.black, global.position),
),
)),
);
},
// container for the slider
wrapperBuilder: (context, global, child) {
return Stack(
alignment: Alignment.center,
children: [
Positioned(
left: 0.0,
right: 0.0,
height: 48,
child: DecoratedBox(
decoration: BoxDecoration(
gradient: Gradient.lerp(
SPAColorSet.PrimaryGradient.gradient,
SPAColor.getGradientColor(['FFFFFF', '222222']),
global.position
),
// color: Color.lerp(SPAColor.getColorFromHex('2A7DDE'),
// SPAColor.getColorFromHex('5FCFFF'), global.position),
borderRadius: const BorderRadius.all(Radius.circular(24.0)),
),
)),
child,
],
);
},
);
}}
from animated_toggle_switch.
Thanks for the help, the problem fixed , the iconBuilder will as a child render in the wrapperBuilder
did i understand the situation correctly?
from animated_toggle_switch.
I close the Issue now , Thanks for your help
from animated_toggle_switch.
@peterLam2 Thanks for reporting the issue.
Yes, the results of the iconBuilder
are part of the child
in the wrapperBuilder
👍
from animated_toggle_switch.
@peterLam2 I don't know if this helps you, but I added two new parameters to AnimatedToggleSwitch.dual
. Maybe you can replace your custom switch with AnimatedToggleSwitch.dual
now.
You can now disable the rolling animation and set a gradient for the background.
from animated_toggle_switch.
Good to hear that 🤠 i will check that tomorrow
from animated_toggle_switch.
Related Issues (20)
- Point releases should not have breaking changes HOT 3
- Range error when dragging the indicator too far in right direction HOT 9
- 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
- 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.