A
A
ashyr962020-09-14 11:06:07
API
ashyr96, 2020-09-14 11:06:07

How to organize like/unlike work in Flutter?

While working on the project, an interesting problem arose.
Namely, the post like system in Flutter.

There is input with request API = (isLiked = true/false ).

How to change like states on click. The obvious solution is:

if ( isLiked ) {
   setState((){
      _isliked = !isLiked
 })

does not fit, because the logic does not work already on the second click. (The original isLiked data does not change when clicked).
How to write this logic?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Neonoviiwolf, 2020-09-14
@Neonoviiwolf

else? enum? what is the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question