f2prateek/dart

Add Flags via Henson

Closed this issue · 3 comments

It seems to add flags to your intent you have to generate the intent with Henson, then set flags, then call startActivity. Can Henson be extended with an optional withFlags(...) method? It feels much more fragile when I have to manually adjust the generated intent before using it

It would be exactly the same as adding them manually, same number of lines of code, and there is no verification mechanism that we could use to enforce the flags.

I don't think this is a good candidate for a future feature. But submit a PR if you think otherwise.

It's only more lines in terms of requiring a local variable

Intent intent = Henson.with(...)...build(); intent.setFlags(...); startActivity(intent);

vs

startActivity(Henson.with(...).withFlags(...)...build())

I hadn't thought of the need to enforce the flags. My thinking was that I should be able to generate a complete intent and not manually modify it. It might be possible to automatically add flags if the activity had dart annotations for the various flags, but I don't know if that's a reasonable solution, what do you think?

Intent intent = Henson.with(...)
  .build()
  .setFlags(...); 
startActivity(intent);