r/dartlang • u/randomguy4q5b3ty • 27d ago
Am I the only one absolutely frustrated by Build Hooks?
I'm sorry, but how is any non-expert supposed to understand how to use hooks? Have any of you, after studying the rather sparse documentation and complex Hooks API, actually felt like you understood any of this? I have been sitting here for hours, just trying to call a simple function from a pre-compiled dll, but the non-helpful documentation and error messages make even the simplest things a daunting task.
But what I find most unpleasent is that even the basic example code (which hasn't helped me at all) looks quite complex and build hooks can just execute any arbitrary code, be that downloading files, executing some other script, or whatever. Not only does that stink of a huge security risk, but there will be so many packages with completely broken hooks on pub, which will then also start to depend on each other. This will be really fun...
Edit: Heureka, it finally worked! But what a frustrating ride it was...
•
•
u/loic-sharma-google 26d ago
Hello, I'm from the Flutter team at Google. Thanks for the feedback!
Could you provide specific details on your experience? For example, for each task:
- What actions did you try?
- What error messages did you see that were unclear?
- What docs did you find confusing?
The more specific the feedback, the better! That'll help us iron out those kinks :)
•
u/randomguy4q5b3ty 26d ago
Well, even after reading everything for the fifth time, I barely understood what any of these parts do exactly or what this ominous assetId is and how it gets connected to a dynamic library that was already sitting in the project directory.
And for somebody who has no clue what exactly these hooks are supposed to build when the dll is already there, the error messages about some assetId that wasn't found (still had no clue what that was supposed to be) weren't particularly helpful.
Just through trial and error I got it working and a superficial understanding of what I was doing.
And let's just say the API is not nice and even the example code looks hideous. It's there any reason we can't have a nice, clean task runner like Jake.js?
•
u/DigiProductive 27d ago edited 27d ago
I assume you are talking about Dart Hooks. To be honest, hooks are for seasoned developers. If you are a newbie, you probably want to leave it alone because you probably don’t even need them.
•
u/randomguy4q5b3ty 27d ago edited 27d ago
I am seasoned and have been using Dart right from the beginning. Even before they stabalized the FFI, I had been working with VM Native Extensions, and even those were hard to use. But this? It's 100% a documentation issue and I don't have to feel dumb for not understanding any of this.
•
u/autognome 26d ago
Maybe write up your "falling down" and suggest where documentation could be clearer?
•
•
u/Luc-redd 26d ago
Hooks is for the middle of the bell curve, beginners should stay away, and experts prefer not to use them.
•
u/Bachihani 26d ago
I m not particularly advanced but i didn't find hooks that hard to understand or write, especially with some explanation from an llm
•
u/GMP10152015 24d ago
I suggest you take a look at real projects:
•
•
u/ralphbergmann 27d ago
Claude did it for me and it works :)
•
u/randomguy4q5b3ty 27d ago
And here come the broken hooks and security flaws 😆 Seriously, when we don't even understand how our software is build anymore... Then some AI/bad faith actor will just smuggle in some rogue code or telemetrics.
•
u/ralphbergmann 26d ago
Whether or not you understand how the AI built something is irrelevant. The important thing is testing. If you already know how something works, why use AI at all? I might as well just do it myself.
Dart Hooks was set up by the AI once. Since then, it has run automatically with every build. It doesn't matter if I've changed anything in the Dart or Rust code — it just works.
It was a one-off setup task for Claude. So it’s perfect for AI. Why should I spend days getting to grips with something that I’ll only do once and then forget about?
•
u/randomguy4q5b3ty 26d ago
I can see why it has become so easy to smuggle malware into software projects...
•
u/raman4183 27d ago
What is so complicated and which part is giving you a hard time?
You have to digest it in separate parts. As you have mentioned that you already have a compiled dll then you don’t need an intermediary package for compilation such as ‘c_builder’ and etc. You can directly use ‘code_asset’ package to include the compiled dll into the final bundle which will automatically be loaded when you call your function.
Just make sure to create proper bindings.