TomlViewerStyle class
Complete text and layout styling for the TOML viewer.
This class controls every visual aspect beyond colours — font sizes, weights, families, indentation, spacing, separators, icons, and how long values are truncated.
TomlView(
content: toml,
config: TomlViewerConfig.of(context).copyWith(
style: const TomlViewerStyle(
rootKeyStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
indentation: 20,
separator: ' : ',
),
),
)
Clearing a field
copyWith only ever sets values — passing null means "leave
unchanged". To remove a value, use clear:
// Hide the expand icons entirely:
style.clear(collapsedIcon: true, expandedIcon: true);
- Annotations
Constructors
- TomlViewerStyle({TextStyle? rootKeyStyle, TextStyle? nonRootKeyStyle, TextStyle? tableKeyStyle, TextStyle? valueStyle, TextStyle? separatorStyle, TextStyle? typeStyle, TextStyle? arrayIndexStyle, TextStyle? arrayExpandableStyle, TextStyle? searchMatchStyle, double indentation = 14.0, double rowSpacing = 4.0, double rowVerticalPadding = 4.0, String separator = ' = ', double separatorGap = 3.0, int? maxValueLines = 1, int? maxValueLength = 512, IconData? collapsedIcon = Icons.chevron_right, IconData? expandedIcon = Icons.expand_more, double expandIconSize = 16.0, Color? expandIconColor})
-
Creates a style. Every parameter has a sensible default.
const
Properties
- arrayExpandableStyle → TextStyle?
-
Style for expandable array element labels.
final
- arrayIndexStyle → TextStyle?
-
Style for array element labels like
items [0].final - collapsedIcon → IconData?
-
Icon shown next to expandable entries when collapsed.
Set to
nullto hide the icon.final - expandedIcon → IconData?
-
Icon shown next to expandable entries when expanded.
Set to
nullto hide the icon.final - expandIconColor → Color?
-
Colour of the expand/collapse icon. Uses the palette's symbol colour
when null.
final
- expandIconSize → double
-
Size of the expand/collapse icon.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- indentation → double
-
Indentation in logical pixels per nesting level.
final
- maxValueLength → int?
-
Maximum number of characters rendered for a value.
final
- maxValueLines → int?
-
Maximum number of lines a value may occupy before being ellipsised.
final
- nonRootKeyStyle → TextStyle?
-
Style for nested (non-root) keys.
final
- rootKeyStyle → TextStyle?
-
Style for top-level keys. Colour is applied from the palette if not set.
final
- rowSpacing → double
-
Vertical spacing between rows.
final
- rowVerticalPadding → double
-
Vertical padding inside each row.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchMatchStyle → TextStyle?
-
Style applied to the substring matching the active search query.
final
- separator → String
-
The separator string between key and value (default
" = ").final - separatorGap → double
-
Horizontal gap between separator and value.
final
- separatorStyle → TextStyle?
-
Style for the separator text (default
" = ").final - tableKeyStyle → TextStyle?
-
Style for keys whose value is a table.
final
- typeStyle → TextStyle?
-
Style for type labels like
Array of int[3],Table{2}.final - valueStyle → TextStyle?
-
Style for primitive values.
final
Methods
-
clear(
{bool rootKeyStyle = false, bool nonRootKeyStyle = false, bool tableKeyStyle = false, bool valueStyle = false, bool separatorStyle = false, bool typeStyle = false, bool arrayIndexStyle = false, bool arrayExpandableStyle = false, bool searchMatchStyle = false, bool maxValueLines = false, bool maxValueLength = false, bool collapsedIcon = false, bool expandedIcon = false, bool expandIconColor = false}) → TomlViewerStyle -
Returns a copy with each field flagged
truereset tonull. -
copyWith(
{TextStyle? rootKeyStyle, TextStyle? nonRootKeyStyle, TextStyle? tableKeyStyle, TextStyle? valueStyle, TextStyle? separatorStyle, TextStyle? typeStyle, TextStyle? arrayIndexStyle, TextStyle? arrayExpandableStyle, TextStyle? searchMatchStyle, double? indentation, double? rowSpacing, double? rowVerticalPadding, String? separator, double? separatorGap, int? maxValueLines, int? maxValueLength, IconData? collapsedIcon, IconData? expandedIcon, double? expandIconSize, Color? expandIconColor}) → TomlViewerStyle - 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
Constants
- fallback → const TomlViewerStyle
- Default style with no text style overrides.
- monospace → const TomlViewerStyle
- A monospaced style suited to configuration files.
-
monospaceFallback
→ const List<
String> - Font families to fall back through when asking for a monospaced face.