code_editor 0.1.0 copy "code_editor: ^0.1.0" to clipboard
code_editor: ^0.1.0 copied to clipboard

outdated

A CSS, HTML and Javascript code editor for Flutter with syntax highlighting and custom theme.

example/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'code_editor tests',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(title: Text("code_editor tests"), elevation: 0),
        body: MyEditor(),
      ),
    );
  }
}

class MyEditor extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<String> contentOfPage1 = [
      "<!DOCTYPE html>",
      "<html lang='fr'>",
      "\t<body>",
      "\t\t<a href='page2.html'>go to page 2</a>",
      "\t</body>",
      "</html>",
    ];

    List<FileEditor> files = [
      new FileEditor(
        name: "page1.html",
        language: "html",
        code: contentOfPage1.join("\n"),
      ),
      new FileEditor(
        name: "page2.html",
        language: "html",
        code: "<a href='page1.html'>go back</a>",
      ),
      new FileEditor(
        name: "style.css",
        language: "css",
        code: "a { color: red; }",
      ),
    ];

    EditorModel model = new EditorModel(
      files,
      styleOptions: new EditorModelStyleOptions(
        fontSize: 13,
      ),
    );

    return SingleChildScrollView(
      child: CodeEditor(
        model: model,
        onSubmit: (String language, String value) {
          print("language = $language");
          print("value = '$value'");
        },
      ),
    );
  }
}
101
likes
0
pub points
88%
popularity

Publisher

verified publishersciencesky.fr

A CSS, HTML and Javascript code editor for Flutter with syntax highlighting and custom theme.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_highlight, font_awesome_flutter, provider

More

Packages that depend on code_editor