-
Notifications
You must be signed in to change notification settings - Fork 107
Code File (Custom Classes) Docs #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requested some fixes, but overall LGTM!
|
||
## Create Class Instance | ||
|
||
You need to create an instance of a class so you can work with actual data and use the class’s properties and methods in your app. Here’s a simple explanation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention how it is similar to datatype instance and point to that doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't have any docs in custom data type about creating a datatype instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we don't have it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you create a linear ticket for the same and reference this PR comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- An **instance** (or “object”) is a real, usable item made from that blueprint. See the code snippet below: | ||
|
||
```jsx | ||
Review review1 = Review( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THis may be incomplete if we don't show the code for the Review class first. I know its added to the Arcade but its not enough since the rest of the explanations is so tied to the Review class, but we dont show the class definition in code here. I'd suggest add the Review class snippet after the Create Custom Class Arcade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree! added.
|
||
- Store actual review details. | ||
- Access and update the fields (e.g., `review1.rating` or `review1.comment`). | ||
- Call methods that do something with that data (e.g., `review1.markHelpful()` or `review1.shortComment()`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another point where these methods are confusing because we dont have the code for Review class somewhere here where we can reference it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, now worries. added the code snippet for the Review class.
</div> | ||
<p></p> | ||
|
||
:::tip[When You Don't Need an Instance] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldnt call it a tip rather its a feature. Im afraid this entire section with the description (for e.g "skip instance creation" language) can make non coders feel like this is the easiest approach so lets go with it, and they will have static methods everywhere and more bugs because the logic will not work the way a non static class is expected to work.
We should treat it as its own section and talk about when its useful with more examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, in that case, let's remove (comment out) this part and revisit with more detail!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it will take more time to rewrite this part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see a bunch of new actions under custom class, see here: https://linear.app/flutterflow/issue/SUP-2529/custom-class-method-is-not-appearing-in-actions-list#comment-34cd1a72
also some related to static fields. I think it should be covered in the v1 version of the docs (as a separate section)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say this 'should be covered in the v1 version of the docs' you mean in this PR only right? yes, we can do it. Could you please help with that ticket? it is is not opening for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes in this PR, can you check the linear ticket again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Added a new 'Using Static Classes' section.
|
||
 | ||
|
||
### Call In Action Flows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is more important to show with an Arcade. and if I remember correctly this is not the name of the action. we must have the action name the way we do it for other features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. However, there's currently an issue where custom class methods aren't showing up in the actions list, so I’m unable to see any details or record the arcade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added now!
|
||
You can also add your custom class’s methods directly within an Action Flow. For example, you can trigger the `markHelpful()` method when a user taps a “Mark as Helpful” button to update a field or increment the helpful count of a review. | ||
|
||
## Enums |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its ###?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely the name shouldnt be just Enums, same reason as Data Types comment. Custom Enums?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the name to "Custom Enums" but kept the heading as ## only to avoid nesting it under "Using Custom Classes." Since enums are different from classes, I think they deserve their section.
Co-authored-by: Pooja Bhaumik <[email protected]>
…ow/flutterflow-documentation into feature/custom-classes
Hi @PoojaB26, Most of the review comments are addressed. For some, I left the reply. You can take a look. |
Hi @PoojaB26 all review comments are addressed now! |
@@ -194,7 +194,67 @@ You can use custom class fields to display values directly in the UI, and call i | |||
|
|||
### Call In Action Flows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we need this, lets just have all actions in h3 and remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
…ow/flutterflow-documentation into feature/custom-classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some examples & explanations need fixing
|
||
### Set Field [Action] | ||
|
||
Use the **Set Field** action to update a specific property of a custom class instance. For example, you can set `order.status = 'shipped'` when a user confirms an order, allowing the UI to reflect the change immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is different from the text here. May be confusing to users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- not matching the Review class above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
## Using Static Classes | ||
|
||
Sometimes, you just want to run a small piece of logic like formatting text or doing a calculation, without needing to set up anything extra. That’s when `static` data members are helpful. You can access static fields and methods without creating an instance of a class. You can think of them like tools that are always ready to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect actually. We don't use static classes because its minor logic, but rather when there is "shared logic across app" where calculator / utility functions fit that definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes, you just want to run a small piece of logic like formatting text or doing a calculation, without needing to set up anything extra. That’s when `static` data members are helpful. You can access static fields and methods without creating an instance of a class. You can think of them like tools that are always ready to use. | |
Sometimes, you just want to run a small piece of logic like formatting text or doing a calculation, without needing to set up anything extra. That’s when `static` data members are helpful. You can access static fields and methods without creating an instance of a class. Because they're tied to the class rather than an instance, static members are accessible globally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, updated it.
- This `StringFormatter` class below provides reusable static methods to capitalize text, convert it to lowercase, or format it in snake_case. | ||
|
||
```jsx | ||
class StringFormatter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is off on this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
</div> | ||
<p></p> | ||
|
||
## Using Static Classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused on this one. technically Dart doesnt allow a "static class" per se. What people often do instead is create a class that contains only static members or mix static and instance members in the same class. So the title might be a bit misleading in this context? Maybe just call it Using Static Members or just Static Members if you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok updated to 'Using Static Members'
|
||
:::warning | ||
|
||
Static classes are powerful, but they should be used carefully. Overusing static methods can lead to less flexible code and potential issues, especially when the logic requires access to state or needs to evolve over time. Stick to static methods only when the logic is truly independent and doesn’t rely on instance-specific data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can fix the first line based on the feedback about "static classes"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also mention somewhere that static and instance fields can be mixed in a class as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed both of comments!
</div> | ||
<p></p> | ||
|
||
### Call Static Method [Action] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example in the text not matching the example in the Arcade. You can add multiple examples, but the main one should reflect the Arcade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@PoojaB26 you can take a look again. |
Description
Code File (Custom Classes) Docs
Linear ticket and magic word Fixes DEVR-914
Type of change