flutter_syntax_view 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

flutter_syntax_view #

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

Usage #

  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! */
                """;
  SyntaxView(
        code: code,
        syntax: Syntax.DART,
        syntaxTheme: SyntaxTheme.dracula(),
        withZoom: true,
        withLinesCount: true,
      );

Supported Syntax #

  • [x] Dart
  • [x] Java
  • [x] Kotlin
  • [x] Swift
  • [x] JavaScript
  • More will be added.

Themes #

TODO #

  • [ ] Add More Syntax Support.
  • [ ] Add More Themes.

Contributing #

  • if you are familiar with Regular Expressions in Dart and would like contribute in adding further syntax support. it will be very appreciated!

Contributors #

Installing #

Package

Features and bugs #

If you face any problems feel free to open an issue at the issue tracker. If you feel the library is missing a feature, please raise a ticket on Github. Pull request are also welcome.

[0.0.1] - 04/26/2019 #

  • First test release.

[0.1.0] - 04/27/2019 #

  • First stable release.

[0.1.1] - 04/27/2019 #

  • Fixed a Warning.

[0.1.2] - 04/28/2019 #

  • New Syntax Added (Java, Kotlin, Swift).
  • New Theme Added (Ocean Sunset).

[0.1.3] - 04/28/2019 #

  • Fixed README.md

[0.2.0] - 05/25/2019 #

  • JavaScript Syntax Added & Fixed Duplicated Syntax KeyWord in Swift.

[0.2.1] - 05/25/2019 #

  • Syntax Theme is not required (Default: dracula).
  • SDK minimun support upgraded from 2.1.0 to 2.2.2.
  • Syntax Lines counter is now available.

[0.2.2] - 02/23/2020 #

  • implemented abstraction.
  • Added Editable Rich Text

[1.0.0] - 05/25/2019 #

  • Removed (Editable Rich Text due some platform errors)

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,
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_syntax_view: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_syntax_view/flutter_syntax_view.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
81
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
string_scanner ^1.0.5 1.0.5
Transitive dependencies
charcode 1.1.3
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
source_span 1.7.0
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test