Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make documentation more clear on how to use custom logs and colors with the TalkerScreen #354

@MeyerOppelt

Description

@MeyerOppelt

My feature request comes from issue #349 where a user was confused about how to use the custom log feature in talker_flutter.

I'd like to see better documentation regarding the custom logs, especially because the example app hosted by the talker team uses a different approach than the documentation. In the team's documentation custom logs types are created by the following code:

talker/README.md

Lines 185 to 199 in ab547ee

class YourCustomLog extends TalkerLog {
YourCustomLog(String message) : super(message);
@override
String get title => 'Custom';
@override
String? get key => 'custom_log_key';
@override
AnsiPen get pen => AnsiPen()..xterm(121);
}
final talker = Talker();
talker.logCustom(YourCustomLog('Something like your own service message'));

However, in the team's example app, the way they use getters in the custom log type is the following:

class GoodLog extends TalkerLog {
GoodLog(String super.message);
/// Log title
@override
String get title => 'good';
/// Log key
@override
String get key => getKey;
/// Log color
@override
AnsiPen get pen => getPen;
static get getPen => AnsiPen()..xterm(121);
static get getKey => 'good';
}

This makes it confusing for people who are first starting to use custom logs with the talker_flutter package's TalkerScreen. If you were to use the code in the documentation, you get errors when trying to get the custom log keys, which I believe has been overlooked.

TalkerScreenTheme(
  /// Your custom log colors
  logColors: {
    TalkerLogType.error.key: Colors.redAccent,
    TalkerLogType.info.key: Colors.grey,
    RequestLog.getKey: Colors.pink,
    // correct implementation with no errors, from the example app
    ResponseLog.getKey: Colors.green,
    // error right here
    YourCustomLog.key: Colors.black
  },
)
Image

Instead, I believe that documentation should use the approach taken by the designer of the example app, where getters are used, and it is more clear that you should be using the getKey static string. Example of which, from the demo app listed below.

final talkerTheme = TalkerScreenTheme(logColors: {
GoodLog.getKey: const Color(0xff4CAF50),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelated to core packages (talker, talker_logger, talker_flutter)documentationImprovements or additions to documentationopen-to-contributionYou can open Pull-request to resolve this issuetalker_flutterRelated to talker_flutter package

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions