예외가 발생했습니다.
FlutterError (No MediaQuery widget ancestor found.
MyApp widgets require a MediaQuery widget ancestor.
The specific widget that could not find a MediaQuery ancestor was:
MyApp
The ownership chain for the affected widget is: "MyApp ← [root]"
No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of(). This can happen because you have not added a WidgetsApp, CupertinoApp, or MaterialApp widget (those widgets introduce a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.)
미디어 쿼리 사용 후 계속 이런 에러가 발생했다...
조상중에 MaterialApp 이 있어야 한다는 뜻을 제대로 이해못했나보다 ...
해당 내용을 받아오기 위해
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
라고 작성되어있던 코드를
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(
로 수정하였다.
context 값을 제대로 못받아와서 발생한 에러였구나 ...
'개인 공부' 카테고리의 다른 글
[플러터] 기본 디자인 UI를 만들며 (0) | 2023.05.08 |
---|---|
[플루터] MaterialApp / Scaffold 클래스 이용해보기 (0) | 2023.04.20 |
[프로그래머스] 수박수박수? (1) | 2023.04.20 |
[프로그래머스] 소수찾기 (0) | 2023.04.05 |
[프로그래머스] 서울에서 김서방 찾기 (0) | 2023.03.30 |