반응형
Flutter 플러터 Progress bar 진행바 간단 구현
import 'package:flutter/material.dart';
class MyWidget extends StatefulWidget {
const MyWidget({Key? key}) : super(key: key);
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
double _progressValue = 0.0;
void _updateProgress() {
setState(() {
_progressValue += 0.1;
if (_progressValue >= 1.0) {
_progressValue = 0.0;
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Linear Progress Indicator Example'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
LinearProgressIndicator(
value: _progressValue,
),
SizedBox(height: 20),
ElevatedButton(
child: Text('Update Progress'),
onPressed: _updateProgress,
),
],
),
),
);
}
}
반응형