toml_viewer 2.0.0
toml_viewer: ^2.0.0 copied to clipboard
A Flutter widget for displaying TOML files as interactive, searchable, lazily-rendered tree views with partial-parse error reporting, a raw source view, light/dark theming, custom styling, and extensi [...]
Changelog #
2.0.0 #
A correctness and performance release. The rendering pipeline was rebuilt around a typed node model, three long-standing bugs were fixed, and the configuration API was reorganised.
Fixed #
collapseAll()did nothing to untouched nodes. It calledMap.updateAll, which only affects paths already toggled; every node that had merely been rendered kept the default-expanded fallback and stayed open.expandAll()had the mirror-image bug withdefaultExpanded: false. Both now flip the fallback itself.- Arrays were labelled
Array of Table[n]. The element type was read from the list rather than its elements, so[1, 2, 3]reportedTable. Arrays now reportArray of int[3],Array of mixed[2], orArray[0]. - The declared Flutter minimum was unbuildable.
Color.withValuesandColor.r/g/brequire Flutter 3.27 / Dart 3.6, but the package advertised Flutter 3.10. The constraint now matches reality. - The partial-parse section splitter mangled valid TOML. Any line starting
with
[was treated as a table header, so multi-line arrays ([1, 2],) and bracketed lines inside"""blocks were split apart and reported as phantom errors. The splitter is now header-shaped and string-aware. - Duplicate keys were silently resolved. Sections were deep-merged with
"later wins" and no report. Collisions now produce a
TomlParseError. - Monospaced text fell back to the system default on iOS, macOS, and web,
where
'monospace'is not a real family. UseTomlViewerStyle.monospaceFallbackfor a stack that resolves everywhere. - Row semantics were not reachable. Each row is now a single accessible node with a label, a tap action, and an expanded state.
TomlViewasserted without aMaterialancestor. Rows useInkWell, so dropping the viewer into a plainContaineror a custom shell threw. It now supplies its own transparentMaterial.
Added #
- Lazy rendering. The tree is flattened into the list of currently visible
rows and rendered with a
SliverList.builder, so cost scales with the viewport rather than the document. A 5,000-key file now builds a few dozen rows instead of all 5,000. - Search.
TomlView(searchQuery: ...)filters to matching keys and values, keeps and force-expands the ancestors of each hit, and highlights the match.caseSensitiveSearchopts into exact matching. - Raw source view.
TomlView(mode: TomlViewMode.source)shows the original text with line numbers and error lines highlighted. Also available directly asTomlSourceView. - Clipboard support. Long-press copies the value, the path, or both, per
TomlViewerConfig.copyMode;onValueCopiedreports what was written. The tree is wrapped in aSelectionAreaunlessenableTextSelectionis false. - New sources.
TomlView.loader(() async => ...)covers files, HTTP, and anything else without this package taking an I/O dependency;TomlView.stream(...)re-parses on every emission. - A public node model.
TomlNode,TomlTableNode,TomlArrayNode, andTomlLeafNodeexpose the parsed tree with stable paths and lazy children;flattenVisibleturns it into rows.TomlFormatexposes the value formatting helpers, andTomlParseris now exported soTomlParseResultcan actually be obtained without the widget. - Expansion-state persistence.
TomlExpandController.overridesandrestoresave and reload what the user opened;expandToPathreveals a node by opening every ancestor;setExpandedsets an explicit state. - Value truncation.
TomlViewerStyle.maxValueLines(default1) andmaxValueLength(default512) keep one enormous string from dominating the view. maxRenderedErrors(default100) caps the rendered error list.emptyBuilder,padding,shrinkWrap,physics, andscrollControlleronTomlView.clear()onTomlViewerConfigandTomlViewerStyle, which can reset a field tonull— somethingcopyWithcannot express.- Value equality on
TomlViewerConfig,TomlViewerStyle, andTomlViewerColors. - CI running format, analyze, tests, goldens, the example, and a publish dry-run; golden tests covering seven rendered states.
Changed — breaking #
-
TomlViewerThemenow works. It was exported and documented but never read by any widget.TomlView.configis nullable and resolves as: the widget's ownconfig, then the nearestTomlViewerTheme, then a palette matching the ambientTheme. The theme's separatestyleproperty is gone — styling lives inconfig.style, so there is one place to set it.// Before TomlViewerTheme(config: ..., style: TomlViewerStyle(indentation: 20), child: ...) // After TomlViewerTheme(config: TomlViewerConfig(style: TomlViewerStyle(indentation: 20)), child: ...) -
Colours moved into
TomlViewerColors. The ten colour parameters onTomlViewerConfigare now onecolorsfield, which is what let.light(),.dark(), and.of()stop repeating an identical parameter list. Read-only getters (valueColor,keyColor, …) remain, deprecated, until 3.0.0.// Before TomlViewerConfig(valueColor: Colors.red, keyColor: Colors.teal) // After TomlViewerConfig(colors: TomlViewerColors(value: Colors.red, tableKey: Colors.teal)) -
TomlViewerConfig.of(context)takes only a context. ChaincopyWithfor anything else:TomlViewerConfig.of(context).copyWith(expandMode: false). -
createConfusedCopy()is gone. It randomised every colour and had no place in a viewer's public API. -
maxValueLinesdefaults to1. Values ellipsise instead of wrapping; passstyle.clear(maxValueLines: true)for the old behaviour. -
Empty tables and arrays are no longer expandable, since there is nothing to reveal.
-
Builder and callback signatures take
Object?instead ofdynamic, as a consequence of enablingstrict-raw-types. -
TomlObjectViewerandTomlArrayViewerare replaced by the single internalTomlRow.TomlUtilsis replaced byTomlFormat.
Documentation #
- A README rebuilt for both newcomers and integrators: a demo GIF rendered from
the real widget, three theme-aware SVG diagrams (what it does, the rendering
pipeline, the anatomy of a row), a troubleshooting FAQ, and a migration
section. Both are generated —
tool/make_gif.shandtool/make_diagrams.py.
Packaging #
.pubignoredrops the example's platform scaffolding, the test suite, and the documentation assets from the published archive, taking it from 960 KB to 715 KB — almost all of which is now the pub.dev screenshots themselves.- Stricter analysis:
strict-casts,strict-inference,strict-raw-types, andpublic_member_api_docsamong others.
1.0.0 #
- Initial stable release: tree view, partial-parse error reporting, light/dark themes, custom styling, interaction callbacks, and builder support.
