Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 对null调用了方法[]_Json_Flutter - Fatal编程技术网

Json 对null调用了方法[]

Json 对null调用了方法[],json,flutter,Json,Flutter,我是个新手。我在YouTube和Google上看过很多教程,但我找不到解决这个问题的方法。如何解决此错误 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'

我是个新手。我在YouTube和Google上看过很多教程,但我找不到解决这个问题的方法。如何解决此错误

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)),
              ),
            ),
          ),
        ],
      ),
    ),
  ),

 );
 }
 }
导入“包装:颤振/材料.省道”;
导入“dart:ui”;
导入“dart:convert”;
导入“数据/shelfscreenda.dart”;
导入“package:google_fonts/google_fonts.dart”;
将“常量/常量.dart”作为常量导入;
导入“PicturerWelcomenote.dart”;
将“package:http/http.dart”导入为http;
将“Utility/global.dart”作为全局导入;
导入“data/errordata.dart”;
导入“数据/shelfscreenda.dart”;
导入“数据/shelfscreenda.dart”;
类ShelfScreen扩展StatefulWidget{
@凌驾
_ShelfScreenState createState()=>\u ShelfScreenState();
}
类_ShelfScreenState扩展状态{
bool_isLoading=false;
地图公司;
列出坎皮亚甘达;
Future Shelf()异步{
地图数据={
“AccessToken”:“MjUyLTg1REEyUzMtQURTUzVELUVJNUI0QTIyMTE=”,
“客户ID”:1
};
final http.Response Response=wait http.post(
"http://api.pgapp.in/v1/shelflist",
标题:{
“内容类型”:“应用程序/json;字符集=UTF-8”,
},
正文:JSONECODE(数据),
);
var jsonResponse=null;
CompaignShelfList=json.decode(response.body);
设置状态(){
campiagnada=CompaignShelfList[“CompaignShelfList”];
});
//debugPrint(CompaignShelfList.toString());
如果(response.statusCode==200)
{
jsonResponse=json.decode(response.body);
打印(“响应状态:${Response.statusCode}”);
打印(“响应状态:${Response.body}”);
if(jsonResponse!=null&&!jsonResponse.containsKey(“错误”)){
设置状态(){
_isLoading=false;
});
}
否则{
设置状态(){
_isLoading=false;
});
打印(“响应状态:${Response.body}”);
}
}
}
@凌驾
void initState(){
super.initState();
架子();
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
背景颜色:常量颜色(0xFFF8),
前导:填充(
填充:仅限边缘设置(左:20),
子项:Image.asset(“assets/logo.png”,宽:45,高:45,),
),
标题:中心(
子项:Image.asset(“assets/Textimage.png”,宽:170,高:45),
),
行动:[
填充物(
填充:仅限常量边集(右:20,顶部:10,底部:10),
子:容器(
身高:8,
宽度:35,
孩子:圆环星(
最大半径:20,
背景图片:AssetImage(“assets/images/prof.jpg”),
),
),
),
],
),
正文:GridView.builder(
收缩膜:假,
滚动方向:轴垂直,
gridDelegate:新SliverGridDelegateWithFixedCrossAxisCount(
交叉轴计数:1,
儿童比例:1.200,
主轴间距:1.0,
交叉轴间距:1.0,
),
itemCount:CompaignShelfList.length,
itemBuilder:(上下文,int索引){
返回
范畴(
imgUrls:CompaignShelfList[index][“CoverImagePath”],
分类:CompaignShelfList[索引][“活动标题”],
日期:CompaignShelfList[索引][“日期”],
电邮:CompaignShelfList[索引][“拍照留念”],
stduio:CompaignShelfList[index][“BusinessName”],
);
//资产(Shelflist[index][“text_3”],fit:BoxFit.cover,);
}
)
);
}
}
类CategoriesTile扩展了无状态小部件{
最终字符串符号、类别、日期、电子邮件、stduio;
分类文件({@required this.imgUrls,@required this.catagory,@required this.date,@required
this.email,@required this.stduio});
@凌驾
小部件构建(构建上下文){
返回手势检测器(
onTap:(){
导航器。推(
上下文
材料路线(
生成器:(上下文)=>摄影师帮助注释(
封面图片:imgUrls,
)));
},
孩子:卡片(
语义容器:对,
clipBehavior:Clip.antiAliasWithSaveLayer,
标高:5,
子:容器(
保证金:全部(8),
儿童:
堆叠(
儿童:[
定位(
排名:1,
左:1,,
右:1,,
底数:50,
孩子:ClipRRect(
边界半径:边界半径。圆形(8),
子:Image.asset(
伊姆古尔斯,
身高:250,
宽度:400,
适合:BoxFit.cover,
)
),
),
定位(
底数:50,
左:1,,
右:1,,
//宽度:400,
身高:60,
孩子:ClipRect(
孩子:背投滤波器(
过滤器:ImageFilter.blur(sigmaX:3,sigmaY:3),
子:容器(
装饰:盒子装饰(
颜色:颜色。黑色。不透明度(0),
边界半径:边界半径。圆形(8),
),
),
),
),
),
定位(
底部:80,
左:20,,
子:容器(
身高:50,
宽度:400,
对齐:对齐。左下角,
子:文本(
分类??“溜溜球”,
风格:GoogleFonts.nunito(
尺码:18,
颜色:常量颜色(0xFFFFFF),
fontWeight:fontWeight.w700,
身高:1.7647058823529411,
),
)),
),
定位(
左:20,,
底数:60,
子:容器(
身高:30,
宽度:150,
对齐:对齐。左下角,
子:文本(
日期、样式:GoogleFonts.nunito(