flutter 渲染圖形驗(yàn)證碼幅聘,點(diǎn)擊刷新狼犯。加載過渡等余寥。
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:wegame_msmk/network/api.dart';
/// 圖片驗(yàn)證碼
class ImageVerifyCode extends StatefulWidget {
final String url;
final double? width;
final double? height;
const ImageVerifyCode({super.key, required this.url, this.width, this.height});
@override
State<ImageVerifyCode> createState() => _ImageVerifyCodeState();
}
class _ImageVerifyCodeState extends State<ImageVerifyCode> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
setState(() {});
},
child: Container(
width: widget.width ?? 80,
height: widget.height ?? 35,
color: const Color(0xFF44341D),
child: Image.network(
'${widget.url}?t=${DateTime.now().millisecondsSinceEpoch}',
fit: BoxFit.cover,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return const Center(
child:
CupertinoActivityIndicator(radius: 10, color: Colors.white),
);
},
),
),
);
}
}