Skip to content
This repository has been archived by the owner on Nov 21, 2021. It is now read-only.

Can't run it #1

Closed
MDSADABWASIM opened this issue Jul 23, 2018 · 2 comments
Closed

Can't run it #1

MDSADABWASIM opened this issue Jul 23, 2018 · 2 comments

Comments

@MDSADABWASIM
Copy link

hello, I just cloned your repo and want to run it but it gives me exceptions seems like you changed a lot of things in flute_plugin song class, if you can share that code too, it'll be very helpful.

@avirias
Copy link
Owner

avirias commented Jul 24, 2018

### here's the updated class

class Song {
  int id;
  String artist;
  String title;
  String album;
  int albumId;
  int duration;
  String uri;
  String albumArt;
  int isFav=0;
  int timestamp=0;
  int count=0;

  Song(this.id, this.artist, this.title, this.album, this.albumId,
      this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});

  Song.fromMap(Map m) {
    id = m["id"];
    artist = m["artist"];
    title = m["title"];
    album = m["album"];
    albumId = m["albumId"];
    duration = m["duration"];
    uri = m["uri"];
    albumArt = m["albumArt"];
    isFav=m["isFav"];
    timestamp=m["timestamp"];
    count=m["count"];
  }
  static final Columns=["id","artist", "title", "album", "albumId", "duration", "uri", "albumArt","isFav","timestamp"];

  Map toMap(){
    Map<String,dynamic> map={
      "id":id,
      "artist":artist,
      "title":title,
      "album":album,
      "albumId":albumId,
      "duration":duration,
      "uri":uri,
      "albumArt":albumArt,
      "isFav":isFav,
      "timestamp":timestamp,
      "count":count,
    };
    return map;
  }
}

@MDSADABWASIM
Copy link
Author

Thanks for your response, @avirias
Now when I run it shows me this error
error2
caused by this method
getSharedData() async {
const platform = const MethodChannel('app.channel.shared.data');
Map sharedData = await platform.invokeMethod("getSharedData");
if (sharedData != null) {
if (sharedData["albumArt"] == "null") {
sharedData["albumArt"] = null;
}
Song song = new Song(
9999 /random/,
sharedData["artist"],
sharedData["title"],
sharedData["album"],
null,
int.parse(sharedData["duration"]),
sharedData["uri"],
sharedData["albumArt"]);
List list = new List();
list.add((song));
MyQueue.songs = list;
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new NowPlaying(null, list, 0, 0);
}));
}
}
in musicHome class
when I step out the error it runs again and then throws this error
error3
caused by this method

Future fetchLastSong() async {
List results = await _db
.rawQuery("select * from songs order by timestamp desc limit 1");
Song song;
results.forEach((s) {
song = new Song.fromMap(s);
});
print("Last" + song.title);
return song;
}

in database class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants