Skip to content

feat!: val_highlight_flutter 1.0.0 — widgets-only core, stable widget API - #5

Merged
saminsohag merged 1 commit into
mainfrom
feature/flutter-1.0
Nov 17, 2026
Merged

saminsohag merged 1 commit into
mainfrom
feature/flutter-1.0

Conversation

@saminsohag

Copy link
Copy Markdown
Collaborator

Summary

Step 2 of 2 for the 1.0.0 release: makes val_highlight_flutter safe to freeze. Builds on #4 (merged). Version bumped to 1.0.0; requires val_highlight 1.0.0.

Please don't publish yet — publish val_highlight 1.0.0 first, then this package.

Breaking changes (all in docs/upgrading.mdx with before/after code)

  • Material is optional. The main library needs only Flutter's widgets layer, so CodeView, HighlightTextController and CodeTheme work under package:flutter/material.dart, material_ui, Cupertino or anything else. 0.1.2 threw "No MaterialLocalizations found" / "No Material widget found" in a flutter/material.dart app.
  • CodeField moved to package:val_highlight_flutter/material.dart (which re-exports everything); it is still built on material_ui.
  • CodeTheme is an InheritedTheme holding CodeThemeData (light, dark, brightness, textStyle, padding, lineNumbers), instead of a ThemeExtension. The brightness is CodeThemeData.brightness or the platform's; apps with their own light/dark toggle set it in MaterialApp.builder from Theme.of(context).brightness.
  • CodeView no longer adds its own SelectionArea (selectable is gone); wrap it in one, as with Flutter's Text.
  • CodeView.textStyle → style; CodeField.margin → styleMargin; CodeField.lineNumbers falls back to CodeThemeData.
  • gutterBuilder / lineBuilder take a CodeLineDetails (line, lineNumber, highlighted) instead of positional args, so fields can be added later without breaking callers.
  • HighlightTextController.window is internal.
  • CodeEditingFormatter is immutable; its state lives on the controller, so one created in build keeps working.
  • Final classes: CodeToken, CodeEditing, CodeHighlighter, CodeEditingFormatter, CodeThemeData, the three intents.

Fixes (each with a regression test)

  • CodeView rows cut off at large text scales (line height ignored the text scaler).
  • Code laid out right to left in RTL apps; both widgets now force LTR.
  • Edits made by CodeField shortcuts (Tab, Ctrl+/, Enter) skipped inputFormatters.
  • Screen readers read CodeView's line numbers.
  • A CodeEditingFormatter created in build forgot its auto-closed pairs (f())).
  • Background highlight errors were dropped; now reported to FlutterError.
  • CodeField.defaultShortcuts returned a new map every build.

Also

  • Core: HighlightResult.lineAt(offset) (additive) replaces three copies of the same binary search.
  • New test/flutter_material_test.dart: the widgets-layer library inside a package:flutter/material.dart app.
  • Example app: CodeTheme in MaterialApp.builder, gallery and large file wrapped in SelectionArea.
  • Docs: Flutter half of the upgrade guide, pages updated for the new API, new troubleshooting entries. The API completeness check now counts a table row only when a cell is the symbol itself (a description that merely mentions a name no longer counts).
  • screenshots/code-view.png regenerated: the committed one still showed the pre-material_ui import in its sample code.

Related issue

None found.

Checklist

  • just check passes (format, analyze, tests on the VM and JavaScript)
  • Tests added or updated — every fixed bug has a regression test
  • Golden snapshots: no changes
  • Breaking changes called out above
  • CHANGELOG.md: ## 1.0.0 entry in val_highlight_flutter; lineAt added to val_highlight's 1.0.0 entry
  • Docs updated

Verification

  • just check (pinned Flutter 3.44.2): 485 VM and 373 JavaScript core tests, 106 Flutter tests, example test; analyzer clean.
  • Integration tests on macOS (app_test, editor_test): pass.
  • Latest stable Flutter 3.50.0 with upgraded dependencies (material_ui 1.11): analyzer clean, all tests pass, flutter build web works, pub publish --dry-run 0 warnings for both packages.
  • All 19 docs screenshots regenerate byte-identical.

… API

Make the Flutter package safe to freeze at 1.0.

Material is optional:
- The main library needs only Flutter's widgets layer, so CodeView,
  HighlightTextController and CodeTheme work under
  package:flutter/material.dart, material_ui, Cupertino or anything else
  (0.1.2 threw in a flutter/material app).
- CodeField, built on material_ui, moves to
  package:val_highlight_flutter/material.dart, which exports everything.
- CodeTheme is an InheritedTheme holding CodeThemeData; brightness comes
  from CodeThemeData.brightness or the platform. CodeView no longer adds
  its own SelectionArea (selectable is gone).

Stable API:
- gutterBuilder/lineBuilder take a CodeLineDetails.
- CodeView.textStyle -> style; CodeField.margin -> styleMargin;
  CodeField.lineNumbers falls back to CodeThemeData.
- HighlightTextController.window is internal.
- CodeEditingFormatter is immutable; its state lives on the controller, so
  one created in build keeps working.
- Final classes: CodeToken, CodeEditing, CodeHighlighter,
  CodeEditingFormatter, CodeThemeData, the intents.

Fixes: rows cut off at large text scales; code laid out right to left in
RTL apps; shortcut edits skipping inputFormatters; screen readers reading
line numbers; background highlight errors dropped; defaultShortcuts
rebuilt on every build.

Core: HighlightResult.lineAt replaces three copies of the same search.

Docs: Flutter half of the upgrade guide; pages updated for the new API;
troubleshooting entries for theming, selection and CodeField; the API
completeness check counts a table row only when a cell is the symbol.
@saminsohag
saminsohag merged commit 6319268 into main Nov 17, 2026
1 check passed
@saminsohag
saminsohag deleted the feature/flutter-1.0 branch November 17, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant