smartlinks_ad 1.0.0
smartlinks_ad: ^1.0.0 copied to clipboard
A Flutter package for Linklytics SmartLinks Ads.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:smartlinks_ad/smartlinks_ad.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('SmartLinks Ad Example')),
body: const AdExample(),
),
);
}
}
class AdExample extends StatefulWidget {
const AdExample({super.key});
@override
State<AdExample> createState() => _AdExampleState();
}
class _AdExampleState extends State<AdExample> {
final _adService = SmartLinksAdService(baseUrl: 'http://127.0.0.1:8000');
bool _initialized = false;
@override
void initState() {
super.initState();
_init();
}
Future<void> _init() async {
// Replace with your API Key
await _adService.initialize('YOUR_API_KEY_HERE');
setState(() {
_initialized = true;
});
}
@override
Widget build(BuildContext context) {
if (!_initialized) {
return const Center(child: CircularProgressIndicator());
}
return Column(
children: [
const Text('Banner Ad Below:'),
const SizedBox(height: 10),
SmartLinkBannerAd(adService: _adService, height: 100),
const Spacer(),
const Text('End of screen'),
],
);
}
}