Skip to content

Error: The getter 'publisherConsents' isn't defined for the class 'BasicConsentInfo' #10

@chrissy-dev

Description

@chrissy-dev

I can't seem to access publisherConsents in the return. I can print it but I can't access it? Any ideas? I'm using the demo code.

I'd like to create a wrapper that takes a widget, checks for consent and decides whether the it can load.

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

class ConsentGate extends StatefulWidget {
  const ConsentGate({Key? key, required this.child}) : super(key: key);

  final Widget child;

  @override
  State<ConsentGate> createState() => _ConsentGateState();
}

class _ConsentGateState extends State<ConsentGate> {
  BasicConsentInfo? consentInfo;

  @override
  void initState() {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      consentInfo = await _getConsentInfo();
    });
    super.initState();
  }

  Future<BasicConsentInfo?> _getConsentInfo() async {
    BasicConsentInfo? consent =
        await IabtcfConsentInfo.instance.currentConsentInfo();

    setState(() {
      consentInfo = consent;
    });

    return consent;
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Text(consentInfo.toString());
  }
}

I'd like to have a conditional check in the build but I can't access the data. I can see the data being printed but I'm unsure how to access it.

Screenshot 2023-03-20 at 13 27 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions