I know this is a basic question but I wanna know how you guy's implement logic for your widgets. I normally write logic in build() function just above the return type.
CodePudding user response:
What do you mean by logic..?? If you are talking about like adding some values.. then we use a different method for that outside the build Method because build method will rebuild when the set state method called so some times logic can be used inside the build but some time we need to write the logic in different method and called them..
CodePudding user response:
Build method will rebuild every time the app state got change or refresh if you talking about widget state You can write it in separate file using state management approaches like (Getx,Provider) You can write it in separate function if you need to perform setState that method will update the state ...Try to use separate functions and controllers for logic it will help you in scalability for your code