furugenict8 / my_youtube_indexer

youtubeにindexをつけて、保存できるアプリ
0 stars 0 forks source link

playerのシークバーやListTileタップで再生していると、flutter: type 'Null' is not a subtype of type 'num'が表示される #107

Open furugenict8 opened 2 years ago

furugenict8 commented 2 years ago

概要

youtube_player_flutterのplayerをseek バー操作してたり、 ListTIleをonTapしていると出てくる。 (出てこないこともある。) seekしたり、該当の箇所へのスキップ操作はできている。

To Reproduce Steps to reproduce the behavior:

  1. Go to 山浦さんの動画、ホリエモンの動画 (Kboyの動画はでない。長い(1h、30min over)から?)
  2. ListTileをタップもしくはseekバーで動かしていると出てくる(毎回ではない)
  3. See error

Expected behavior 問題なく動く

Screenshots If applicable, add screenshots to help explain your problem. スクリーンショット 2022-03-18 2 27 05

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context 毎回出るのではなく、出る時と出ない時がある。 androidとか、別の機種で出るかは不明。

関連タスク

furugenict8 commented 2 years ago

やったこと

ググる flutter - Type Null is not a subtype of type int error when tried fetch data from an API - Stack Overflow

Welcome to SO, You are running with Null Safety Enbaled in your project. You have declared your all fields required and non-null in your Data Model Class. あなたのプロジェクトでは、Null Safety Enbaledで実行されています。データモデルクラスで、すべてのフィールドを必須かつ非NULLと宣言しています。

Your API response is having a field absent or having a null value, that's why you are facing this issue. APIレスポンスにフィールドがない、またはNULL値があるため、この問題に直面しています。

Solution: Replacing int with int? (making fields optional will resolve issue).Read 解決方法intをintに置き換える?(に置き換える(フィールドをオプションにすると解決する).Read

このサンプルみると、 int idで定義しているが、読んできているjsonのidのところがnullだからかなーと、 だからint? id みたいに定義しないとダメってことらしい。

自分に置き換えると flutter: type 'Null' is not a subtype of type 'num' のnumが何かってことだが、 seekTo()ででているのはcurrentPosition(Duration型)が近いのかなと思う。 ただ、seekバーで動かしている時も出ると考えると、このcurrentPositionではなく、youtubePlayerの中のどこかで起きていることなのかもしれない。自分のコードではなく。

furugenict8 commented 2 years ago

後回しにしようかな? 動いているので後回しにする。