'Futurebuilder NoSuchMethodError The method [] was called on null receiver : null

I have an error message using futurebuilder in flutter. My widget code is : Do you see a visible error in my code ? My function Get_Date_Claim() uses http for contact my php server and it returns a value like that :

$response["status"]=1;

$response["dateclaim"]=$date1;

$response["message"]="";

$response["solde"]=$data['balance'];

import 'package:flutter/material.dart';
import 'dart:convert';
import 'login.dart';
import 'dart:async';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'menu_member.dart';
import 'globals.dart' as globals;
import 'appbar_draw.dart';
import 'package:awesome_page_transitions/awesome_page_transitions.dart';
import 'win_credit.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:http/http.dart' as http;


class HomePage extends StatefulWidget {

  HomePage_State createState() {
    return HomePage_State();
  }

}

class HomePage_State extends State<HomePage> {
// User Logout Function.
  Future logout(BuildContext context) async {

    final storage = new FlutterSecureStorage();

    await storage.deleteAll();

    globals.id_membre="";

    Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => LoginPage())
    );
  }

Future Get_Date_Claim() async {

  Map<String,dynamic> claim;

    // SERVER LOGIN API URL
    var url = 'https://www.bemyfaucet.com/app/get_date_claim.php';

    // Store all data with Param Name.
    var data = {'id_membre':globals.id_membre,'lang':context.locale.toString()};

    // Starting Web API Call.
    var response = await http.post(url, body: json.encode(data),headers: {'content-type': 'application/json','accept': 'application/json','authorization': globals.token});

    // Getting Server response into variable.
    claim = json.decode(response.body);
    
    return claim;
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
        children: <Widget>[
          Positioned.fill(
            child: Image( image: AssetImage('assets/img/background.jpg'), fit : BoxFit.fill, ),
          ),
          Scaffold(
            appBar: drawappbar(true),
            backgroundColor: Colors.transparent,
            drawer: new DrawerOnly(className: HomePage()),
            body:
    Container(
    height: MediaQuery
        .of(context)
        .size
        .height,
    width: MediaQuery
        .of(context)
        .size
        .width,
    margin: const EdgeInsets.only(
    top: 10.0, bottom: 10, right: 10, left: 10),
    decoration: BoxDecoration(
    color: Color(0xddb84a).withOpacity(0.9),
    border: Border.all(
    color: Colors.white,
    width: 3,
    ),
    borderRadius: BorderRadius.circular(25),
    ),
    child:
            Center(
                child:
                Column(children: <Widget>[
                  Expanded(
                      child : ListView(
                          children : <Widget>[
                            Container(
                                margin: const EdgeInsets.only(top: 20.0,bottom:20.0),
                                child: Text('Espace_Membre'.tr(),
                                    textAlign: TextAlign.center,
                                    style: TextStyle(
                                        fontSize: 30.0, color: Colors.white))
                            ),
                  Container(
                      height: 40,
                      width: MediaQuery.of(context).size.width,
                      padding : EdgeInsets.only(left: 20, right:20),
                      margin: EdgeInsets.only(top:20,bottom: 20.0),
                      color: Colors.blue[700],
                      child: Center(
                          child:
                          Text("1 - "+"Gagnez_BMF".tr(),style: TextStyle(fontSize: 20, color: Colors.white))
                      )
                  ),
                  Container(
                    margin: EdgeInsets.only(top:10),
                    child : 
                    FutureBuilder(
            future: Get_Date_Claim(),
            initialData: [],
            builder: (BuildContext context, AsyncSnapshot snapshot) {
          switch (snapshot.connectionState) {
          case ConnectionState.waiting: return new Center(child: new CircularProgressIndicator(),);
          default:
          if(snapshot.hasError) {
          return new Center(child: new Text('Error: ${snapshot.error}'),);
          }
          else {
            Map <String,dynamic> values = snapshot.data[0];
            String date_claim=values[0].dateclaim;
            print("date="+date_claim);
                    return ElevatedButton(
                        style : ElevatedButton.styleFrom(
                            primary: Colors.green,
                            padding: EdgeInsets.symmetric(horizontal: 40, vertical: 10),
                            textStyle: TextStyle(
                                fontSize: 20,
                                fontWeight: FontWeight.bold)),
                      child: Text(
                          'Cliquez_Ici'.tr()),
                      onPressed: () {
                        Navigator.push(context,
                            AwesomePageRoute(
                              transitionDuration: Duration(milliseconds: 600),
                              exitPage: widget,
                              enterPage: Credit(),
                              transition: CubeTransition(),
                            )
                        );
                      },
                    );
          }
          }
            }
                  ),
                  )
                          ]
                      )
                  )
                ],
                )
            )
    )
        )
    ]
    );
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source