mirror of
https://github.com/ArizArmeidi/AnimSearch.git
synced 2026-03-13 08:51:46 +08:00
Fixed getAnimeById to work with API v4
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const api_url = 'https://api.jikan.moe/v4/anime';
|
||||
const top_url = 'https://api.jikan.moe/v4/anime?status=airing';
|
||||
const upcoming_url = 'https://api.jikan.moe/v4/anime?status=upcoming';
|
||||
const series_url = 'https://api.jikan.moe/v4/anime?status=airing&type=tv';
|
||||
|
||||
@@ -47,9 +47,9 @@ class AnimeModel {
|
||||
return AnimeModel(
|
||||
malId: json['mal_id'] ?? 0,
|
||||
url: json['url'] ?? '',
|
||||
imageUrl: json['image_url'] ?? '',
|
||||
imageUrl: json['images']['jpg']['image_url'] ?? '',
|
||||
title: json['title'] ?? '',
|
||||
trailerUrl: json['trailer_url'] ?? '',
|
||||
trailerUrl: json['trailer']['url'] ?? '',
|
||||
titleEnglish: json['title_english'] ?? 'TBA',
|
||||
synopsis: json['synopsis'] ?? '',
|
||||
status: json['status'] ?? '',
|
||||
|
||||
@@ -83,8 +83,7 @@ class DataProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> searchData(String query) async {
|
||||
final String url =
|
||||
'https://api.jikan.moe/v3/search/anime?q=$query&page=1&limit=12';
|
||||
final String url = api_url + 'q=$query&page=1&limit=12';
|
||||
try {
|
||||
isLoading = true;
|
||||
isError = false;
|
||||
@@ -128,13 +127,13 @@ class DataProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> getAnimeData(int malId) async {
|
||||
final String url = 'https://api.jikan.moe/v3/anime/$malId';
|
||||
final String url = 'https://api.jikan.moe/v4/anime/$malId';
|
||||
try {
|
||||
isLoading = true;
|
||||
isError = false;
|
||||
var dio = Dio();
|
||||
var response = await dio.get(url);
|
||||
animeData = AnimeModel.fromJson(response.data);
|
||||
animeData = AnimeModel.fromJson(response.data['data']);
|
||||
await getRecommendationData(animeData.genreId);
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
@@ -12,8 +12,13 @@ class WebViewContainer extends StatefulWidget {
|
||||
|
||||
class _WebViewContainerState extends State<WebViewContainer> {
|
||||
final _key = UniqueKey();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _controller = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..loadRequest(Uri.parse(widget.url));
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
iconTheme: IconThemeData(
|
||||
@@ -21,11 +26,7 @@ class _WebViewContainerState extends State<WebViewContainer> {
|
||||
),
|
||||
backgroundColor: Colors.orange,
|
||||
),
|
||||
body: WebView(
|
||||
key: _key,
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
initialUrl: widget.url,
|
||||
),
|
||||
body: WebViewWidget(key: _key, controller: _controller),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user