Home > Software design >  Flutter progress loader not showing in the center
Flutter progress loader not showing in the center

Time:11-10

I'm trying to show CircularProgress center of my webview inside stack but its showing bottom. I used expanded widget to use available space for webview.

My code :

Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: WillPopScope(
          onWillPop: () async {
            print("back pressed");
            return false;
          },
          child: Column(
            children: [
              webProgress < 1
                  ? SizedBox(
                      height: 5,
                      child: LinearProgressIndicator(
                        value: webProgress,
                        color: Colors.blue,
                        backgroundColor: Colors.white,
                      ),
                    )
                  : SizedBox(),
              Expanded(
                child: WebviewScaffold(
                  url: "https://google.com",
                  mediaPlaybackRequiresUserGesture: false,
                  withLocalStorage: true,
                ),
              ),
              isLoading
                  ? Center(
                      child: CircularProgressIndicator(),
                    )
                  : Stack(),
            ],
          ),
        ),
      ),
    );
  }
}

CodePudding user response:

this worked for me the initial progress must be 0.0

CodePudding user response:

Maybe try wrapping what you want to show circular progress above with a stack,

like this:

  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: WillPopScope(
          onWillPop: () async {
            print("back pressed");
            return false;
          },
          child: Column(
            children: [
              webProgress < 1
                  ? SizedBox(
                height: 5,
                child: LinearProgressIndicator(
                  value: webProgress,
                  color: Colors.blue,
                  backgroundColor: Colors.white,
                ),
              )
                  : SizedBox(),
              Stack(
                children: [
                  Expanded(
                    child: WebviewScaffold(
                      url: "https://google.com",
                      mediaPlaybackRequiresUserGesture: false,
                      withLocalStorage: true,
                    ),
                  ),
                  isLoading
                      ? Center(
                    child: CircularProgressIndicator(),
                  )
                      : Container(),
                ],
              ),
              
            ],
          ),
        ),
      ),
    );
  }
  • Related