Вы можете использовать виджет Row с комбинацией Container
и LinearProgressIndicator
Поскольку я не знаком с остальной частью приложения, я предоставлю образец дерева виджетов для справки.
Дерево виджетов:
Row(
children: <Widget>[
Container([...]),
LinearProgressIndicator([...]),
Container([...]),
LinearProgressIndicator([...]),
Container([...]),
]
)
Чтобы сделать круговой Container
вместе с переходом color
,
AnimatedContainer(
duration: Duration(seconds:2),
width: x,
height: x,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(x/2),
// color: (progressvalue>200)? Colors.yellow : Colors.grey
)
)
Пример логики:
Container1 - progressValue > 0
LinearProgressIndicator - (progressValue-10) to 110
Container2 - progressValue > 110
LinearProgressIndicator - (progressValue-120) to 220
Container2 - progressValue > 220
Приведенная выше логика может быть изменена по вашему усмотрению.
Рабочий пример для LinearProgressIndicator
,
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
debugShowCheckedModeBanner: false,
home: new MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
MyAppState createState() => new MyAppState();
}
class MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Slider Demo'),
),
body: new Container(
color: Colors.blueAccent,
padding: new EdgeInsets.all(32.0),
child: new ProgressIndicatorDemo(),
),
);
}
}
class ProgressIndicatorDemo extends StatefulWidget {
@override
_ProgressIndicatorDemoState createState() =>
new _ProgressIndicatorDemoState();
}
class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo>
with SingleTickerProviderStateMixin {
AnimationController controller;
Animation<double> animation;
@override
void initState() {
super.initState();
controller = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
animation = Tween(begin: 0.0, end: 1.0).animate(controller)
..addListener(() {
setState(() {
// the state that has changed here is the animation object’s value
});
});
controller.repeat();
}
@override
void dispose() {
controller.stop();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Center(
child: new Container(
child: LinearProgressIndicator( value: animation.value,),
)
);
}
}
person
Son of Stackoverflow
schedule
02.09.2019