r/FlutterDev • • Oct 14 '26

Plugin code_forge migrated from rust backend to pure dart.

https://pub.dev/packages/code_forge

Hello, I'm the author of the code_forge package, a very powerful text field widget capable of handling even 1M+ lines of text smoothly, where the default TextField widget crashes the app for a few thousand lines.

The package backend was written in rust using the ropey and zed_sum_tree crates, resulting in no web support and requiring the user to install rust in their system to build the package. Because of that most of the people migrated to an alternative package called re_editor.

I removed the rust backend and implemented rope data structure and zed_sum_tree like Layout mapping in pure dart.

45 Upvotes

13 comments sorted by

6

u/feodorfff Oct 14 '26

Great, the same package for web, desktop and mobile is the right idea. It's time to revisit your package. Thank you!

2

u/NoBeginning2551 Oct 15 '26

Yes, now flet can easily use it without any additional tweaks. Am I right?

2

u/feodorfff Oct 15 '26

Will take a look. We might need to implement our own LSP transport as LSP will be running in a separate browser web worker with Pyodide 🤓

1

u/NoBeginning2551 Oct 15 '26

No need for that. CodeForge supports LSP via websocket. Run the LSP server elsewhere and pass the url to the controller class. More info is there in the README.

2

u/yakupkahraman Oct 17 '26

Supaaa, i like the pure dart things. I'm currently using this package in the Bird IDE (an IDE for Flutter Community written in Flutter) and maybe i can make the web side. Thank you!

2

u/NoBeginning2551 Oct 17 '26

Thank you for using code_forge ❤️. I've inspected your pubspec.yaml and found that you're using version 11.1.1. Please update to 11.2.0, as it fixes a major `RangeError` bug.

2

u/yakupkahraman Oct 17 '26

👀 i upgraded, thanks o7

2

u/TheGratitudeBot Oct 17 '26

Hey there yakupkahraman - thanks for saying thanks! TheGratitudeBot has been reading millions of comments in the past few weeks, and you’ve just made the list!

6

u/rabinapps Oct 14 '26

This is honestly super cool. My only concern is how big is it going to add to my app?

1

u/SpecialistServe3974 Oct 19 '26

have u benchmarked it? rust vs dart?

1

u/NoBeginning2551 Oct 19 '26

yes, both can handle 1M+ lines. But the rust version had some cursor mismatch issue on large files. Also, the FFI calls were quite expensive. I inspected the performance of both versions via flutter devtools CPU profiler and performance monitor, and found out that the pure dart version is better compared to the rust one. Not because of the language speed, but because of the FFI.

1

u/SpecialistServe3974 Oct 19 '26

Interesting.. have u used FRB?
Also im not sure why wouldn't rust work on web..

1

u/NoBeginning2551 Oct 19 '26

Yes, I've been using FRB to connect with backend rust code. That was the another major problem. The FRB is a plugin, not a pure package. Which means, the FRB generates and ships platform specific code with the main package. This caused many issues with Android, IOs and MacOS. Because the FRB is not that active and we'll maintained, the dependencies are outdated, getting warnings like outdated gradle version on android, SPM migration warning in iOS/macOS, and no web. Yeah we can compile it into wasm, but the wasm build was super slow and requires additional CORS handling.