movie and tvshow list
This commit is contained in:
+30
-47
@@ -10,6 +10,16 @@ class Movie {
|
||||
DateTime releaseDate;
|
||||
int state;
|
||||
String resolution;
|
||||
String backdropPath;
|
||||
String languages;
|
||||
String productionCountries;
|
||||
String productionCompanies;
|
||||
double voteAverage;
|
||||
int voteCount;
|
||||
String cast;
|
||||
String crew;
|
||||
String genre;
|
||||
String localPath;
|
||||
|
||||
Movie({
|
||||
required this.movieID,
|
||||
@@ -18,6 +28,16 @@ class Movie {
|
||||
required this.releaseDate,
|
||||
required this.state,
|
||||
required this.resolution,
|
||||
required this.backdropPath,
|
||||
required this.languages,
|
||||
required this.productionCountries,
|
||||
required this.productionCompanies,
|
||||
required this.voteAverage,
|
||||
required this.voteCount,
|
||||
required this.cast,
|
||||
required this.crew,
|
||||
required this.genre,
|
||||
required this.localPath,
|
||||
});
|
||||
|
||||
factory Movie.fromJson(Map<String, dynamic> json) {
|
||||
@@ -28,53 +48,16 @@ class Movie {
|
||||
releaseDate: DateTime.parse(json['releaseDate']),
|
||||
state: int.parse(json['state']),
|
||||
resolution: json['resolution'] as String,
|
||||
backdropPath: json['backdropPath'] as String,
|
||||
languages: json['languages'],
|
||||
productionCountries: json['productionCountries'],
|
||||
productionCompanies: json['productionCompanies'],
|
||||
voteAverage: double.parse(json['voteAverage']),
|
||||
voteCount: int.parse(json['voteCount']),
|
||||
cast: json['cast'],
|
||||
crew: json['crew'],
|
||||
genre: json['genre'],
|
||||
localPath: json['localpath'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MovieDataSource extends DataGridSource {
|
||||
/// Creates the employee data source class with required details.
|
||||
MovieDataSource(this.movies) {
|
||||
buildDataGridRow();
|
||||
}
|
||||
|
||||
void buildDataGridRow() {
|
||||
_movieDataGridRows = movies
|
||||
.map<DataGridRow>((e) => DataGridRow(cells: [
|
||||
DataGridCell<int>(columnName: 'movieID', value: e.movieID),
|
||||
DataGridCell<int>(columnName: 'state', value: e.state),
|
||||
DataGridCell<String>(
|
||||
columnName: 'movieTitle', value: e.movieTitle),
|
||||
DataGridCell<String>(
|
||||
columnName: 'releaseDate',
|
||||
value: DateFormat('yyyy-MM-dd').format(e.releaseDate)),
|
||||
DataGridCell<String>(
|
||||
columnName: 'resolution', value: e.resolution),
|
||||
DataGridCell<String>(columnName: 'overview', value: e.overview),
|
||||
]))
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<Movie> movies = [];
|
||||
|
||||
List<DataGridRow> _movieDataGridRows = [];
|
||||
|
||||
@override
|
||||
List<DataGridRow> get rows => _movieDataGridRows;
|
||||
|
||||
@override
|
||||
DataGridRowAdapter buildRow(DataGridRow row) {
|
||||
return DataGridRowAdapter(
|
||||
cells: row.getCells().map<Widget>((e) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(e.value.toString()),
|
||||
);
|
||||
}).toList());
|
||||
}
|
||||
|
||||
void updateDataGrid() {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user