[Flutter]へっぽこプログラミング!またエラー出た!

こんなエラーが出た!

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building ChartsDemo(state: _ChartsDemoState#02e45):
MediaQuery.of() called with a context that does not contain a MediaQuery.

No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of(). This can happen because you do not have a WidgetsApp or MaterialApp widget (those widgets introduce a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.
The context used was: Scaffold
dirty
state: ScaffoldState#c8471(lifecycle state: initialized, tickers: tracking 2 tickers)
The relevant error-causing widget was:
ChartsDemo file:///Users/37malin/code/flutter_chart/lib/main.dart:6:10
When the exception was thrown, this was the stack:
#0 MediaQuery.of (package:flutter/src/widgets/media_query.dart:813:5)
#1 ScaffoldState.didChangeDependencies (package:flutter/src/material/scaffold.dart:2172:50)
#2 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4661:12)
#3 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
#4 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)

════════════════════════════════════════════════════════════════════════════════════════════════════

これは「MaterialApp」の記載をしてなかっただけでした!

runAppを修正♪

void main() {
runApp(new MaterialApp(
home: new ChartsDemo(),
));
}

これでうまくいった!

私はこのスキルを身につけて不労所得を得ています

【Web開発初心者向け!】Web開発入門完全攻略 充実の18時間コース

未経験からプロのWebデザイナーになる! 400レッスン以上の完全マスターコース

HTML/CSSだけで自動収益化 1万円達成

関連記事

[flutter]実機でデバッグする方法

[Flutter]縦棒&横棒グラフ(チャート)

[Python]JupyterLabの使い方

[Python] Tweepyのme()でエラー出た時の解決法

[Python]Tweepyのget_user()でエラーが出た時の解決法

Progate(プロゲート)完了したら何したらいい?