简体   繁体   中英

Flutter: Exception caught by widgets library error

In the app i am developing i keep getting the below error.Below after the error is the code section that it points to.

Exception caught by widgets library ══════════════════════════════════
'package:flutter/src/painting/_network_image_io.dart': Failed assertion: line 25 pos 14: 
'url != null': is not true.
The relevant error-causing widget was
Homepage
lib/…/LandingPage/landingServices.dart:359

** line 359 is below on child: Homepage() and I added the code before and right after. ════════════════════════════════════════════════════════════════════════════════

                           .createUserCollection(context, {
                            'userpassword': userPasswordController.text,
                            'useruid': Provider.of<Authentication>(context,
                                    listen: false)
                                .getUserUid,
                            'useremail': userEmailController.text,
                            'username': userNameController.text,
                            'userimage': Provider.of<LandingUtils>(context,
                                    listen: false)
                                .getUserAvatarUrl,
                          });
                        }).whenComplete(() {
                          Navigator.pushReplacement(
                              context,
                              PageTransition(
                              child: Homepage(),
                                  type: 
                     PageTransitionType.bottomToTop));

my homepage code is here:

   class Homepage extends StatefulWidget {
   @override
   _HomepageState createState() => _HomepageState();
 }

  class _HomepageState extends State<Homepage> {
  ConstantColors constantColors = ConstantColors();
  final PageController homepageController = PageController();
  int pageIndex = 0;

 @override
 void initState() {
 Provider.of<FirebaseOperations>(context, listen: false)
    .initUserData(context);
 super.initState();
 }

 @override
 Widget build(BuildContext context) {
 return Scaffold(
    backgroundColor: constantColors.darkColor,
    body: PageView(
      controller: homepageController,
      children: [Feed(), Chatroom(), Profile()],
      physics: NeverScrollableScrollPhysics(),
      onPageChanged: (page) {
        setState(() {
          pageIndex = page;
        });
      },
    ),
    bottomNavigationBar:
        Provider.of<HomepageHelpers>(context, listen: false)
            .bottomNavBar(context, pageIndex, homepageController));
 }
}

any idea? I cant figure this out. Thanks!

Just Change the context to the right of homepageController .. Trust me it will suerly work..


 bottomNavigationBar:
        Provider.of<HomepageHelpers>(context, listen: false)
            .bottomNavBar(pageIndex, homepageController, context));
 }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM