【お知らせ】みんプロ式Flutter講座は2026年4月末をもって新規販売を終了いたしました。詳しくはこちら →
[Flutter]トップレベル(top-level)メンバ使用上の注意点(意図せざるしてアプリが落ちるトラップが起こる可能性あり)
このページには広告が含まれる場合があります。
これは、FlutterでStatefulWidgetを使う際の育ての親である「State」クラスのbuildメソッド内で、
以下のような感じでトップレベルメンバ(プロパティ・メソッド)を参照した場合に、
Androidアプリとしてビルドすると
Scudo OOM: The process has exhausted 256M for size class ….
また、iOSアプリとしてビルドすると
interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke
という謎のエラーが発生してアプリが落ちてしまうというトラップが発生する可能性があります。
その場合は、以下のような感じで、トップレベル(static)として設定しているメンバを「static」にしてやるとなぜか解消する可能性があります。
Steps to Reproduce Load a text file of at least 3 megabytes. Convert to String Execute textPainter.layout() Execute textPainter.computeLineMetrics() do something Expected results: A problem occurs ...
ただし、これは万能な解決策というわけではないようで、staticにしてもエラーが解消しない場合もあるようです。
I was a developing a flutter app when I suddenly came across an error that I simply can't solve. I have a few variables declared in between the two classes of a stateful widget, and when I use setS...
My App crashes randomly with this error:
[ServicesDaemonManager] interruptionHandler is called.
-[FontServicesDaemonManager connection]_block_invoke(didReceiveMemoryWarning fires before the error
(詳しくは、以下の動画で解説していますので、よろしければご覧ください)






