How to make my own Loading Screen Indicator in flutter?

51 Views Asked by At

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 [];

}

0

There are 0 best solutions below