1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter Image.network() Exception : Invalid Image Data

Discussão em 'Mobile' iniciado por Stack, Outubro 31, 2024 às 20:52.

  1. Stack

    Stack Membro Participativo

    The following is my code, which is just a simple Image.network() constructor. The issue I am facing is some URLs works, some does not. I am trying to understand why this happens. While I see solutions such as CachedNetworkImage or other ways of handling unavailable images, I can't seem to find why this is happening. When trying to see the images on a web browser, I see the image there. Even when using APIs to get an image, I see the image in Postman and browser.

    @override
    Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(
    title: const Text('API Test App'),
    ),
    body: SingleChildScrollView(
    child: Column(
    children: [
    const Text('Hello world!'),
    Image.network(
    'https://secretrecipebd.com/wp-content/uploads/2021/07/pizza_tuna-.jpg',
    fit: BoxFit.cover,
    ),
    Image.network('https://picsum.photos/250?image=9'),
    ],
    ),
    ),
    );
    }


    The first one, Image.network('https://secretrecipebd.com/wp-content/uploads/2021/07/pizza_tuna-.jpg',fit: BoxFit.cover,) does not work and simply shows Exception : Invalid Image Data, while the second one loads up and is displayed on the app.

    Basically, I was trying to display the image using an API, but it was not working so I tried hardcoding the url inside the Image.network constructor and that is when I found this issue.

    Continue reading...

Compartilhe esta Página