代码拉取完成,页面将自动刷新
带刻度的圆形进度条
import 'dart:async';
import 'package:circle_indicate_with_scale/custom.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int progress = 0;
Timer? timer;
bool isPlay = false;
@override
void initState() {
super.initState();
}
void _incrementCounter() {
setState(() {
isPlay = !isPlay;
});
if (isPlay) {
timer = Timer.periodic(Duration(milliseconds: 200), (timer) {
setState(() {
progress += 1;
if (progress > 100) {
progress = 0;
}
print(progress);
});
});
} else {
timer?.cancel();
}
}
@override
void dispose() {
timer!.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: CircleIndicateWithScale(
width: 300,
progress: progress,
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: isPlay ? Icon(Icons.stop) : Icon(Icons.play_arrow),
),
);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。