Forwarded from Azim Pulat
Kodni o'zim yozsam: <10 daqiqa>
...
Kodni AI yozsa: <1 soniya>
Keyin u kodni ishlatvolishga: <1 soat>
...
Kodni AI yozsa: <1 soniya>
Keyin u kodni ishlatvolishga: <1 soat>
π1
buttonni atrofida color aylanib yuradi ga custom widget
import 'dart:math' as math;
import 'package:sell_market/path_file/all_path_file.dart';
sealed class AppColors{
static const white=Colors.white;
static const transparent=Colors.transparent;
static const black=Colors.black;
static final red=Color(0xFFFF1F38);
static final red3=Color(0xFFF01FFF);
static final red2=Color(0xFFE61090);
}
class AnimatedBorderButton extends StatefulWidget {
final String text;
final VoidCallback onPressed;
const AnimatedBorderButton({
super.key,
required this.text,
required this.onPressed,
});
@override
State<AnimatedBorderButton> createState() => _AnimatedBorderButtonState();
}
class _AnimatedBorderButtonState extends State<AnimatedBorderButton>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 3),
)..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return CustomPaint(
painter: _GradientBorderPainter(angle: _controller.value * 2 * math.pi),
child: child,
);
},
child: GestureDetector(
onTap: widget.onPressed,
child: Container(
padding:EdgeInsetsGeometry.all(14),
child: Center(
child: Text(
widget.text,
style: const TextStyle(
color: Colors.white,
fontSize: 18,
),
),
),
),
),
);
}
}
class _GradientBorderPainter extends CustomPainter {
final double angle;
_GradientBorderPainter({required this.angle});
@override
void paint(Canvas canvas, Size size) {
final rect = Offset.zero & size;
final gradient = SweepGradient(
startAngle: angle,
endAngle: angle + 2 * math.pi,
/// color ni berish kere
colors: [AppColors.red,AppColors.white,AppColors.red3],
// colors: const [Colors.blue, Colors.green, Colors.red, Colors.orange, Colors.blue],
);
final paint = Paint()
..shader = gradient.createShader(rect)
..style = PaintingStyle.stroke
..strokeWidth = 3;
final rrect = RRect.fromRectAndRadius(rect.deflate(1), const Radius.circular(12));
canvas.drawRRect(rrect, paint);
}
@override
bool shouldRepaint(covariant _GradientBorderPainter oldDelegate) {
return oldDelegate.angle != angle;
}
}
/// example
AnimatedBorderButton(
text: "Continue",
onPressed: () {
print("Button pressed!");
},
),
π1π₯1
Learning Flutter π±π»
buttonni atrofida color aylanib yuradi ga custom widget import 'dart:math' as math; import 'package:sell_market/path_file/all_path_file.dart'; sealed class AppColors{ static const white=Colors.white; static const transparent=Colors.transparent; staticβ¦
version 2
import 'dart:math' as math;
import 'package:flutter/material.dart';
class AnimatedBorderButton extends StatefulWidget {
final String text;
final VoidCallback onPressed;
const AnimatedBorderButton({
super.key,
required this.text,
required this.onPressed,
});
@override
State<AnimatedBorderButton> createState() => _AnimatedBorderButtonState();
}
class _AnimatedBorderButtonState extends State<AnimatedBorderButton>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _rotation;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 5),
)..repeat();
_rotation = CurvedAnimation(
parent: _controller,
curve: Curves.easeInToLinear,
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _rotation,
builder: (context, child) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
gradient: SweepGradient(
startAngle: 0,
endAngle: math.pi * 2,
transform: GradientRotation(_rotation.value * 2 * math.pi),
colors: const [
Colors.blue,
Colors.purple,
Colors.red,
Colors.orange,
Colors.white,
Colors.blue,
],
),
),
child: Padding(
padding: const EdgeInsets.all(7),
child: Container(
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
child: TextButton(
onPressed: widget.onPressed,
child: Text(
widget.text,
style: const TextStyle(color: Colors.white, fontSize: 18),
),
),
),
),
);
},
);
}
}
π1
Learning Flutter π±π»
version 2 import 'dart:math' as math; import 'package:flutter/material.dart'; class AnimatedBorderButton extends StatefulWidget { final String text; final VoidCallback onPressed; const AnimatedBorderButton({ super.key, required this.text,β¦
This media is not supported in your browser
VIEW IN TELEGRAM
β€1π1
This media is not supported in your browser
VIEW IN TELEGRAM
Bugunga yetadi degani video
π1π₯1π1
Learning Flutter π±π»
Tavsiya etaman: Yandex Maps and Navigator https://play.google.com/store/apps/details?id=ru.yandex.yandexmaps
Yandex ancha yaxshilangan dasturchilar anchagina ter to'kishgan MDH davlatlarida yaxshi ishlasa kere dep oyliman 2 yildan beri ishlataman navigatsiyasi Juda yaxshi biror joyga borsam ancha kere boladi
π1π₯1π1
This media is not supported in your browser
VIEW IN TELEGRAM
Production ga chiqgan ilovaga ozgina codini o'zgartirsang π₯
π₯1π1
This media is not supported in your browser
VIEW IN TELEGRAM
Bu Telefonni yaxshi tomoni qaramasdan ham yozish mumkin edi π¨βπ¦³
π1π₯1
This media is not supported in your browser
VIEW IN TELEGRAM
Binary xisoblash qanday ishlaydi
π1π₯1π1
This media is not supported in your browser
VIEW IN TELEGRAM
Clean code shunday ekan biz adashibmiz
β1π1
Learning Flutter π±π»
Manda hammasiga tog'ri kelar ekanman
Gap isboti bilan