Plugin to integrate Firebase Native Admob to Flutter application
Warning:
The plugin is based on Flutter PlatformView
(AndroidView
) to create a custom widget from Native View. Therefore, only Android is supported at the moment.
For iOS, wait for Flutter team to implement iOSView
equivalent.
For help getting started with Flutter, view our online documentation.
The plugin provides:
NativeAdmob
: a singleton class that let you to initialize Admob app IDNativeAdmobBannerView
: a Flutter widgetNativeAdmob
allows you to initialize Admob ID. For example:
final _nativeAdmob = NativeAdmob();
@override
void initState() {
super.initState();
_nativeAdmob.initialize(appID: "<Your Admob app ID>");
}
'NativeAdmobBannerView' is a Flutter widget, so you can add it anywhere in Flutter application. For example:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: ListView(
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
),
Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
),
Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
),
NativeAdmobBannerView(
adUnitID: "<Your ad unit ID>",
style: BannerStyle.dark, // enum dark or light
showMedia: true, // whether to show media view or not
contentPadding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 0.0), // content padding
),
Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
),
Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
),
Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
),
],
),
),
);
}
Warning:
NativeAdmobBannerView
has a fixed height. Its height is based on content height, content padding (contentPadding
parameter) and media view (showMedia
parameter). So you don't need to worry about the widget height.
To run example project, please follow this link: Flutter Firebase to integrate you google services
example/README.md
Demonstrates how to use the flutter_native_admob plugin.
For help getting started with Flutter, view our online documentation.
Add this to your package's pubspec.yaml file:
dependencies:
flutter_native_admob: ^0.1.1+2
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:flutter_native_admob/flutter_native_admob.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.1.1+2 | Nov 27, 2018 |
|
|
0.1.1+1 | Nov 27, 2018 |
|
|
0.1.1 | Nov 26, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
72
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
80
|
Overall:
Weighted score of the above.
[more]
|
82
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Format lib/flutter_native_admob.dart
.
Run flutter format
to format lib/flutter_native_admob.dart
.
The package description is too short. (-20 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.68.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 |