Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
ddb2de6
Initial version of AdSense plugin for Flutter Web
sokoloff06 Jun 5, 2024
968dcdb
Merge branch 'flutter:main' into main
sokoloff06 Jun 5, 2024
3c99bae
Merge branch 'flutter:main' into main
sokoloff06 Jul 21, 2024
c37d644
WIP: apply flutter_packages analysis_options.yaml and fixing warnings
sokoloff06 Jul 21, 2024
dfae8ee
Merge remote-tracking branch 'origin/main'
sokoloff06 Jul 21, 2024
15826c0
remove local analysis_options.yaml
sokoloff06 Jul 21, 2024
6050087
Update README.md, pubspec.yaml, work on example and linter warnings
sokoloff06 Jul 25, 2024
25158d3
Update public API, add example, update README.md, add more docs and s…
sokoloff06 Jul 27, 2024
91ae43f
Update public API, add example, update README.md, add more docs and s…
sokoloff06 Jul 27, 2024
4308c93
Merge remote-tracking branch 'origin/main'
sokoloff06 Jul 27, 2024
52fb128
Merge remote-tracking branch 'origin/main'
sokoloff06 Jul 27, 2024
a562233
Merge remote-tracking branch 'origin/main'
sokoloff06 Jul 27, 2024
500483d
Fix analyzer warnings
sokoloff06 Jul 27, 2024
65c61ab
Updated README.md
sokoloff06 Jul 27, 2024
065e6fe
Add documentation, copyright, initial tests, update README.md
sokoloff06 Aug 4, 2024
b99f4f7
Fix linter error
sokoloff06 Aug 4, 2024
2c7db93
Make plugin closer to publishable state: update copyright, commit mis…
sokoloff06 Aug 4, 2024
1697032
Rename adView to adUnit, fix deps and update README.md
sokoloff06 Aug 4, 2024
875f621
Merge branch 'main' into main
sokoloff06 Aug 4, 2024
5773e5d
Refactoring + unit tests
sokoloff06 Aug 11, 2024
537d611
Merge remote-tracking branch 'origin/main'
sokoloff06 Aug 11, 2024
f105166
Refactoring + unit tests
sokoloff06 Aug 11, 2024
7d3b9c2
Upgrade dart SDK
sokoloff06 Aug 11, 2024
de1fe7c
Upgrade package:web and dart
sokoloff06 Aug 11, 2024
458cb4e
Add integration test
sokoloff06 Sep 15, 2024
ffab481
Clarify 403 error in README.md
sokoloff06 Sep 15, 2024
257007f
Rename ad_unit_widget.dart and solve dart analysis errors
sokoloff06 Sep 27, 2024
7701a7c
Merge branch 'main' into main
sokoloff06 Sep 27, 2024
172dd00
Add styling property for adUnit CSS customization
sokoloff06 Oct 12, 2024
c427a8a
Merge remote-tracking branch 'origin/main'
sokoloff06 Oct 12, 2024
689b1a6
Merge branch 'main' into main
sokoloff06 Oct 12, 2024
215da90
Code format
sokoloff06 Oct 12, 2024
3232f0e
Fix repo rules
sokoloff06 Oct 12, 2024
d59f7b7
Fix repo rules
sokoloff06 Oct 12, 2024
98b0845
Update min Dart version and readme links
sokoloff06 Oct 12, 2024
0232565
Update min SDK versions for dependencies compatibility
sokoloff06 Oct 12, 2024
f2b9c06
Fix typo
sokoloff06 Oct 16, 2024
db13a98
Revert README.md
sokoloff06 Oct 28, 2024
51e2042
Update README.md
sokoloff06 Oct 28, 2024
c57e03f
Merge branch 'main' into main
sokoloff06 Oct 28, 2024
e6842f2
Update README.md, rename class Adsense into AdSense
sokoloff06 Oct 28, 2024
913f347
Update packages/google_adsense/example/pubspec.yaml
sokoloff06 Oct 28, 2024
9ba0ba5
Use instance property to access AdSense singleton instance
sokoloff06 Oct 28, 2024
eb20328
Merge remote-tracking branch 'sokoloff06/main' into fork/sokoloff06/main
sokoloff06 Oct 28, 2024
2a8a998
Add explanation about local DNS records for testing environment
sokoloff06 Oct 29, 2024
1c29983
Use strong String type for additionalParams argument values
sokoloff06 Oct 29, 2024
d07ea36
Remove as JS* casts, change isAdTest default value, improve some docs…
sokoloff06 Oct 29, 2024
d48aa16
Remove as JS* casts, change isAdTest default value, improve some docs…
sokoloff06 Oct 29, 2024
094460b
Add screenshots to pubspec.yaml
sokoloff06 Oct 30, 2024
3f58513
Simplify ResizeObserver, define adsbygoogle JS variable
sokoloff06 Nov 3, 2024
988d3f7
Code cleanup
sokoloff06 Nov 3, 2024
6c244fd
Merge tests
sokoloff06 Nov 3, 2024
410a7eb
Tests cleanup
sokoloff06 Nov 3, 2024
dc78f2e
Provide adSense global variable for convenience
sokoloff06 Nov 3, 2024
12e657d
Remove adClient override logic,
sokoloff06 Nov 11, 2024
3a820bc
Update adUnit API with AdUnitConfiguration and named constructors for…
sokoloff06 Nov 12, 2024
1d288db
Remove test_ad.html, format code
sokoloff06 Nov 12, 2024
d214fc0
Merge branch 'main' into main
sokoloff06 Nov 12, 2024
3fda3da
Ignore avoid_print in test, remove redundant arguments
sokoloff06 Nov 12, 2024
0258b86
use testWidgets in integration tests
sokoloff06 Nov 12, 2024
b9f61b8
Fix adUnit returns Widget type test
sokoloff06 Nov 12, 2024
c509169
Update README.md and add LICENSE
sokoloff06 Nov 12, 2024
4096469
Tweak JS-interop.
ditman Nov 13, 2024
fbde1c2
Tweak ad unit param enums.
ditman Nov 13, 2024
bbaa9db
Use new js-interop init. Remove array fallback from addMasterScript.
ditman Nov 13, 2024
9742dcf
Use new types in ad_unit_configuration
ditman Nov 13, 2024
3acd43c
Use Size for ad unit widget. Some tweaks.
ditman Nov 13, 2024
bc140f4
dart format .
ditman Nov 13, 2024
bd7f839
Fix HTMLDivElement cast
ditman Nov 13, 2024
604b87b
Use offsetWidth/height
ditman Nov 13, 2024
4175da6
Fix tests
ditman Nov 13, 2024
36d2550
Merge pull request #1 from ditman/adsense-js-interop
sokoloff06 Nov 17, 2024
875f72c
Remove width and height css rules, fix test app
sokoloff06 Nov 17, 2024
41edb56
TO_REVIEW: Optimize? - Reuse single static ResizeObserver as per [thi…
sokoloff06 Nov 17, 2024
39dfc97
Hide logs from release, add AdStatus enum,
sokoloff06 Nov 17, 2024
1bbaeee
Fix AdStatus
sokoloff06 Nov 17, 2024
7a31b8e
Fix unit tests CI
sokoloff06 Nov 17, 2024
aeab558
Add TrustedTypes support
sokoloff06 Nov 17, 2024
3235d27
Remove stub tests
sokoloff06 Nov 17, 2024
5a7abad
Fix missing type annotation
sokoloff06 Nov 17, 2024
9dca5d1
Update README.md excerpts
sokoloff06 Nov 17, 2024
7d828cf
Update example to more complex layout
sokoloff06 Nov 17, 2024
d9dbc79
Merge branch 'main' into main
sokoloff06 Nov 17, 2024
308a325
Simplify API: remove cssText and add docs to use Flutter instruments,…
sokoloff06 Nov 19, 2024
baac6ba
Tweak initialization. Support prior initialization in HTML.
ditman Nov 21, 2024
2d9e5bd
Add integration tests mocking window.adsbygoogle. Tweaks.
ditman Nov 21, 2024
456da08
Ensure package compiles in Wasm.
ditman Nov 21, 2024
5f2b324
Tweak the API of AdSense. Rename internal adClient to adClientId. Mak…
ditman Nov 21, 2024
ffd8c4a
Remove adClient from AdUnitParams object, because it's always passed …
ditman Nov 21, 2024
7e4ddc9
Pass clientId when creating ad units from AdSense instance.
ditman Nov 21, 2024
d2b42f1
Simplify some more code.
ditman Nov 21, 2024
e5da3bf
Make isAdTest a normal member of the config. Remove unused getters.
ditman Nov 21, 2024
9ce3347
Remove AdUnitWidget._internal constructor.
ditman Nov 21, 2024
8bda3fd
Make as much API private as possible.
ditman Nov 21, 2024
500337e
Use new constructor instead of the removed factory.
ditman Nov 21, 2024
06886dd
Allow limiting ads by height, update example
sokoloff06 Nov 24, 2024
a36f9f8
Allow limiting ads by height, update example
sokoloff06 Nov 24, 2024
7f55807
Merge pull request #2 from ditman/add-mock-adsense-tests
sokoloff06 Nov 24, 2024
ba38273
Fix CI analyzer fails
sokoloff06 Nov 24, 2024
1914f6b
Fix CI analyzer fails
sokoloff06 Nov 24, 2024
c5e46a6
Fix CI analyzer fails
sokoloff06 Nov 24, 2024
3bb56b9
Make sure <ins> initial size is equal to wrapping div
sokoloff06 Nov 25, 2024
d7abe89
dart format
sokoloff06 Nov 25, 2024
a92864f
Add docs on using BoxConstraints
sokoloff06 Nov 25, 2024
4e52e92
Update tests to match AdSense behavior, and our code.
ditman Nov 28, 2024
44fc9e6
Update README.md and comments
sokoloff06 Dec 1, 2024
49a7a75
Merge pull request #3 from ditman/fix-ins-in-integration-test
sokoloff06 Dec 1, 2024
683fe65
Update README.md
sokoloff06 Dec 2, 2024
06803b8
Update README.md
sokoloff06 Dec 4, 2024
c0d9ec3
Merge remote-tracking branch 'sokoloff06/main' into fork/sokoloff06/main
sokoloff06 Dec 4, 2024
6dbecd7
Merge branch 'main' into main
sokoloff06 Dec 4, 2024
53f47e4
Move exports to experimental folder, update README.md
sokoloff06 Dec 4, 2024
9735ba0
Fix CI
sokoloff06 Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update README.md, pubspec.yaml, work on example and linter warnings
  • Loading branch information
sokoloff06 committed Jul 25, 2024
commit 605008758c4a051970fe47185e88e684decb3979
4 changes: 2 additions & 2 deletions packages/google_adsense/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.0.1
## 0.1.0

* Initial MVP release.
* Initial release.
71 changes: 32 additions & 39 deletions packages/google_adsense/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
Plugin allowing Adsense integration with Flutter Web

[//]: # (## Features)

[//]: # ()
[//]: # (TODO: List what your package can do. Maybe include images, gifs, or videos.)

[//]: # ()
[//]: # (## Getting started)

[//]: # ()
[//]: # (TODO: List prerequisites and provide or point to information on how to)

[//]: # (start using the package.)

[//]: # ()
[//]: # (## Usage)

[//]: # ()
[//]: # (TODO: Include short and useful examples for package users. Add longer examples)

[//]: # (to `/example` folder.)

[//]: # ()
[//]: # (```dart)

[//]: # (const like = 'sample';)

[//]: # (```)

[//]: # ()
[//]: # (## Additional information)

[//]: # ()
[//]: # (TODO: Tell users more about the package: where to find more information, how to)

[//]: # (contribute to the package, how to file issues, what response they can expect)

[//]: # (from the package authors, and more.)
# google_adsense
[Google AdSense](https://adsense.google.com/intl/en_us/start/) plugin for Flutter Web

Generally integration with AdSense requires:

1. Adding an [AdSense code](https://support.google.com/adsense/answer/9274634?hl=en&ref_topic=28893&sjid=9002959242386336076-EU) usually in between the `<head></head>` tag to connect your site with AdSense account. Allows using **Auto ads**
2. Adding [ad unit code](https://support.google.com/adsense/answer/9274025?sjid=9002959242386336076-EU) in between the `<body><body/>` tags of your pages where you want ad to appear. Ad unit code snippet is unique per **ad unit** that you need to create in your AdSense account first. You might have several ad units added to your website

Since Flutter apps are not rendered as traditional HTML pages and there is no easy way to access final DOM tree from Dart, this plugin provides a Widget (`AdViewWidget`) that you can configure as an ad unit and place in the desired location in your app UI


## Installation
run `flutter pub add google_adsense`

## Usage
#### Initialize AdSense
Before displaying ads, initialize the AdSense with your ad client ID.
```dart
import 'package:google_adsense/adsense.dart';

void main() {
Adsense().initialize('your-ad-client-id');
}
```
#### Display AdViewWidget
```dart
import 'package:google_adsense/adsense.dart';
// ...
val adWidget = Adsense().adView(
adSlot: 'your-ad-slot-id',
);
```
2 changes: 0 additions & 2 deletions packages/google_adsense/lib/adsense.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
library adsense_web_standalone;

export 'src/adsense_stub.dart' if (dart.library.html) 'src/adsense_web.dart';
8 changes: 4 additions & 4 deletions packages/google_adsense/lib/src/adsense_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'ad_view_widget.dart';

class Adsense {
static final Adsense _instance = Adsense._internal();
static bool isInitialized = false;
static bool _isInitialized = false;

Adsense._internal();

Expand All @@ -19,11 +19,11 @@ class Adsense {
}

void initialize(String adClient) {
if (isInitialized) {
if (_isInitialized) {
log('Adsense was already initialized, skipping');
return;
}
isInitialized = true;
_isInitialized = true;
_addMasterScript(adClient);
}

Expand All @@ -49,7 +49,7 @@ class Adsense {
}

static void _addMasterScript(String adClient) {
web.HTMLScriptElement scriptElement = web.HTMLScriptElement();
final web.HTMLScriptElement scriptElement = web.HTMLScriptElement();
scriptElement.async = true;
scriptElement.src =
'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-$adClient';
Expand Down
52 changes: 10 additions & 42 deletions packages/google_adsense/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,58 +1,26 @@
name: google_adsense
description: Google Adsense plugin for Flutter Web
repository: https://github.com/flutter/packages/tree/main/packages/google_adsense
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_adsense%22
version: 0.0.1
homepage:

environment:
sdk: '>=3.1.0 <4.0.0'
flutter: ">=1.17.0"
sdk: ^3.1.0
flutter: ^1.17.0

dependencies:
flutter:
sdk: flutter
web: ^0.5.1

dev_dependencies:
build_runner: ^2.4.9
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
test: ^1.24.9
mockito: ^5.4.4
build_runner: ^2.4.9

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
test: ^1.24.9

# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
topics:
- monetization
- ads