패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.1.2

val_highlight_flutter

구문 강조 코드용 플러터 위젯: 표시용 CodeView와 편집용 CodeField, 55개 언어, 테마 및 부드러운 대용량 파일 지원

AndroidiOSLinuxmacOSWebWindows
30일 다운로드
6.7만
좋아요
8
Pub 점수
160

패키지 설치

flutter pub add val_highlight_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

ValHighlightFlutter는 플러터 앱용 구문 강조 코드 표시 및 편집 위젯을 제공합니다. CodeView는 55개 언어를 지원하고 사용자 정의 테마를 적용할 수 있으며, CodeField는 실시간 강조 기능을 갖춘 상호작용식 코드 편집을 가능하게 합니다. 성능 최적화로 웹, 모바일, 데스크톱 등 모든 플랫폼에서 대용량 파일을 원활하게 처리합니다. 문서 도구, IDE 또는 깔끔하고 가독성이 좋은 코드 표시가 필요한 교육용 앱에 이상적입니다.

사용 사례

  • 코드 문서 뷰어
  • 인터랙티브 코딩 튜토리얼
  • IDE 유사 코드 편집기
  • 앱 내 개발자 도구
  • 실시간 코드 미리보기

주요 기능

  • 55개의 프로그래밍 언어 지원
  • 사용자 지정 가능한 색 테마
  • 큰 파일의 부드러운 렌더링
  • 표시용 CodeView, 편집용 CodeField
  • 크로스 플랫폼 호환성

적합한 대상

  • 교육 앱
  • 개발자 도구
  • 문서 플랫폼
  • 코드 공유 앱
  • 내부 개발자 유틸리티

고려 사항

  • 가독성을 위해 주의 깊게 테마 설정이 필요합니다
  • 매우 큰 파일에서는 성능이 달라질 수 있습니다
  • 제한된 내장 자동 완성
  • 내장된 언어 감지 없음
  • 사전에 형식이 지정된 코드 문자열과 함께 사용하는 것이 가장 좋습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

val_highlight

Syntax highlighting for Dart and Flutter.

A pure-Dart engine with 55 languages, incremental updates and themes,
plus Flutter widgets to show and edit code.

val_highlight on pub.dev val_highlight_flutter on pub.dev BSD-3-Clause license


📦 Packages

Package Use it for
val_highlight The engine, in pure Dart: 55 languages plus a generic fallback, flat tokens, incremental updates, language detection, 8 themes, VS Code theme import and HTML output. Runs on the VM, in Flutter and on the web.
val_highlight_flutter Flutter widgets: CodeView to show code, CodeField to edit it, HighlightTextController, and CodeTheme for app-wide defaults.

A val_highlight_jaspr package is planned, built on the same engine.

// Flutter
CodeView(source, language: dartLanguage)

// Pure Dart
final html = const Highlighter().toHtml(source, language: dartLanguage);
Dart in CodeView with line numbers and highlighted lines
CodeView
Line numbers, highlighted lines, selection.
TSX in the midnight theme
Themes
Eight built in, or import a VS Code theme.
Markdown with bash, Python and JSON code fences
Languages inside languages
Markdown fences, HTML with CSS and JavaScript.
Python being edited in CodeField
CodeField
An editor that highlights as you type.

⚡ Performance

just bench compiles to native code, highlights a Dart file and renders it to HTML (best of 5 runs, on a MacBook):

Lines Highlight + HTML
600 1.5 ms
2,400 4.3 ms
9,600 13.9 ms

just bench-languages measures about 256 KB of realistic source per language on native code. It averages about 43 MB/s, from 30 MB/s (HTML) to 64 MB/s (Markdown). just bench-js runs the same test compiled to JavaScript, where it averages about 62 MB/s.

With incremental highlighting, one keystroke in the 9,600-line file takes about 0.4 ms. Frame timings for scrolling and typing in Flutter are in the val_highlight_flutter README (just bench-frames).

How it works
  • One pass, no copying. The scanner walks the source by offset, never copies it, and time grows in step with input size.
  • First-character dispatch. Each rule's pattern is analysed once to find the characters it can start with. The scanner skips positions where no rule can start, and tries only the rules that can. Rules anchored with ^ are tried only at line starts. States with a rule that can start almost anywhere fall back to one combined regular expression. Both paths give identical results, and fuzz tests check this.
  • Plain-Dart matchers. On native platforms, most patterns run as small Dart matchers instead of the regular expression engine, with identical results (checked by fuzz tests). Browsers compile regular expressions to machine code, so the web keeps using them.
  • Flat output. Tokens are two integer lists, not a tree of objects.

🛠️ Development

This repository is a pub workspace. The Flutter version is pinned in .fvmrc (3.44.2), and the justfile runs everything through FVM:

just setup            # install the pinned SDK and fetch dependencies
just check            # format check, analyze, all tests (VM and JS)
just devices          # list available devices
just example-flutter  # run the Flutter example; asks which device to use
just example-web      # run the Flutter example in Chrome
just example-dart     # run the pure-Dart example
just bench            # benchmark

Run just with no arguments to list every command.

Note: with Xcode 27, Flutter 3.44.2 (the pinned version) fails to build for iOS, and to build macOS apps in profile or release mode, such as the frame benchmark. Its architecture check rejects Xcode 27's lipo output. Flutter 3.47 builds both. Web, Android and macOS debug builds work with the pin.

Built by Val

val_highlight is part of Val, the live visual layer for AI agents.

💬 Community

Issues and pull requests are welcome. See CONTRIBUTING.md for setup, tests and what we look for in a pull request.

📄 License

BSD 3-Clause — see LICENSE.

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.

순위