flutter_google_ad_manager icon indicating copy to clipboard operation
flutter_google_ad_manager copied to clipboard

Flutter, bottomSheet seems to be in loop

Open rochapablo opened this issue 5 years ago • 0 comments

I have a screen that at bottom should load a banner. But when I run, the log goes crazy printing Banner mount and the banner never shows up. But if I remove it (BannerComponent) from bottomSheet the banner works without the crazy print in loop.

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new StoreProvider<BookmarkState>(
      store: store,
      child: new MaterialApp(
        debugShowCheckedModeBanner: false,
        initialRoute: '/',
        routes: {
          '/': (context) => HomeScreen(),
        },
      ),
    );
  }
}

class HomeScreen extends StatelessWidget {
  static const int PAGE_SIZE = 5;

  @override
  Widget build(BuildContext context) {
    // return BannerComponent() // this whill work
    
    return Scaffold(
      appBar: AppBarComponent(),
      drawer: DrawerComponent(),
      // body: this.mountBody(context),
      bottomSheet: BannerComponent(),
    );
  }
}

class BannerComponent extends StatelessWidget {
  BannerComponent();

  @override
  Widget build(BuildContext context) {
    
    return Container(
        color: Colors.red,
        child: Row(
          children: [
            this.mountDFPBanner(context),
          ],
        ));
  }

  mountDFPBanner(context) {
    print('Banner mount');
    return DFPBanner(...);
  }
}

If at the mountDFPBanner, I just return the follow block, 'Banner Test' it will be shown without loop.

return Container(
        padding: EdgeInsets.only(left: 5.0),
        height: 40.0,
        alignment: Alignment.center,
        child: Text(
          'Banner Test',
          style: TextStyle(color: Colors.white, fontSize: 18.0),
        ));

So, what could I be doing wrong here?

https://stackoverflow.com/questions/59217651/flutter-bottomsheet-seems-to-be-in-loop

rochapablo avatar Dec 06 '19 18:12 rochapablo