Flutter LinearProgressIndicator使用指南分析

  import 'package:flutter/material.dart';

  class RoundedLinearProgressIndicator extends StatelessWidget {

  final double value;

  final Color backgroundColor;

  final Color valueColor;

  final double height;

  final double borderRadius;

  const RoundedLinearProgressIndicator({

  Key? key,

  required this.value,

  this.backgroundColor = Colors.grey,

  this.valueColor = Colors.blue,

  this.height = 10.0,

  this.borderRadius = 5.0,

  }) : super(key: key);

  @override

  Widget build(BuildContext context) {

  return Stack(

  children: [

  Container(

  height: height,

  decoration: BoxDecoration(

  color: backgroundColor,

  borderRadius: BorderRadius.circular(borderRadius),

  ),

  ),

  FractionallySizedBox(

  widthFactor: value,

  child: Container(

  height: height,

  decoration: BoxDecoration(

  color: valueColor,

  borderRadius: BorderRadius.circular(borderRadius),

  ),

  ),

  ),

  ],

  );

  }

  }