I'm trying to get a album list from a server, the server uses xml and I'm trying to convert it to json but for some reason it doesn't work/comes back as null.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:xml2json/xml2json.dart';
import 'package:get/get.dart';
import 'package:xml/xml.dart' as xml;
class RecentlyAddedHome extends StatefulWidget {
  @override
  _RecentlyAddedHomState createState() => _RecentlyAddedHomState();
}
  Future<List<AlbumsResponse>> fetchRecentlyAddedAlbums() async{
  final aresponse = await http.get(recentAlbumsURL);
  xml2json.parse(aresponse.body);
  var jsondata = xml2json.toGData();
  var data = json.decode(jsondata);
  print(data);
  return AlbumsResponse.fromJson(data).toList();
}
class _RecentlyAddedHomState extends State<RecentlyAddedHome> {
  final Future<List<AlbumsResponse>> albumsresponse = fetchRecentlyAddedAlbums();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: FutureBuilder(
          future: fetchRecentlyAddedAlbums(),
          builder: (context, data){
            if (data.hasData){
              List<AlbumsResponse> albumsresponse = data.data;
              return ListView.builder(
              itemCount: albumsresponse.length,
              itemBuilder: (context, index){
                return ListTile(
                  title: Text(albumsresponse[index].title,style: TextStyle(fontSize: 25.0),),
                );
              }, 
              );
            }
          },
        )
      )
    );
  }
}
this is my model for it
import 'package:xml/xml.dart' as xml;
import 'package:music_app_prototype/services/auth.dart';
import 'package:http/http.dart' as http;
 class AlbumsResponse {
  final String title;
  final int albumid;
  final String artist;
  final int coverart;
  AlbumsResponse({this.albumid, this.artist, this.coverart, this.title});
  factory AlbumsResponse.fromJson(Map<String, dynamic> json){
    return AlbumsResponse(
      title: json['_title'] as String,
      albumid: json['_albumid'] as int,
      artist: json['_artist'] as String,
      coverart: json['_coverart'] as int,
    );
  }
  get albumtitle => this.title;
  Future<List<AlbumsResponse>> toList() {}
}
and this is what the server sends me when i make the request
<?xml version="1.0" encoding="UTF-8"?>
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.15.0">
    <albumList>
        <album id="695" parent="577" isDir="true" title="Whatever" album="Whatever" artist="Kaytranada" genre="Hip-Hop" coverArt="695" playCount="0" created="2020-04-18T02:01:55.546Z"/>
        <album id="850" parent="581" isDir="true" title="Cruel Intentions" album="Cruel Intentions" artist="Tory Lanez" genre="Hip-Hop" coverArt="850" playCount="1" created="2020-04-18T01:56:48.148Z"/>
        <album id="649" parent="574" isDir="true" title="So Far Gone" album="So Far Gone" artist="Drake" year="2009" genre="Hip-Hop/Rap" coverArt="649" playCount="0" created="2020-04-18T01:49:12.120Z"/>
        <album id="668" parent="575" isDir="true" title="Myst" album="Myst" artist="Herzeloyde" year="2020" genre="Electro" coverArt="668" playCount="1" created="2020-04-05T03:08:36.596Z"/>
        <album id="607" parent="572" isDir="true" title="Survival" album="Survival" artist="Dave East" year="2019" genre="Hip-Hop/Rap" coverArt="607" playCount="2" created="2020-03-01T02:29:48.072Z"/>
        <album id="792" parent="580" isDir="true" title="Yikes" album="Yikes" artist="Nicki Minaj" year="2020" genre="Rap/Hip Hop" coverArt="792" playCount="0" created="2020-02-17T04:47:49.067Z"/>
        <album id="790" parent="580" isDir="true" title="Sucka Free" album="Sucka Free" artist="Nicki Minaj" year="2008" genre="Hip-Hop" coverArt="790" playCount="0" created="2020-01-02T01:34:11.738Z"/>
        <album id="786" parent="580" isDir="true" title="Playtimes Over" album="Playtimes Over" artist="Nicki Minaj" year="2007" genre="Hip-Hop" coverArt="786" playCount="0" created="2020-01-02T01:34:11.716Z"/>
        <album id="715" parent="578" isDir="true" title="No Ceilings 2" album="No Ceilings 2" artist="Lil Wayne" year="2009" genre="Hip-Hop" coverArt="715" playCount="0" created="2020-01-02T01:34:04.226Z"/>
        <album id="788" parent="580" isDir="true" title="Queen" album="Queen" artist="Nicki Minaj" year="2018" genre="Hip-Hop/Rap" coverArt="788" playCount="0" created="2020-01-02T00:25:00.671Z"/>
    </albumList>
</subsonic-response>
When i try to go to the Recently added page it says my build function returned null? I see that i get the data but it still doesn't show up. Can anyone help me, I'm not sure what I'm doing wrong, if i don't have to convert it from xml to json, how to do i work with it in xml form? Thanks!
