teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

5

誤字の修正

2021/09/22 14:24

投稿

nk1
nk1

スコア42

title CHANGED
File without changes
body CHANGED
@@ -130,8 +130,7 @@
130
130
  はうまくいきませんでした。
131
131
  そこで、取得したurl
132
132
  http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/json
133
- のページを眺めたところ、"entry"が、"results"に当たりそうなので、その部分を変更し、rankingDataに"entry"の値を代入することができました。しかし、その後がうまくいきません。もはや、この部分だけの問題ではなさそうなので以下にgithubを載せます。
133
+ のページを眺めたところ、"entry"が、"results"に当たりそうなので、その部分を変更し、rankingDataに"entry"の値を代入することができました。しかし、その後がうまくいきません。
134
- https://github.com/phi7/app_ranking/blob/main/lib/ranking_page.dart
135
134
 
136
135
  エラー内容
137
136
  ```console

4

URLを新しいものに変更し、###試したことに「追記②」をつけました。

2021/09/22 14:24

投稿

nk1
nk1

スコア42

title CHANGED
File without changes
body CHANGED
@@ -121,13 +121,67 @@
121
121
  と書いており、これが原因なのでしょうか?
122
122
  なにかご存じの方がいたら教えていただけると嬉しいです。
123
123
 
124
+ 追記②
125
+ おっしゃるとおり、urlの最後をxmlからjsonに変えたところ、
124
- ### 補足情報(FW/ツールのバージョンなど)
126
+ feedData = data["feed"];
127
+ print(feedData);
128
+ までデータをとることができました。しかし、もとのコードとデータの取得先が違うのか"results"という項目がないためか、
129
+ rankingData = feedData["results"];
125
- dependencies:
130
+ はうまくいきませんでした。
126
- flutter:
127
- sdk: flutter
131
+ そこで、取得したurl
128
- http: ^0.13.3
129
- flutter_svg: ^0.22.0
132
+ http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/json
133
+ のページを眺めたところ、"entry"が、"results"に当たりそうなので、その部分を変更し、rankingDataに"entry"の値を代入することができました。しかし、その後がうまくいきません。もはや、この部分だけの問題ではなさそうなので以下にgithubを載せます。
130
- country_icons: ^2.0.2
134
+ https://github.com/phi7/app_ranking/blob/main/lib/ranking_page.dart
131
- url_launcher: ^6.0.9
132
135
 
133
- cupertino_icons: ^1.0.2
136
+ エラー内容
137
+ ```console
138
+ flutter: us
139
+ flutter: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/json
140
+
141
+ ======== Exception caught by widgets library =======================================================
142
+ The following _TypeError was thrown building RankingPage(dirty, state: _RankingPageState#5f572):
143
+ type 'Null' is not a subtype of type 'String'
144
+
145
+ The relevant error-causing widget was:
146
+ RankingPage file:///Users/nt/StudioProjects/app_ranking/lib/main.dart:18:13
147
+ When the exception was thrown, this was the stack:
148
+ #0 _RankingPageState.build (package:app_ranking/ranking_page.dart:177:44)
149
+ #1 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691:27)
150
+ #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574:15)
151
+ #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4746:11)
152
+ #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4267:5)
153
+ ...
154
+ ====================================================================================================
155
+ flutter: Instance of 'Response'
156
+ flutter: {"feed":{"author":{"name":{"label":"iTunes Store"}, "uri":{"label":"http://www.apple.com/itunes/"}}, "entry":[
157
+ {"im:name":{"label":"TikTok"}, "im:image":[
158
+ {"label":"https://is2-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/53x53bb.png", "attributes":{"height":"53"}},
159
+ {"label":"https://is1-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/75x75bb.png", "attributes":{"height":"75"}},
160
+ {"label":"https://is3-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.png", "attributes":{"height":"100"}}], "summary":{"label":"TikTok is THE destination for mobile videos. On TikTok, short-form video<…>
161
+ flutter: 200
162
+ flutter: {feed: {author: {name: {label: iTunes Store}, uri: {label: http://www.apple.com/itunes/}}, entry: [{im:name: {label: TikTok}, im:image: [{label: https://is2-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/53x53bb.png, attributes: {height: 53}}, {label: https://is1-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/75x75bb.png, attributes: {height: 75}}, {label: https://is3-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.png, attributes: {height: 100}}], summary: {label: TikTok is THE destination for mobile videos. On TikTok, short-form videos are exciting, spontaneous, and genuine. Wh<…>
163
+ flutter: {author: {name: {label: iTunes Store}, uri: {label: http://www.apple.com/itunes/}}, entry: [{im:name: {label: TikTok}, im:image: [{label: https://is2-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/53x53bb.png, attributes: {height: 53}}, {label: https://is1-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/75x75bb.png, attributes: {height: 75}}, {label: https://is3-ssl.mzstatic.com/image/thumb/Purple125/v4/d5/f8/3e/d5f83ec1-8903-ba99-2605-ddc4ce0ecd51/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.png, attributes: {height: 100}}], summary: {label: TikTok is THE destination for mobile videos. On TikTok, short-form videos are exciting, spontaneous, and genuine. Whether y<…>
164
+ flutter: null
165
+
166
+ ======== Exception caught by widgets library =======================================================
167
+ The following _TypeError was thrown building RankingPage(dirty, state: _RankingPageState#5f572):
168
+ type 'Null' is not a subtype of type 'String'
169
+
170
+ The relevant error-causing widget was:
171
+ RankingPage file:///Users/nt/StudioProjects/app_ranking/lib/main.dart:18:13
172
+ When the exception was thrown, this was the stack:
173
+ #0 _RankingPageState.build (package:app_ranking/ranking_page.dart:177:44)
174
+ #1 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691:27)
175
+ #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574:15)
176
+ #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4746:11)
177
+ #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4267:5)
178
+ ...
179
+ ====================================================================================================
180
+ Lost connection to device.
181
+ ```
182
+
183
+ また、urlにcc="国名"を入れることで、各国のランキングがとれるようになるかと思いきや、どれも変わりませんでした。
184
+ http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/limit=200/json
185
+ http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/json
186
+ http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=jp/limit=200/json
187
+ データの取得方法と、各国のランキングのurlの発見方法についてご存知の方が教えていただけると嬉しいです。

3

teminal→console

2021/09/02 08:36

投稿

nk1
nk1

スコア42

title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  dataにしっかり値が代入されるようにしたいです。
13
13
 
14
- ### print関数でterminalに出力されたもの
14
+ ### print関数でconsoleに出力されたもの
15
15
 
16
16
  ```
17
17
  flutter: us
@@ -96,7 +96,7 @@
96
96
  print(response);
97
97
  がうまくいかないようで
98
98
 
99
- ```teminal
99
+ ```console
100
100
  flutter: us
101
101
  flutter: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/xml
102
102
  ======== Exception caught by widgets library =======================================================

2

teminalの書式の改善

2021/09/02 03:45

投稿

nk1
nk1

スコア42

title CHANGED
File without changes
body CHANGED
@@ -96,7 +96,7 @@
96
96
  print(response);
97
97
  がうまくいかないようで
98
98
 
99
- //termial
99
+ ```teminal
100
100
  flutter: us
101
101
  flutter: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/xml
102
102
  ======== Exception caught by widgets library =======================================================
@@ -114,6 +114,7 @@
114
114
  ...
115
115
  ====================================================================================================
116
116
 
117
+ ```
117
118
  とエラーがでるようになりました、、、
118
119
  取得したurlのページを開くと頭に
119
120
  This XML file does not appear to have any style information associated with it. The document tree is shown below.

1

URLを新しいものに変更し、###試したことに「追記」をつけました。

2021/09/02 03:31

投稿

nk1
nk1

スコア42

title CHANGED
File without changes
body CHANGED
@@ -78,6 +78,48 @@
78
78
  グーグルで 「response body null flutter」と検索して、下記のサイトに辿り着きましたが、そこでも解決されていないようです。
79
79
  https://stackoverflow.com/questions/64942048/flutter-response-body-is-empty
80
80
 
81
+ 追記
82
+ おっしゃるとおりでURLが変わっていたようなので、新しいURLで試してみました。
83
+ (初期値は currentCode = 'us';
84
+ currentType = 'topfree';
85
+ currentGenre = 'applications';に)
86
+
87
+ ```dart
88
+ String? currentTypeAndGenre = "$currentType$currentGenre";
89
+ var url = Uri.parse(
90
+ "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/$currentTypeAndGenre/cc=$currentCode/limit=200/xml");
91
+ print(url);
92
+ ```
93
+
94
+ print(url)まではteminalに出力されましたが、その後の
95
+ http.Response response = await http.get(url);
96
+ print(response);
97
+ がうまくいかないようで
98
+
99
+ //termial
100
+ flutter: us
101
+ flutter: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/cc=us/limit=200/xml
102
+ ======== Exception caught by widgets library =======================================================
103
+ The following _TypeError was thrown building RankingPage(dirty, state: _RankingPageState#aa6a8):
104
+ type 'Null' is not a subtype of type 'String'
105
+
106
+ The relevant error-causing widget was:
107
+ RankingPage file:///Users/nt/StudioProjects/app_ranking/lib/main.dart:18:13
108
+ When the exception was thrown, this was the stack:
109
+ #0 _RankingPageState.build (package:app_ranking/ranking_page.dart:177:44)
110
+ #1 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691:27)
111
+ #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574:15)
112
+ #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4746:11)
113
+ #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4267:5)
114
+ ...
115
+ ====================================================================================================
116
+
117
+ とエラーがでるようになりました、、、
118
+ 取得したurlのページを開くと頭に
119
+ This XML file does not appear to have any style information associated with it. The document tree is shown below.
120
+ と書いており、これが原因なのでしょうか?
121
+ なにかご存じの方がいたら教えていただけると嬉しいです。
122
+
81
123
  ### 補足情報(FW/ツールのバージョンなど)
82
124
  dependencies:
83
125
  flutter: