Spaces:
Build error
Build error
File size: 2,409 Bytes
3382f47 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import 'package:auto_gpt_flutter_client/constants/app_colors.dart';
import 'package:flutter/material.dart';
class LoadingIndicator extends StatefulWidget {
final bool isLoading;
const LoadingIndicator({Key? key, required this.isLoading}) : super(key: key);
@override
_LoadingIndicatorState createState() => _LoadingIndicatorState();
}
class _LoadingIndicatorState extends State<LoadingIndicator>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
double width =
(constraints.maxWidth >= 1000) ? 850 : constraints.maxWidth - 65;
return SizedBox(
width: width,
height: 4.0,
child: widget.isLoading
? AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return ShaderMask(
shaderCallback: (rect) {
return LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Colors.grey[400]!,
AppColors.primaryLight,
Colors.white,
Colors.grey[400]!,
],
stops: [
_controller.value - 0.5,
_controller.value - 0.25,
_controller.value,
_controller.value + 0.25,
],
).createShader(rect);
},
child: Container(
width: width,
height: 4.0,
color: Colors.white,
),
);
},
)
: Container(
color: Colors.grey[400],
),
);
},
);
}
}
|