Skip to content

Проблема с TalkerSettings - titles,colors #480

@RocksteadyDog

Description

@RocksteadyDog

Приветствую!

При использовании

  final talker = Talker(
    settings: TalkerSettings(titles: {TalkerKey.info: "Information"}),
  );

  final talker2 = Talker();

  talker.info('Ordering from other restaurant...');
  talker2.info('Ordering from other restaurant...');

получаю оба заголовка "Information":

Image

хотя ожидаю только у первого:
Image

Если посмотреть файл TalkerSettings поля и конструктор, то данное поведение ожидаемо:

  final Map<String, String> titles = _defaultTitles;
  final Map<String, AnsiPen> colors = _defaultColors;
    if (colors != null) {
      _defaultColors.addAll(colors);
    }
    if (titles != null) {
      _defaultTitles.addAll(titles);
    }
    this.colors.addAll(_defaultColors);
    this.titles.addAll(_defaultTitles);

И собственно данное поведение ожидаемо или это багуличка? Если баг и я правильно понимаю замысел, тогда должно быть так:

  final Map<String, String> titles = Map.from(_defaultTitles);
  final Map<String, AnsiPen> colors = Map.from(_defaultColors);
  if (colors != null) {
    this.colors.addAll(colors);
  }
  if (titles != null) {
    this.titles.addAll(titles);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions