Closed damulhan closed 4 years ago
first upgrade flutter because of BottomAppBar() class => flutter upgrade and update the song class in plugin
class Song {
int id;
String artist;
String title;
String album;
int albumId;
int duration;
String uri;
String albumArt;
int count = 0;
int timestamp = 0;
int isFav = 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});
static final Columns=["id","artist", "title", "album", "albumId", "duration", "uri", "albumArt","isFav","timestamp"];
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"];
count = m["count"];
timestamp = m["timestamp"];
isFav = m["isFav"];
}
Map<String,dynamic> toMap(){
Map<String,dynamic> map = {
"id" : id,
"artist" : artist,
"title" : title,
"album" : album,
"albumId" : albumId,
"duration" : duration,
"uri" : uri,
"albumArt" : albumArt,
"count" : count,
"timestamp" : timestamp,
"isFav" : isFav
};
return map;
}
}
Hi @avirias , I have same issue with this but a little bit different showed error log. What should I do? My environment is: Flutter 1.0.0 • channel beta • https://github.com/flutter/flutter.git Framework • revision 5391447fae (5 days ago) • 2018-11-29 19:41:26 -0800 Engine • revision 7375a0f414 Tools • Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
The problem is every time I run flutter run
it always showed me error like this:
Compiler message:
lib/views/songs.dart:37:3: Error: The name of a constructor must match the name of the enclosing class.
Song.fromMap(Map m) {
^^^^
package:musicplayer/views/songs.dart:1: Context: The name of the enclosing class is 'Songs'.
lib/views/songs.dart:10:7: Error: The non-abstract class 'Songs' is missing implementations for these members:
'Song', 'createState'.
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class Songs extends StatefulWidget {
^^^^^
lib/views/songs.dart:32:3: Context: 'Song' is defined here.
Song(this.id, this.artist, this.title, this.album, this.albumId,
^^^^
file:///D:/flutter/packages/flutter/lib/src/widgets/framework.dart:1: Context: 'createState' is defined here.
lib/musichome.dart:27:16: Error: Method not found: 'Songs'.
return Songs(db);
^^^^^
lib/views/songs.dart:32:8: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
Song(this.id, this.artist, this.title, this.album, this.albumId,
^^^^
lib/views/songs.dart:32:17: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
Song(this.id, this.artist, this.title, this.album, this.albumId,
^^^^
lib/views/songs.dart:32:30: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
Song(this.id, this.artist, this.title, this.album, this.albumId,
^^^^
lib/views/songs.dart:32:42: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
Song(this.id, this.artist, this.title, this.album, this.albumId,
^^^^
lib/views/songs.dart:32:54: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
Song(this.id, this.artist, this.title, this.album, this.albumId,
^^^^
lib/views/songs.dart:33:7: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});
^^^^
lib/views/songs.dart:33:22: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});
^^^^
lib/views/songs.dart:33:32: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});
^^^^
lib/views/songs.dart:33:47: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});
^^^^
lib/views/songs.dart:33:60: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});
^^^^
lib/views/songs.dart:33:77: Error: Field formal parameters can only be used in a constructor.
Try removing 'this.'.
this.duration, this.uri, this.albumArt,{this.isFav=0,this.timestamp=0,this.count=0});
^^^^
lib/views/songs.dart:82:26: Error: The getter 'db' isn't defined for the class '#lib1::Songs'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'db'.
songs = await widget.db.fetchSongs();
^^
lib/views/songs.dart:131:48: Error: The getter 'db' isn't defined for the class '#lib1::Songs'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'db'.
widget.db, MyQueue.songs, i, 0)));
^^
Compiler failed on D:\Code\Flutter\Grey-master\lib/main.dart
Gradle task 'assembleDebug'... Done 9.7s
Gradle task assembleDebug failed with exit code 1
run flutter package upgrade
What can I do.
build environments are:
Flutter 0.5.1 • channel beta • https://github.com/flutter/flutter.git Framework • revision c7ea3ca377 (5 months ago) • 2018-05-29 21:07:33 +0200 Engine • revision 1ed25ca7b7 Tools • Dart 2.0.0-dev.58.0.flutter-f981f09760