Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set background color for children of column

I am trying to implement Admob banner ad in my Flutter app. There is a black line above Admob banner, I could not understand how it happened. I did not set any background.

enter image description here

Current widget:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  @override
  Widget build(BuildContext context) {
    final tb = context.watch<ThemeBloc>();
    return Column(
      children: [
        Expanded(
...
...
...
),
        Container(height: 30, color: Colors.red),
        AdmobBanner(),
      ],
    );
}

I want to set background color for column. I added

backgroundColor:Colors.white

line

But it doesn’t work:

      @override
      Widget build(BuildContext context) {
        final tb = context.watch<ThemeBloc>();
        return Column(
        backgroundColor:Colors.white,//This line is problematic.
          children: [
            Expanded(
    ...
    ...
    ...
    ),
            Container(height: 30, color: Colors.red),
            AdmobBanner(),
          ],
        );
    }

It gives

The named parameter ‘backgroundColor’ isn’t defined.

error.

How can I solve my problem? What should I do to add background color for column? Will it solve my problem?

Thanks…

>Solution :

You can use Container around Column widget.

return Container(color: Colors.white,
child:
Column(
        //backgroundColor:Colors.white,//This line is problematic.
          children: [
            Expanded(
    ...
    ...
    ...
    ),
            Container(height: 30, color: Colors.red),
            AdmobBanner(),
          ],
        ));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading