Score constructor

Score(
  1. Entity entity,
  2. String score, {
  3. bool addNew = true,
  4. List<Widget>? commands,
  5. String type = 'dummy',
})

The Score class is the basis for setting values, calculating with scores and checking the values. It implements one base class with no functionality and several methods to do actions:

constructor
Entity the entity within the scoreboard
String the name of the objective
addNew bool whether it should add the scoreboard itself if it does not exist(default = true)
Score(Entity.Selected(),'score',addNew: true)

Implementation

Score(
  this.entity,
  this.score, {
  bool addNew = true,
  List<Widget>? commands,
  this.type = 'dummy',
}) {
  if (commands != null) _commands = commands;
  if (addNew) {
    _commands.add(
      Scoreboard(score, type: type),
    );
  }
  if (Scoreboard.prefix != null && !score.contains(Scoreboard.prefix!)) {
    score = Scoreboard.prefix! + score;
  }
}