Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tab3 extends StatefulWidget {
- const Tab3({Key? key}) : super(key: key);
- @override
- _Tab3State createState() => _Tab3State();
- }
- class _Tab3State extends State<Tab3> {
- late BannerAd banner;
- @override
- void didChangeDependecies() {
- super.didChangeDependencies();
- final adState = Provider.of<AdState>(context);
- adState.initialization.then((status) {
- setState(() {
- banner = BannerAd(
- size: AdSize.banner,
- adUnitId: adState.bannerAdUnitId,
- listener: adState.adListener,
- request: AdRequest(),
- )..load();
- });
- });
- }
- @override
- Widget build(BuildContext context) {
- return ListView(
- children: [
- if (banner == null)
- SizedBox(
- child: Container(),
- height: 50,
- )
- else
- Container(
- height: 50,
- child: AdWidget(ad: banner),
- )
- ],
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement