Buenas quiusiera hacer una consulta ya anteriormente he trabajado con jsons en flutter sin problemas pero este json me esta causando problemas para obtener los datos
el json en cuestion es el siguiente Datos del JSON
Para esto utilizo la herramienta de https://app.quicktype.io/ la cual me ayuda a generar el codigo mas rapido ahora mi problema esta en esta parte en el momento de acceder a los valores este es mi codigo
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
import 'dart:async' show Future;
import 'package:apxltracker/JsonParse/getPlayerData.dart';
import 'package:apxltracker/Services/translations.dart';
final String urlApi0 = "https://api102ty.re/bridge?12&platform=";
final String API = "&auth=xFAfEAkmF4bu";
Future userGlobalData(String userid, String platform) async {
var urlGlobalF = Uri.parse(urlApi0 + platform + "&player=" + userid + API);
final Response response = await http.get(urlGlobalF);
//final Response response = await http.get(urlGlobalF, headers: {'Authorization': API});
//final GetPlayerData = getPlayerDataFromJson(response.body);
final getPlayerData = getPlayerDataFromJson(response.body);
return getPlayerData;
}
class GlobalData extends StatefulWidget {
const GlobalData({Key key}) : super(key: key);
@override
_GlobalDataState createState() => _GlobalDataState();
}
class _GlobalDataState extends State<GlobalData> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: userGlobalData("yunier10", "X1"),
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
case ConnectionState.active:
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(),
Text(
Translations.of(context).text('loading'),
style: TextStyle(
fontFamily: "Teko", color: Colors.red, fontSize: 26.0),
)
],
));
case ConnectionState.done:
if (snapshot.hasError) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image(
image: AssetImage("assets/img/error.png"),
height: 100.0,
),
Text(Translations.of(context).text("wrong"),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22.0,
fontFamily: "Acme",
color: Colors.red)),
],
));
}
return GridView.builder(
padding: EdgeInsets.only(top: 0),
itemCount: 1,
shrinkWrap: true,
physics: ScrollPhysics(),
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1),
),
itemBuilder: (BuildContext context, int index) {
final Global getData = snapshot.data.global[index];
return GlobalDataView(
username: getData.name,
);
},
);
}
});
}
}
class GlobalDataView extends StatelessWidget {
final username;
const GlobalDataView({
Key key,
this.username
}) : super(key: key);
@override
Widget build(BuildContext context) {
final ViewcardGlobal = Card(
elevation: 3.0,
child: Hero(
tag:username,
child: Material(
child: InkWell(
child: GridTile(
child: Text(username),
),
),
),
),
) ;
return ViewcardGlobal;
}
}
en la parte del itemcount no se que colocar ya he puesto
snapshot.data.global.length
y nada y en esta parte
final Global getData = snapshot.data.global[index];
me envia mensaje de error
Class 'GetPlayerData' has no instance method '[]'. Receiver: Instance of 'GetPlayerData' Tried calling: