shiki_flutter 1.0.0 copy "shiki_flutter: ^1.0.0" to clipboard
shiki_flutter: ^1.0.0 copied to clipboard

A TextMate-grammar based syntax highlighter for Flutter, ported from Shiki. Tokenizes source code with VS Code themes and renders it as styled TextSpans.

example/example.dart

import 'package:flutter/material.dart';
import 'package:shiki_flutter/shiki_flutter.dart';

const _code = '''
void main() {
  final greeting = 'Hello, Shiki!';
  for (var i = 0; i < 3; i++) {
    print('\$greeting (\$i)'); // batteries included
  }
}
''';

void main() {
  // Batteries-included: pass bundled languages/themes by symbol.
  final highlighter = ShikiHighlighter()
    ..preload(
      langs: [CodeLanguages.dart],
      themes: [ShikiThemes.githubDark],
    );

  runApp(
    MaterialApp(
      home: Scaffold(
        body: Center(
          child: ShikiCodeView(
            highlighter: highlighter,
            code: _code.trim(),
            lang: CodeLanguages.dart,
            theme: ShikiThemes.githubDark,
            textStyle: const TextStyle(fontFamily: 'monospace', fontSize: 16),
          ),
        ),
      ),
    ),
  );
}
11
likes
0
points
240
downloads

Publisher

verified publisherbirju.dev

Weekly Downloads

A TextMate-grammar based syntax highlighter for Flutter, ported from Shiki. Tokenizes source code with VS Code themes and renders it as styled TextSpans.

Homepage
Repository (GitHub)
View/report issues

Topics

#syntax-highlighting #textmate #themes #highlighting #code

License

unknown (license)

Dependencies

flutter, meta, shiki_flutter_dart_engine, shiki_flutter_engine_interface, web

More

Packages that depend on shiki_flutter