aipok06/23/2020, 10:50 AM
jim06/23/2020, 12:11 PM
could all have very sophisticated validation logic. If you were implementing GoogleDocs, you might have a
widget that took in a mutable
data structure describing the document. But the logic of these widgets should be self-contained to the widget's specific concerns, and not explicitly depend on the app as a whole. If your widget has a reference to your
, you're almost certainly doing it wrong. Compose widgets are certainly expected to replace Fragments in general usage, but I'd suggest using a mental model that is closer to custom views. Fragments were a very leaky abstraction that wasn't conducive to good encapsulation. Instead, you want to build reusable chunks that feel like something you could embed into another app. At some point you will intentionally break this rule, but if you feel the need to ask the question, then you're probably not yet ready to break the rule.