FLUTTER: Google mobile ads error "'Type WriteBuffer' not found.", "Type 'ReadBuffer' not found."

74 views Asked by At

I am trying to use google_mobile_ads but It does not work.

The error is:

../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/google_mobile_ads-3.0.0/lib/src/ump/user_messaging_codec.dart:27:19: Error: Type 'WriteBuffer' not found.
  void writeValue(WriteBuffer buffer, dynamic value) {
                  ^^^^^^^^^^^
../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/google_mobile_ads-3.0.0/lib/src/ump/user_messaging_codec.dart:45:41: Error: Type 'ReadBuffer' not found.
  dynamic readValueOfType(dynamic type, ReadBuffer buffer) {
                                        ^^^^^^^^^^
../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/google_mobile_ads-3.0.0/lib/src/ump/user_messaging_codec.dart:27:19: Error: 'WriteBuffer' isn't a type.
  void writeValue(WriteBuffer buffer, dynamic value) {
                  ^^^^^^^^^^^
../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/google_mobile_ads-3.0.0/lib/src/ump/user_messaging_codec.dart:45:41: Error: 'ReadBuffer' isn't a type.
  dynamic readValueOfType(dynamic type, ReadBuffer buffer) {

I used the sample here: https://github.com/flutterguru1/source_code/blob/main/admob_interstitialAd/main.dart

I just want to show interstitial add when tap on the button. How can I fix it?

1

There are 1 answers

0
MoNe On

According to #668:

  • Update the google_mobile_ads package to 3.1.0 or above
  • Go to the user_messaging_codec.dart in pub-cache and add this import: import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;