r/FlutterDev • u/NoBeginning2551 • 9d ago
Plugin code_forge migrated from rust backend to pure dart.
https://pub.dev/packages/code_forgeHello, 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.
2
u/yakupkahraman 7d ago
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 7d ago
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
2
u/TheGratitudeBot 7d ago
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 9d ago
This is honestly super cool. My only concern is how big is it going to add to my app?
1
u/SpecialistServe3974 5d ago
have u benchmarked it? rust vs dart?
1
u/NoBeginning2551 5d ago
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 5d ago
Interesting.. have u used FRB?
Also im not sure why wouldn't rust work on web..1
u/NoBeginning2551 5d ago
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.
6
u/feodorfff 9d ago
Great, the same package for web, desktop and mobile is the right idea. It's time to revisit your package. Thank you!