// ignore_for_file: must_be_immutable import 'package:flutter/material.dart'; import 'package:get/get.dart'; class FikoButton1 extends StatelessWidget { FikoButton1({ super.key, required this.text, this.textColor, this.textStrokeColor, this.textStrokeWidth, this.textSize, this.onPressed, this.onLongPress, this.backColor, this.borderColor, this.radius, this.edgePadding, this.textAlign, this.fontWeight, }); dynamic text; Color? textColor; Color? textStrokeColor; Color? backColor; Color? borderColor; double? textStrokeWidth; double? textSize; double? radius; EdgeInsetsGeometry? edgePadding; TextAlign? textAlign; FontWeight? fontWeight; final VoidCallback? onPressed; final VoidCallback? onLongPress; @override Widget build(BuildContext context) { return TextButton( // icon: const Text("💡"), onLongPress: onLongPress, onPressed: onPressed, style: TextButtonTheme.of(context).style!.copyWith( backgroundColor: backColor != null ? WidgetStateProperty.all( backColor ?? Colors.transparent, ) : WidgetStateProperty.all( Colors.transparent, ), shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius ?? 10.0), side: BorderSide( color: borderColor ?? Colors.transparent, ), ), ), ), child: text.runtimeType == String ? Padding( padding: edgePadding ?? const EdgeInsets.all(0), child: Stack( alignment: Alignment.center, children: [ Align( alignment: Alignment.center, child: Text( text, textAlign: textAlign ?? TextAlign.center, style: TextStyle( // color: Colors.amberAccent, fontSize: textSize ?? 12, fontWeight: fontWeight ?? FontWeight.bold, foreground: Paint() ..style = PaintingStyle.stroke ..strokeWidth = textStrokeWidth ?? 2 ..color = textStrokeColor ?? Colors.black, ), ), ), Align( alignment: Alignment.center, child: Text( text, textAlign: textAlign ?? TextAlign.center, style: TextStyle( color: textColor ?? Colors.amberAccent, fontSize: textSize ?? 12, fontWeight: fontWeight ?? FontWeight.bold, ), ), ), ], ), ) : text, ); } } class AnimatedFikoButton1 extends StatelessWidget { AnimatedFikoButton1({ super.key, required this.text, this.textColor, this.textStrokeColor, this.textStrokeWidth, this.textSize, this.onPressed, this.onLongPress, this.backColor, this.borderColor, this.radius, this.duration, this.edgePadding, this.textAlign, this.fontWeight, }); dynamic text; Color? textColor; Color? textStrokeColor; Color? backColor; Color? borderColor; double? textStrokeWidth; double? textSize; double? radius; Duration? duration; EdgeInsetsGeometry? edgePadding; TextAlign? textAlign; FontWeight? fontWeight; final VoidCallback? onPressed; final VoidCallback? onLongPress; @override Widget build(BuildContext context) { return TextButton( // icon: const Text("💡"), onLongPress: onLongPress, onPressed: onPressed, style: TextButtonTheme.of(context).style!.copyWith( backgroundColor: backColor != null ? WidgetStateProperty.all( backColor ?? Colors.transparent, ) : null, shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius ?? 10.0), side: BorderSide( color: borderColor ?? Colors.transparent, ), ), ), ), child: AnimatedSwitcher( duration: duration ?? const Duration(milliseconds: 750), transitionBuilder: (Widget child, Animation animation) { return FadeTransition( opacity: animation, child: child, ); }, child: text.runtimeType == String ? Padding( key: ValueKey(text), padding: edgePadding ?? const EdgeInsets.all(0), child: Stack( alignment: Alignment.center, children: [ Align( alignment: Alignment.center, child: Text( text, textAlign: textAlign ?? TextAlign.center, style: TextStyle( // color: Colors.amberAccent, fontSize: textSize ?? 12, fontWeight: fontWeight ?? FontWeight.bold, foreground: Paint() ..style = PaintingStyle.stroke ..strokeWidth = textStrokeWidth ?? 2 ..color = textStrokeColor ?? Colors.black, ), ), ), Align( alignment: Alignment.center, child: Text( text, textAlign: textAlign ?? TextAlign.center, style: TextStyle( color: textColor ?? Colors.amberAccent, fontSize: textSize ?? 12, fontWeight: fontWeight ?? FontWeight.bold, ), ), ), ], ), ) : text, ), // animated Text True ise ); } } /** * */ class AnimatedNumberFikoButton1 extends StatefulWidget { AnimatedNumberFikoButton1({ super.key, required this.text, this.textBuilder, this.textColor, this.textStrokeColor, this.textStrokeWidth, this.textSize, this.onPressed, this.onLongPress, this.backColor, this.borderColor, this.radius, this.duration, this.edgePadding, this.textAlign, this.fontWeight, }); double? text; dynamic Function(double tweenValue)? textBuilder; ///---> Color? textColor; Color? textStrokeColor; Color? backColor; Color? borderColor; double? textStrokeWidth; double? textSize; double? radius; Duration? duration; EdgeInsetsGeometry? edgePadding; TextAlign? textAlign; FontWeight? fontWeight; final VoidCallback? onPressed; final VoidCallback? onLongPress; @override State createState() => _AnimatedNumberFikoButton1State(); } class _AnimatedNumberFikoButton1State extends State { late double? _oldText; // Eski text değeri @override void initState() { super.initState(); _oldText = widget.text; // Başlangıçta eski değeri constructor'dan alıyoruz } @override void didUpdateWidget(covariant AnimatedNumberFikoButton1 oldWidget) { super.didUpdateWidget(oldWidget); // Eğer widget'ın text değeri değiştiyse, eski değeri sakla if (oldWidget.text != widget.text) { _oldText = oldWidget.text; } } @override Widget build(BuildContext context) { return TweenAnimationBuilder( tween: Tween( begin: _oldText ?? 0.0, // Başlangıç değeri end: widget.text ?? 0.0, ), // Bitiş değeri duration: widget.duration ?? const Duration(seconds: 1), // Animasyon süresi builder: (context, value, child) { return FikoButton1( // key: ValueKey("${toplamBrutEkUcretler$.value?.toPrecision(2) ?? 0.0} TL"), text: widget.textBuilder != null ? widget.textBuilder!((value.isNaN || value.isInfinite) ? 0.0 : value) : "${(value.isNaN || value.isInfinite) ? 0 : value.toPrecision(2).toStringAsFixed(2)}", textSize: widget.textSize, edgePadding: widget.edgePadding, textColor: widget.textColor, textStrokeColor: widget.textStrokeColor, radius: widget.radius, backColor: widget.backColor, onPressed: widget.onPressed, onLongPress: widget.onLongPress, borderColor: widget.borderColor, textAlign: widget.textAlign, textStrokeWidth: widget.textStrokeWidth, fontWeight: widget.fontWeight, ); }, ); } }