#getString(""));
を呼んだりすると以下のエラーが。
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: type 'int' is not a subtype of type 'String?' in type cast #0 SharedPreferences.getString (package:shared_preferences/shared_preferences.dart:78:58) #1 _TopPageBodyState.initState.<anonymous closure> (package:xxxxxxx/main.dart:122:18) #2 _rootRunUnary (dart:async/zone.dart:1436:47) #3 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
で、勘違いしていたのだが、SharedPreferences のキーは #setInt()
でも#setString()
でも同じものを使い回せないみたい。
しかも同じキーで set 系のメソッドを呼ぶと値が上書きされる。
そして、違う型の get 系メソッドを呼ぶと上記のエラーが発生する。。