Skip to main content

code_forge_web 2.10.1 copy "code_forge_web: ^2.10.1" to clipboard
code_forge_web: ^2.10.1 copied to clipboard

discontinuedreplaced by: code_forge

The web version of the powerful code_forge package

Discontinued #

The new version of code_forge has the web support and it has high performance compared to this package.
Hence, discontinuing this package. You can migrate to code_forge by simply changing the package name in pubspec.yaml. The APIs are same.


This package can load files from raw URLs and the LspSocketConfig() class can be used to enable LSP features, which makes the code_forge_web the ideal choice for browser based code editors.

Difference from code_forge #

Almost all features in the code_forge are same in this package except the file handling and the LSP initialization. The CodeForgeWeb has a fileUrl parameter instead of the filePath parameter of the CodeForge, where the user can pass raw file URLs.

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final CodeForgeWebController controller;

  @override
  void initState() {
    super.initState();
    controller = CodeForgeWebController(
      lspConfig: LspSocketConfig(
        workspacePath: "file:///workspace", // Virtual workspace name
        languageId: "dart", // Language id
        serverUrl: "ws://localhost:9000" // The LSP server url.
      )
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        body: SafeArea(
          child: CodeForgeWeb(
            // Working url of any file.
            fileUrl: "https://raw.githubusercontent.com/heckmon/code_forge/main/lib/code_forge/controller.dart",
            controller: controller,
            textStyle: GoogleFonts.jetBrainsMono(fontSize: 20),
            innerPadding: EdgeInsets.only(top: 10),
          )
        ),
      ),
    );
  }
}

To host a LSP server, you can use the lsp-ws-proxy package.
Here is an example of running dart language server via websocket:

./lsp-ws-proxy --listen 0.0.0.0:9000 -- dart language-server --protocol=lsp

This will start and run the LSP server on the localhost:9000. You can pass the link ws://localhost:9000 to the LspSocketConfig() to enable LSP features like in the above example.

CodeForgeWeb Demo

6
likes
160
points
1.07k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

The web version of the powerful code_forge package

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_colorpicker, http, markdown_widget, re_highlight, vector_math, web_socket_channel

More

Packages that depend on code_forge_web