init
This commit is contained in:
195
lib/src/CustomWidgets.dart
Normal file
195
lib/src/CustomWidgets.dart
Normal file
@@ -0,0 +1,195 @@
|
||||
|
||||
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
double op1 = 0;
|
||||
double op2 = 0;
|
||||
double op3 = 0;
|
||||
Widget CustomBody({required Widget child,required BuildContext context, required Function() onAnimEnd}) {
|
||||
Duration opDuration = const Duration(milliseconds: 1500);
|
||||
var random = new Random();
|
||||
|
||||
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
return SizedBox(
|
||||
height: screenHeight,
|
||||
width: screenWidth,
|
||||
child: Stack(children: [
|
||||
Positioned(
|
||||
top: -100,
|
||||
left: -100,
|
||||
child: AnimatedContainer(
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
op1 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op1);
|
||||
onAnimEnd();
|
||||
},
|
||||
height: 400,
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.blue.withOpacity(0.3 + (op1/3)),
|
||||
Colors.blue.withOpacity(op1),
|
||||
Colors.deepPurpleAccent.withOpacity(op1)
|
||||
],
|
||||
),
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: -25,
|
||||
right: -100,
|
||||
child: AnimatedContainer(
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
// setState(() {
|
||||
op2 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op2); onAnimEnd();
|
||||
|
||||
// });
|
||||
},
|
||||
height: 200,
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
// color: Colors.deepPurple.withOpacity(0.3),
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.deepPurple.withOpacity(op2),
|
||||
Colors.purpleAccent.withOpacity(op2)
|
||||
],
|
||||
),
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: screenHeight * 0.55,
|
||||
left: -100,
|
||||
child: AnimatedContainer(
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
// setState(() {
|
||||
op3 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op3); onAnimEnd();
|
||||
|
||||
// });
|
||||
},
|
||||
height: 200,
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
// color: Colors.deepPurple.withOpacity(0.3),
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.red.withOpacity(op3),
|
||||
Colors.red.withOpacity(op3)
|
||||
],
|
||||
),
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
AnimatedContainer(duration: opDuration,child: child)
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
Widget NeonButton(
|
||||
{required void Function() onPressed,
|
||||
required String text,
|
||||
double width = 250,
|
||||
double height = 50,
|
||||
double fontSize = 20,
|
||||
List<Color>? colors,
|
||||
Widget? trailing,
|
||||
Widget? heading}) {
|
||||
if(colors == null){
|
||||
colors = [Colors.blue, Colors.deepPurple];
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: InkWell(
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.deepPurple.withOpacity(0.4),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 50,
|
||||
offset: Offset(0, 0),
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.white.withOpacity(0.6),
|
||||
spreadRadius: 0.3,
|
||||
offset: Offset(0.2, -0.3))
|
||||
],
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment(0, -1),
|
||||
end: Alignment(0, 1.2),
|
||||
colors: colors),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
(heading == null) ? Container() : heading,
|
||||
Center(child: Text(text, style: TextStyle(fontSize: fontSize))),
|
||||
(trailing == null) ? Container() : trailing
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class GradientText extends StatelessWidget {
|
||||
const GradientText(
|
||||
{required this.text,
|
||||
required this.gradient,
|
||||
this.style,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
final Gradient gradient;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ShaderMask(
|
||||
blendMode: BlendMode.srcIn,
|
||||
shaderCallback: (bounds) => gradient.createShader(
|
||||
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
|
||||
),
|
||||
child: Text(text, style: style),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user