The Method [] was called on null

0

I am new to Flutter. I seen many tutorials on YouTube and Google but I can't find solution on this. How can I resolve this error?

import 'package:flutter/material.dart';
import 'dart:ui';
import 'dart:convert';
import 'data/shelfscreendata.dart';
import 'package:google_fonts/google_fonts.dart';
import 'constant/constant.dart' as Constants;
import 'PhotographerWelcomeNote.dart';
import 'package:http/http.dart' as http;
import 'Utility/global.dart' as Globals;
import 'data/errordata.dart';
import 'data/shelfscreendata.dart';
import 'data/shelfscreendata.dart';



class ShelfScreen extends StatefulWidget {
@override
_ShelfScreenState createState() => _ShelfScreenState();
}

class _ShelfScreenState extends State<ShelfScreen> {
bool  _isLoading = false;
Map CompaignShelfList;
List CampiagnData;

Future Shelf() async {
   Map data = {
  "AccessToken": "MjUyLTg1REEyUzMtQURTUzVELUVJNUI0QTIyMTE=",
  "CustomerId": 1
 };

 final http.Response response = await http.post(
   "http://api.pgapp.in/v1/shelflist",
  headers: <String, String>{
    'Content-Type': 'application/json; charset=UTF-8',
  },
  body: jsonEncode(data),
   );
   var jsonResponse = null;
   CompaignShelfList = json.decode(response.body);
   setState(() {
     CampiagnData = CompaignShelfList["CompaignShelfList"];
   });
   //       debugPrint(CompaignShelfList.toString());
   if (response.statusCode == 200)
   {
     jsonResponse = json.decode(response.body);
     print("Response status : ${response.statusCode}");
     print("Response status : ${response.body}");
     if(jsonResponse != null && ! jsonResponse.containsKey("Error")){
       setState(() {
         _isLoading = false;
       });
     }
     else{
       setState(() {
         _isLoading = false;
       });
       print("Response status : ${response.body}");
     }
   }
   }
  @override
 void initState() {
 super.initState();
 Shelf();
  }
 @override
 Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    backgroundColor: const Color(0xfff8f8f8),
    leading: Padding(
      padding: EdgeInsets.only(left: 20),
      child:  Image.asset("assets/logo.png",width: 45,height: 45,),
    ),
    title: Center(
      child: Image.asset("assets/Textimage.png",width: 170,height: 45),
    ),
    actions: <Widget>[
         Padding(
           padding: const EdgeInsets.only(right: 20,top: 10,bottom: 10),
           child: Container(
            height: 8,
            width: 35,
            child: CircleAvatar(
              maxRadius: 20,
              backgroundImage: AssetImage("assets/images/prof.jpg"),
            ),
        ),
         ),

    ],

  ),
  body: GridView.builder(
      shrinkWrap: false,
      scrollDirection: Axis.vertical,
      gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 1,
        childAspectRatio: 1.200,
        mainAxisSpacing: 1.0,
        crossAxisSpacing: 1.0,

      ),
      itemCount: CompaignShelfList.length,
      itemBuilder: (context, int index){
        return 
          CategoriesTile(
          imgUrls: CompaignShelfList[index]["CoverImagePath"],
          catagory:CompaignShelfList[index]["CampaignTitle"],
          date: CompaignShelfList[index]["Date"],
          email: CompaignShelfList[index]["PhotographerEmail"],
          stduio:CompaignShelfList[index]["BusinessName"],
        );
   //              Image.asset(Shelflist[index]["text_3"],fit: BoxFit.cover,);
      }
  )

  );

 }
 }




 class CategoriesTile extends StatelessWidget {
final String imgUrls, catagory , date,email,stduio;

 CategoriesTile({@required this.imgUrls, @required this.catagory,@required this.date,@required 
this.email,@required this.stduio});

@override
Widget build(BuildContext context) {
return GestureDetector(
  onTap: () {
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => PhotographerWelcomeNote(
              Coverpic: imgUrls,
            )));
  },
  child: Card(
    semanticContainer: true,
    clipBehavior: Clip.antiAliasWithSaveLayer,
    elevation: 5,
    child: Container(
      margin: EdgeInsets.all(8),
      child:
            Stack(
        children: <Widget>[
          Positioned(
            top: 1,
            left: 1,
            right: 1,
            bottom: 50,
            child: ClipRRect(
                borderRadius: BorderRadius.circular(8),
                child:Image.asset(
                  imgUrls,
                  height: 250,
                  width: 400,
                  fit: BoxFit.cover,
                )
               ),
          ),
          Positioned(
            bottom: 50,
            left: 1,
            right: 1,
       //                width: 400,
            height: 60,
            child: ClipRect(
              child: BackdropFilter(
                filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.black.withOpacity(0),
                    borderRadius: BorderRadius.circular(8),
                  ),

                ),
              ),
            ),
          ),
         Positioned(
           bottom: 80,
           left: 20,
           child: Container(
                  height: 50,
                  width: 400,
                  alignment: Alignment.bottomLeft,
                  child: Text(
                    catagory ?? "Yo Yo",
                    style: GoogleFonts.nunito(
                      fontSize: 18,
                      color: const Color(0xffffffff),
                      fontWeight: FontWeight.w700,
                      height: 1.7647058823529411,
                    ),
                  )),
         ),
          Positioned(
            left: 20,
            bottom: 60,
            child: Container(
                   height: 30,
                   width: 150,
                alignment: Alignment.bottomLeft,
                          child: Text(
                    date,style: GoogleFonts.nunito(
                  fontSize: 13,
                  color: const Color(0xffffffff),
                  fontWeight: FontWeight.w700,
                  height: 1.7647058823529411,
                ),
                ),
              ),
          ),
                     Positioned(
                   bottom: 20,
                       left: 90,
                       child: Container(
                       height: 23,

                       alignment: Alignment.center,
                         child: Text(
                         stduio,
                             style: GoogleFonts.nunito(
                           fontSize: 18,
                         color: const Color(0xff7f7f7f),
                         fontWeight: FontWeight.w700,
                         )
                       ),
                     ),
                     ),
                      Positioned(
                               bottom: 1,
                                left: 90,
                           child: Container(
                                  height: 20,

                            alignment: Alignment.center,
                            child: Text(
                              email,style: GoogleFonts.nunito(
                              fontSize: 10,
                              color: const Color(0xffb4b4b4),
                              fontWeight: FontWeight.w600,
                            ),
                            ),
                           ),
                      ),
          Positioned(
           bottom: 2,
            left: 10,
            child: Container(
              width: 66.0,
              height: 39.0,
              decoration: BoxDecoration(
                image: DecorationImage(
                  image: const AssetImage(
                      'assets/images/camlogo.jpg'),
                  fit: BoxFit.cover,
                ),
                border: Border.all(
                    width: 1.0, color: const Color(0xffb4b4b4)),
              ),
            ),
          ),
        ],
      ),
    ),
  ),

 );
 }
 }
json
flutter
asked on Stack Overflow Nov 14, 2020 by Ah Zeem khatib • edited Nov 15, 2020 by halfer

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0