ParentProgress class

A class that aggregates multiple child progress instances and calculates a total progress with weighted contributions from each child. This class is particularly useful in scenarios where multiple concurrent operations contribute to a single overarching goal, such as downloading multiple files, processing multiple data streams, or completing stages of a complex task. Inherits functionalities from ChildProgress.

Features include:

  • Dynamic weighting of each child's progress contribution, allowing for flexible prioritization of tasks based on their importance or impact on the overall process.
  • Real-time calculation and notification of total progress, providing a comprehensive view of the combined progress of all children.
  • Easy integration with UI components to display collective progress, enhancing user experience by showing unified progress details.

The class uses _flexFactors to determine the weight of each child progress's contribution to the total progress, offering a customizable approach to progress aggregation. This mechanism ensures that some tasks can be prioritized higher than others, depending on the specified weights, making the class adaptable to a wide range of applications.

Inheritance

Constructors

ParentProgress(List<ChildProgress> children, List<int> flexFactors, {String? uniqueName})
Initializes a new ParentProgress with a list of child progress objects and their corresponding flex factors. Each child progress's percentageNotifier is included implicitly via the children list, and flexFactors determines the importance or weight of each child's progress. Throws an ArgumentError if the lists' lengths do not match.

Properties

getChildren List<ChildProgress>
Returns a list of child progress instances, each representing a progress tracking component.
no setter
getFlexFactors List<int>
Returns a list of flex factors that determine the weight of each child progress's contribution.
no setter
getProgressWeights List<double>
Returns a list of progress weights calculated from each child's current percentage, influenced by the associated flex factor.
no setter
hashCode int
The hash code for this object.
no setterinherited
onAddSlice bool
getter/setter pair
onDeleteSlice bool
getter/setter pair
percentageNotifier ValueNotifier<int>
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uniqueName String?
getter/setter pairinherited

Methods

addSlice({required ChildProgress child, required int flexFactor}) Future<void>
Waits for any preceding deleteSlice and addSlice operations. It does this without needing to be called with await.
deleteSlice({required ChildProgress child}) Future<void>
Waits for any preceding deleteSlice and addSlice operations. It does this without needing to be called with await.
dispose() → void
Cleans up by removing all listeners from child progress notifiers and disposing of the total percentage notifier. It's essential to call this method to free up resources when the ParentProgress instance is no longer needed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited