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

[Flutter] _CastError (Null check operator used on a null value) even with a data validator -...

Discussão em 'Mobile' iniciado por Stack, Outubro 4, 2024 às 05:12.

  1. Stack

    Stack Membro Participativo

    I'm working with Jikan API. Here I have a FutureBuilder that display some data :

    FutureBuilder<am.AnimeModel>(
    future: getAnimeById(widget.malId),
    builder: (context, snapshot) {
    if (snapshot.hasData) {
    var data = snapshot.data!.data!; // <--- HERE ERROR
    print(data.malId);

    return AnimeDataCardWidget(
    malId: data.malId,
    pic: data.images!.jpg!.largeImageUrl,
    title: data.title,
    totalEpisode: data.episodes,
    studios: data.studios![0].name != null
    ? data.studios![0].name
    : '--',
    originalManga: data.source,
    frenchVersion: data.titles,
    creationDate: data.airing,
    futureData: getFavAnimesId(),
    score: data.score,
    );
    } else {
    return const Center(
    child: CustomLoadingAnimation(),
    );
    }
    }),


    When the user tap on listTile, the app opens a detailed page, and this page displays a card (see code above). It works really fine but not with animes that don't have the 'studio' data.

    As you can see, I check if (snapshot.hasData) but after that, it keep tells me that data is null.

    Any idea how to resolve this ?

    Continue reading...

Compartilhe esta Página