0

So far, I have made a loading animation that includes Container, Column, Text, and Image(gif). And this code is working fine in a new project but when I try to implement this code into my ongoing project, it is not working! It does not throw any error but the loading screen is blank. Like data from API loads without loading animation. So, what I am doing wrong in this, or how to implement loader correctly?

Loader's code:

return Scaffold(
  body: Container(
    height: 130,
    width: 135,
    decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(17),
        border: Border.all(color: Colors.blue)),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.end,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        const Text(
          "Loading...",
          style: TextStyle(
            fontSize: 13,
            letterSpacing: 2.1,
            color: Colors.blue,
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(3.0),
          child: Image.network(
            "https://cdn.dribbble.com/users/42716/screenshots/3913441/media/4ef7d67070fee7ab75948280f51d369f.gif",
            height: 100,
          ),
        ),
      ],
    ),
  ),
);

Here I am implementing code:

Future<List<VeReportModel>>? _vReport() async {
debugPrint("Do not exploit this code  $fDate &&&&&&&& Thank you");
try {
  if (await NetworkUtils.isNetworkAvailable()) {
    //UIUtils.showProcessIndicator(); //TODO This is old Indicator I want a new one here
    Loader();
    ApiResponse? apiResponse = await RestApiClient(session: session)
        .vReport(fDate, tDate, spedLimit, stLimit, vId!);
    UIUtils.hideProcessIndicator(); //TODO Old Indicator disposed
    Common.printWrapped('Map: _vEvent(): apiResponse=$apiResponse');
    if (apiResponse!.successful && apiResponse.code == apiSuccessCode) {
      if (apiResponse.data != null) {
        List mapMessages = apiResponse.result;
        debugPrint("mapMessage $mapMessages");
        return mapMessages
            .map((v) => VeReportModel.fromJson(v))
            .toList();
      }
    }
  } else {
    UIUtils.hideProcessIndicator();
    UIUtils.displayInternetError(context);
  }
} catch (e,stack) {
  UIUtils.hideProcessIndicator();
  UIUtils.catchErrorMsg(context);
  debugPrint('Error While acknowledging v report : $e');
  GeneralException.handleError(e, stack: stack, module: moduleVeReport);
  debugPrint('VeReport: Error while getting v list: $e');
}
return [];

}

3
  • use visible and manage boolean value when you start fetching data from api Commented Dec 30, 2021 at 10:39
  • But I have many pages which will use this loader and I don't want to define the Visible block for each class. @DipakRamoliya Commented Dec 30, 2021 at 10:44
  • so u can use global variable Commented Dec 30, 2021 at 10:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.