mardi 18 mai 2021

Flutter - value is being updated but if state doesn't work again

 for (var i = 0; i < 10; i++)
        for (var j = 0; j < 3; j++)
          Positioned(
              top: size.height * 0.40 * j / 6,
              left: size.width * 0.09 * i,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Container(
                      padding: EdgeInsets.symmetric(
                          horizontal: size.width * 0.09,
                          vertical: size.height * 0.40),
                      child:
                          (datesinmonth.contains("19"))
                              ? CircleButton(color: Colors.green)
                              : CircleButton(color: Colors.red))
                ],
              )),

   CupertinoActionSheetAction(
                            onPressed: () {
                              Navigator.pop(context);
                              setState(() {
                                selectedMonth = searchinmonths;
                                datesinmonth =
                                    FirebaseAuthenticationService.dateCheck(
                                            selectedMonth)
                                        .toString();
                                log(datesinmonth);
                              });
                            },
                            child: Text("Done")),

On the code above if the string "datesinmonth" contains a date, the corresponding circle must be printed green. The data which is "17" is being fetch from the database and assigned to the variable "datesinmonth". I checked and the value is being updated as I wanted but the if statement doesn't work. How can I solve that? Thanks.

Aucun commentaire:

Enregistrer un commentaire