rules/utils/config_utils library

Type-safe helpers for reading rule configuration from analysis_options.yaml.

Each helper extracts a value from the rule's JSON config map, returning null on type mismatch instead of throwing. This lets rule constructors use ?? to fall back to defaults cleanly.

Functions

configBool(Map<String, Object?> json, String key) bool?
Reads a bool value from json at key. Returns null if missing or wrong type.
configDouble(Map<String, Object?> json, String key) double?
Reads a double value from json at key. Accepts both int and double. Returns null if missing or wrong type.
configInt(Map<String, Object?> json, String key) int?
Reads an int value from json at key. Returns null if missing or wrong type.
configList(Map<String, Object?> json, String key) List?
Reads a raw List from json at key. Returns null if missing or wrong type.
configMapList(Map<String, Object?> json, String key) List<Map<String, dynamic>>?
Reads a List<Map<String, dynamic>> from json at key. Returns null if missing or wrong type.
configString(Map<String, Object?> json, String key) String?
Reads a String value from json at key. Returns null if missing or wrong type.
configStringList(Map<String, Object?> json, String key) List<String>?
Reads a List<String> from json at key. Returns null if missing or wrong type.
optionsJson(Map<String, Object?>? options) Map<String, Object?>
Extracts the JSON config map from options, returning an empty map if null.