Wednesday, May 31, 2023
HomeiOS Developmentandroid - Undefined identify 'mounted' in Flutter

android – Undefined identify ‘mounted’ in Flutter


I get this error: Undefined identify ‘mounted’ sooner or later fetchoffers widget. Can anybody assist me with this downside? I wish to use this to make in app purchases work in my flutter app.


import 'bundle:flutter/materials.dart';
import 'bundle:AnyKnower/chatgpt.dart';
import 'bundle:AnyKnower/privacypolicy.dart';
import 'bundle:AnyKnower/purchase_api.dart';
import 'bundle:AnyKnower/utils.dart';
import 'bundle:glassfy_flutter/fashions.dart';
import 'bundle:supplier/supplier.dart';
import 'chat_screen.dart';
import 'bundle:page_transition/page_transition.dart';
import 'glassfy_provider.dart';
class NavBar extends StatelessWidget {
  bool isSubscribed = false;



  @override
  Widget construct(BuildContext context) {
    return Drawer(

        little one: ListView(
          padding: EdgeInsets.zero,
          kids: [
            ClipRRect(
              borderRadius: BorderRadius.only(
                topRight: Radius.circular(15),
              ),
              child: UserAccountsDrawerHeader(
                accountName: Text('AnyKnower'),
                accountEmail: Text(''),
                currentAccountPicture: CircleAvatar(
                  child: ClipOval(
                    child: Image.asset('assets/logo4.jpg', width: 100, height: 100, fit: BoxFit.cover),
                  ),
                ),
                decoration: BoxDecoration(
                  image: DecorationImage(

                    image: AssetImage("assets/background1.jpg"),
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ),
            ListTile(
              leading: Icon(Icons.chat_rounded,color: Colors.blueGrey,),
              title: Text("AnyKnower Chat"),
              onTap: () {
                Navigator.of(context).push(PageTransition(child: ChatScreen(), type: PageTransitionType.fade));

              }
            ),
            ListTile(
                leading: Icon(Icons.shopping_cart_outlined,color: Colors.blueGrey,),
                title: Text("The AnyKnower Shop"),
                onTap: () {
                  fetchOffers(context);

                }
            ),
            ListTile(
                leading: Icon(Icons.chat_outlined,color: Colors.blueGrey,),
                title: Text("Beta Premium chat"),
                onTap: () {
                  Navigator.of(context).push(PageTransition(child: chatgpt(), type: PageTransitionType.fade));

                }
            ),
            ListTile(
                leading: Icon(Icons.privacy_tip_outlined,color: Colors.blueGrey,),
                title: Text("Privacy Policy"),
                onTap: () {
                  Navigator.of(context).push(PageTransition(child: privacypolicy(), type: PageTransitionType.fade));

                }
            ),
          ],
        )

    );

  }

 Future fetchOffers(BuildContext context) async {
    closing choices = await PurchaseApi.fetchOffers();
    closing supply = choices.singleWhere((providing) => providing.offeringId == '100AnyKnowerCredit');
   if(!mounted) return;
   Utils.showSheet(
     context,
       (context) => PayWallWidget(
         title: 'Improve your plan',
           description: 'kkdkdd',
         supply: supply,
         onClickedSku: (sku) async {
           closing transaction = await PurchaseApi.purchaseSku(sku);
           if (mounted!) return;
           if (transaction != null) {
             closing supplier = context.learn<GlassfyProvider>();
             supplier.add10Coins();
           }
           Navigator.pop(context);
         },
       )
   );

    }


    }

Do i possibly have to import one thing? I noticed by an different put up that it wanted to be an statefullwidget however what do i want to alter to make that occur then?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments