I have a wallpaper app that shows pictures from Firestore in homescreen and I am using the flutter_native_admob package to show native and the ads are working fine.
I already tried using the package staggered_grid_view but it didn't work, the package breaks everytime I change the value in StaggeredGridTile from 1 to 2 to show the native ad instead of grids and even if I set a number to show the ad after x pictures, it show in wrong places scrolling.
What I needed:
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final nativeAdmob = NativeAdmob();
int counter = 0;
double result;
int num = 4;
@override
Widget build(BuildContext context) {
Widget _buildGrid(int index){
return Container(
color: Colors.green,
child: Center(
child: Text("$index"),
),
);
/*
// I need to show this widget between the content
NativeAdmobBannerView(
adUnitID: "ca-app-pub-3940256099942544/2247696110", // Test
style: BannerStyle.light,
showMedia: true,
)
*/
}
return Scaffold(
appBar: AppBar(
title: Text('Grid with Native Ad'),
centerTitle: true,
),
body: Container(
child: StaggeredGridView.countBuilder(
crossAxisSpacing: 3.0,
mainAxisSpacing: 3.0,
itemCount: 20,
itemBuilder: (context, index){
return _buildGrid(index);
},
crossAxisCount: 2,
staggeredTileBuilder: (int index){
return StaggeredTile.count(
1,
1
);
},
),
)
);
}
}