Skip to content
Discussion options

You must be logged in to vote

How about this (I've added a small delay to simulate network delay):

import asyncio
from typing import Optional, cast

import httpx

import flet as ft


# ---------- DIALOG COMPONENT ----------
@ft.component
def UserDialogContent():
    """Component that loads and displays user data"""
    loading, set_loading = ft.use_state(True)
    name, set_name = ft.use_state("")
    email, set_email = ft.use_state("")
    error, set_error = ft.use_state("")

    async def load_user():
        set_loading(True)
        set_error("")
        try:
            await asyncio.sleep(2)  # Simulate network delay
            async with httpx.AsyncClient(timeout=5) as client:
                r = await client.get

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RezaErfani67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants