flutter_syntax_view 0.2.1

flutter_syntax_view #

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

Usage #

// Load code text from your assets path.
// Use DefaultAssetBundle. Recommended ( it allows switching asset bundles at runtime ).

String code = "";
DefaultAssetBundle.of(context)
    .loadString('assets/dart_code.txt')
    .then((codeText) => setState(() => code = codeText));
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 #

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

Contributors #

  • null

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.

example/flutter_syntax_view_example.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 = "";
  @override
  void initState() {
    super.initState();

    // Loading code text from assets/dart_code.txt
    // Use DefaultAssetBundle. Recommended ( it allows switching asset bundles at runtime ).
    DefaultAssetBundle.of(context)
        .loadString('assets/dart_code.txt')
        .then((codeText) => setState(() => code = codeText));
  }

  @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: ^0.2.1

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]
45
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]
72
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

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