Question: Cheers,

I have the bellow React code, where i need to send an HTTP Request to check if my actual user have permission or not to access my page.
For that, im using useEffect hook to check his permission every page entry.

But my actual code does not wait for `authorize()` conclusion. Leading for `/Unauthorized` page every request.
What i am doing wrong?

```
import React, { useState, useCallback } from "react";
import { useNavigate } from "react-router-dom";
import { security } from "../../services/security";

export default function MypPage() {
  const navigate = useNavigate();
  const [authorized, setAuthorized] = useState(false);

  const authorize = useCallback(async () => {
    // it will return true/false depending user authorization
    const response = await security.authorize("AAA", "BBB");

    setAuthorized(response);
  });

  useEffect(() => {
    authorize();

    if (authorized) return;
    else return navigate("/Unauthorized");
  }, [authorize]);

  return <div>MypPage</div>;
}

```

Thanks.

Answer: 
replace your container with this code:

```
Container(
        alignment: Alignment.center,
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(5),
            color: (hisseResult?.result[index].rate ?? 0) > 0
                ? Colors.green
                : Colors.red),
        width: 75,
        height: 25,
        child: Text(hisseResult?.result[index].rate.toString() ?? "",
            style: TextStyle(color: Colors.white)))

```

if rate > 0, the container is set to green, else container is set to red

Greetings!
Flutter allows **conditions when giving values to widgets atributes.**

Just use a ternary operator which is very clean visual and suits this perfectly:

```
color:  hisseResult?.result[index].rate > 0 ? Colors.green : Colors.red,

```

Selamlar :)