TomlViewerConfig class

Configuration for the appearance, behaviour, and extensibility of the TOML viewer.

// Auto-detect light/dark from the ambient theme:
TomlView(content: toml, config: TomlViewerConfig.of(context))

// With style overrides:
TomlView(
  content: toml,
  config: TomlViewerConfig.of(context).copyWith(
    style: const TomlViewerStyle(indentation: 24, separator: ' : '),
  ),
)

Clearing a field

copyWith only ever sets values. To remove one, use clear: config.clear(onValueTap: true).

Annotations

Constructors

TomlViewerConfig({bool expandMode = true, TomlViewerColors colors = TomlViewerColors.light, TomlViewerStyle style = TomlViewerStyle.fallback, bool showInlineErrors = true, TextStyle? errorMessageStyle, void onParseErrors(List<TomlParseError> errors)?, TomlKeyBuilder? keyBuilder, TomlValueBuilder? valueBuilder, TomlRowBuilder? rowBuilder, TomlValueCallback? onValueTap, TomlValueCallback? onValueLongPress, TomlCopyMode copyMode = TomlCopyMode.value, TomlValueCallback? onValueCopied, bool enableTextSelection = true, int maxRenderedErrors = 100})
Creates a configuration. Every parameter has a sensible default.
const
TomlViewerConfig.dark({bool expandMode = true, TomlViewerStyle style = TomlViewerStyle.fallback, bool showInlineErrors = true, TextStyle? errorMessageStyle, void onParseErrors(List<TomlParseError> errors)?, TomlKeyBuilder? keyBuilder, TomlValueBuilder? valueBuilder, TomlRowBuilder? rowBuilder, TomlValueCallback? onValueTap, TomlValueCallback? onValueLongPress, TomlCopyMode copyMode = TomlCopyMode.value, TomlValueCallback? onValueCopied, bool enableTextSelection = true, int maxRenderedErrors = 100})
Dark-mode colour scheme.
const
TomlViewerConfig.light({bool expandMode = true, TomlViewerStyle style = TomlViewerStyle.fallback, bool showInlineErrors = true, TextStyle? errorMessageStyle, void onParseErrors(List<TomlParseError> errors)?, TomlKeyBuilder? keyBuilder, TomlValueBuilder? valueBuilder, TomlRowBuilder? rowBuilder, TomlValueCallback? onValueTap, TomlValueCallback? onValueLongPress, TomlCopyMode copyMode = TomlCopyMode.value, TomlValueCallback? onValueCopied, bool enableTextSelection = true, int maxRenderedErrors = 100})
Light-mode colour scheme.
const
TomlViewerConfig.of(BuildContext context)
A config whose palette follows the ambient Theme's brightness.
factory

Properties

arrayExpandableColor → Color
Deprecated: use colors.arrayExpandable.
no setter
arrayIndexColor → Color
Deprecated: use colors.arrayIndex.
no setter
colors → TomlViewerColors
The colour palette. See TomlViewerColors.light and TomlViewerColors.dark.
final
copyMode → TomlCopyMode
What a long-press copies to the clipboard. Defaults to TomlCopyMode.value.
final
enableTextSelection → bool
Whether the tree is wrapped in a SelectionArea so text can be selected and copied with the usual platform gestures.
final
errorHighlightColor → Color
Deprecated: use colors.errorHighlight.
no setter
errorMessageStyle → TextStyle?
Optional style override for error annotation text.
final
errorTextColor → Color
Deprecated: use colors.errorText.
no setter
expandMode → bool
Whether nodes start expanded (true) or collapsed (false).
final
hashCode → int
The hash code for this object.
no setteroverride
keyBuilder → TomlKeyBuilder?
Custom builder for key labels. Return null for default rendering.
final
keyColor → Color
Deprecated: use colors.tableKey.
no setter
maxRenderedErrors → int
Maximum number of parse errors rendered before the list is summarised.
final
nonRootKeyColor → Color
Deprecated: use colors.nonRootKey.
no setter
onParseErrors → void Function(List<TomlParseError> errors)?
Called when parse errors are encountered.
final
onValueCopied → TomlValueCallback?
Called after copyMode has written to the clipboard, so you can show a confirmation. Receives the text that was copied as the value argument.
final
onValueLongPress → TomlValueCallback?
Called when a value is long-pressed.
final
onValueTap → TomlValueCallback?
Called when a value (not a table/array header) is tapped.
final
rootKeyColor → Color
Deprecated: use colors.rootKey.
no setter
rowBuilder → TomlRowBuilder?
Custom builder for entire key-value rows. Return null for default.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showInlineErrors → bool
Whether to show the error banner and inline error annotations.
final
style → TomlViewerStyle
Text and layout styling (fonts, spacing, indentation, icons).
final
symbolColor → Color
Deprecated: use colors.symbol.
no setter
typeTextColor → Color
Deprecated: use colors.type.
no setter
valueBuilder → TomlValueBuilder?
Custom builder for value display. Return null for default rendering.
final
valueColor → Color
Deprecated: use colors.value.
no setter

Methods

clear({bool errorMessageStyle = false, bool onParseErrors = false, bool keyBuilder = false, bool valueBuilder = false, bool rowBuilder = false, bool onValueTap = false, bool onValueLongPress = false, bool onValueCopied = false}) → TomlViewerConfig
Returns a copy with each field flagged true reset to null.
copyWith({bool? expandMode, TomlViewerColors? colors, TomlViewerStyle? style, bool? showInlineErrors, TextStyle? errorMessageStyle, void onParseErrors(List<TomlParseError> errors)?, TomlKeyBuilder? keyBuilder, TomlValueBuilder? valueBuilder, TomlRowBuilder? rowBuilder, TomlValueCallback? onValueTap, TomlValueCallback? onValueLongPress, TomlCopyMode? copyMode, TomlValueCallback? onValueCopied, bool? enableTextSelection, int? maxRenderedErrors}) → TomlViewerConfig
Creates a copy with optionally updated fields.
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.
override