@@ -325,93 +325,96 @@ class _FlutterSwitchState extends State<FlutterSwitch>
325325 return AnimatedBuilder (
326326 animation: _animationController,
327327 builder: (context, child) {
328- return Align (
329- child: GestureDetector (
330- onTap: () {
331- if (! widget.disabled) {
332- if (widget.value)
333- _animationController.forward ();
334- else
335- _animationController.reverse ();
336-
337- widget.onToggle (! widget.value);
338- }
339- },
340- child: Opacity (
341- opacity: widget.disabled ? 0.6 : 1 ,
342- child: Container (
343- width: widget.width,
344- height: widget.height,
345- padding: EdgeInsets .all (widget.padding),
346- decoration: BoxDecoration (
347- borderRadius: BorderRadius .circular (widget.borderRadius),
348- color: _switchColor,
349- border: _switchBorder,
350- ),
351- child: Stack (
352- children: < Widget > [
353- AnimatedOpacity (
354- opacity: widget.value ? 1.0 : 0.0 ,
355- duration: widget.duration,
356- child: Container (
357- width: _textSpace,
358- padding: EdgeInsets .symmetric (horizontal: 4.0 ),
359- alignment: Alignment .centerLeft,
360- child: _activeText,
361- ),
362- ),
363- Align (
364- alignment: Alignment .centerRight,
365- child: AnimatedOpacity (
366- opacity: ! widget.value ? 1.0 : 0.0 ,
328+ return Container (
329+ width: widget.width,
330+ child: Align (
331+ child: GestureDetector (
332+ onTap: () {
333+ if (! widget.disabled) {
334+ if (widget.value)
335+ _animationController.forward ();
336+ else
337+ _animationController.reverse ();
338+
339+ widget.onToggle (! widget.value);
340+ }
341+ },
342+ child: Opacity (
343+ opacity: widget.disabled ? 0.6 : 1 ,
344+ child: Container (
345+ width: widget.width,
346+ height: widget.height,
347+ padding: EdgeInsets .all (widget.padding),
348+ decoration: BoxDecoration (
349+ borderRadius: BorderRadius .circular (widget.borderRadius),
350+ color: _switchColor,
351+ border: _switchBorder,
352+ ),
353+ child: Stack (
354+ children: < Widget > [
355+ AnimatedOpacity (
356+ opacity: widget.value ? 1.0 : 0.0 ,
367357 duration: widget.duration,
368358 child: Container (
369359 width: _textSpace,
370360 padding: EdgeInsets .symmetric (horizontal: 4.0 ),
371- alignment: Alignment .centerRight ,
372- child: _inactiveText ,
361+ alignment: Alignment .centerLeft ,
362+ child: _activeText ,
373363 ),
374364 ),
375- ),
376- Container (
377- child: Align (
378- alignment: _toggleAnimation.value,
379- child: Container (
380- width: widget.toggleSize,
381- height: widget.toggleSize,
382- padding: EdgeInsets .all (4.0 ),
383- decoration: BoxDecoration (
384- shape: BoxShape .circle,
385- color: _toggleColor,
386- border: _toggleBorder,
365+ Align (
366+ alignment: Alignment .centerRight,
367+ child: AnimatedOpacity (
368+ opacity: ! widget.value ? 1.0 : 0.0 ,
369+ duration: widget.duration,
370+ child: Container (
371+ width: _textSpace,
372+ padding: EdgeInsets .symmetric (horizontal: 4.0 ),
373+ alignment: Alignment .centerRight,
374+ child: _inactiveText,
387375 ),
388- child: FittedBox (
389- fit: BoxFit .contain,
390- child: Container (
391- child: Stack (
392- children: [
393- Center (
394- child: AnimatedOpacity (
395- opacity: widget.value ? 1.0 : 0.0 ,
396- duration: widget.duration,
397- child: widget.activeIcon,
376+ ),
377+ ),
378+ Container (
379+ child: Align (
380+ alignment: _toggleAnimation.value,
381+ child: Container (
382+ width: widget.toggleSize,
383+ height: widget.toggleSize,
384+ padding: EdgeInsets .all (4.0 ),
385+ decoration: BoxDecoration (
386+ shape: BoxShape .circle,
387+ color: _toggleColor,
388+ border: _toggleBorder,
389+ ),
390+ child: FittedBox (
391+ fit: BoxFit .contain,
392+ child: Container (
393+ child: Stack (
394+ children: [
395+ Center (
396+ child: AnimatedOpacity (
397+ opacity: widget.value ? 1.0 : 0.0 ,
398+ duration: widget.duration,
399+ child: widget.activeIcon,
400+ ),
398401 ),
399- ),
400- Center (
401- child : AnimatedOpacity (
402- opacity : ! widget.value ? 1.0 : 0.0 ,
403- duration : widget.duration ,
404- child : widget.inactiveIcon ,
402+ Center (
403+ child : AnimatedOpacity (
404+ opacity : ! widget.value ? 1.0 : 0.0 ,
405+ duration : widget.duration ,
406+ child : widget.inactiveIcon ,
407+ ) ,
405408 ),
406- ) ,
407- ] ,
409+ ] ,
410+ ) ,
408411 ),
409412 ),
410413 ),
411414 ),
412415 ),
413- ) ,
414- ] ,
416+ ] ,
417+ ) ,
415418 ),
416419 ),
417420 ),
0 commit comments