crosspromote_flutter 0.2.0 copy "crosspromote_flutter: ^0.2.0" to clipboard
crosspromote_flutter: ^0.2.0 copied to clipboard

Flutter widgets to display CrossPromote ads.

example/lib/main.dart

import 'dart:math' as math;

import 'package:crosspromote_flutter/crosspromote_flutter.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(
    const MaterialApp(
      title: 'Flutter Demo',
      home: Page(),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    final width = MediaQuery.sizeOf(context).width;
    final padding = math.max<double>(
      0,
      (width - 400) / 2,
    );

    return Scaffold(
      appBar: AppBar(title: const Text('CrossPromote')),
      body: ListView(
        padding: EdgeInsets.symmetric(
          vertical: 20,
          horizontal: padding,
        ),
        children: [
          for (final size in AdSize.values) ...[
            Text('${size.width}x${size.height}'),
            CrossPromote(
              appId: 'example.image.${size.name}',
              size: size,
              match: AdMatch.exactSize,
            ),
          ],
        ],
      ),
    );
  }
}