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

outdated

A SyntaxView Widget which highlights code text according to the programming language syntax using Native Dart code.

example/lib/main.dart

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

void main() => runApp(App());

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyApp(),
      debugShowCheckedModeBanner: false,
      title: "Flutter Syntax View Example",
    );
  }
}

class MyApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  String code = """
                // Importing core libraries
                import 'dart:math';
                int fibonacci(int n) {
                  if (n == 0 || n == 1) return n;
                  return fibonacci(n - 1) + fibonacci(n - 2);
                }          
                var result = fibonacci(20);
                /* and there 
                   you have it! */
                """;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Flutter Syntax View Example"),
        backgroundColor: Colors.blueGrey[800],
        elevation: 7,
      ),
      body: SyntaxView(
        code: code,
        syntax: Syntax.DART,
        syntaxTheme: SyntaxTheme.dracula(),
        withZoom: true,
        withLinesCount: true,
      ),
    );
  }
}
94
likes
30
points
11.9k
downloads

Publisher

unverified uploader

Weekly Downloads

A SyntaxView Widget which highlights code text according to the programming language syntax using Native Dart code.

License

MIT (license)

Dependencies

flutter, string_scanner

More

Packages that depend on flutter_syntax_view