withLoading method
让部件进入加载状态
Implementation
Widget withLoading(bool isLoading,
{double size = 16, Color color = const Color(0xff027DFD)}) {
if (!isLoading) return this;
return Stack(
children: [
animate().fade(end: 0.6, duration: 400.milliseconds), // 原组件
Positioned.fill(
child: Container(
color: Colors.transparent,
child: Center(
child: SizedBox(
width: size,
height: size,
child: CircularProgressIndicator(color: color)), // 中间的加载指示器
),
),
).animate().fadeIn(duration: 400.milliseconds),
],
);
}