[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(),
));
}

これでうまくいった!

34歳から始めるオンライン学習

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

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

関連記事

[Flutter]Providerを使ってみる

[Dialogflow]JSでダイアログフローを動かしてみる

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

[Shopify]モーダル作りたいけどJS動作しない

[Flutter]実機で検証する方法(iOS編)

[Dialogflow]ダイアログフローでハローワールド