flutter3广告

import 'package:flutter/material.dart';

class AdBanner extends StatelessWidget {
  const AdBanner({super.key});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        // 主要内容
        Container(
          height: 100.0,
          color: Colors.lightBlue,
          child: const Center(
            child: Text(
              '主要内容',
              style: TextStyle(color: Colors.white, fontSize: 20),
            ),
          ),
        ),
        // 广告banner
        Positioned(
          bottom: 0.0,
          left: 0.0,
          right: 0.0,
          child: Container(
            color: Colors.black54,
            padding:
                const EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
            child: const Text(
              '这是一个广告',
              style: TextStyle(color: Colors.white, fontSize: 16),
            ),
          ),
        ),
      ],
    );
  }
}

void main() {
  runApp(const MaterialApp(home: AdBanner()));
}

  

posted @ 2024-07-02 09:19  飞雪飘鸿  阅读(7)  评论(0编辑  收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL