当前位置:网站首页>[error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
[error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
2022-07-03 01:40:00 【Programmer community】
One 、 Error message
Flutter The application runs with the following errors :
Launching lib\main.dart on Pixel 2 in debug mode...Running Gradle task 'assembleDebug'...√ Built build\app\outputs\flutter-apk\app-debug.apk.Installing build\app\outputs\flutter-apk\app.apk...Uninstalling old version...Error: ADB exited with exit code 1Performing Streamed Installadb: failed to install D:\002_Project\002_Android_Learn\flutter_animation\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package kim.hsl.flutter_animation signatures do not match previously installed version; ignoring!]Installing build\app\outputs\flutter-apk\app.apk...Debug service listening on ws://127.0.0.1:59548/20KwYgDmkUc=/wsSyncing files to device Pixel 2...======== Exception caught by widgets library =======================================================The following assertion was thrown building HeroAnimation:No MediaQuery widget ancestor found.Scaffold widgets require a MediaQuery widget ancestor.The specific widget that could not find a MediaQuery ancestor was: Scaffold dirty state: ScaffoldState#6ef6f(lifecycle state: initialized, tickers: tracking 2 tickers)The ownership chain for the affected widget is: "Scaffold ← HeroAnimation ← [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.The relevant error-causing widget was: HeroAnimation file:///D:/002_Project/002_Android_Learn/flutter_animation/lib/main.dart:5:10When the exception was thrown, this was the stack: #0 debugCheckHasMediaQuery.<anonymous closure> (package:flutter/src/widgets/debug.dart:219:7)#1 debugCheckHasMediaQuery (package:flutter/src/widgets/debug.dart:234:4)#2 MediaQuery.of (package:flutter/src/widgets/media_query.dart:820:12)#3 ScaffoldState.didChangeDependencies (package:flutter/src/material/scaffold.dart:2820:50)#4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4725:11)...====================================================================================================
Error code :
void main() {
runApp(HeroAnimation());}class HeroAnimation extends StatelessWidget{
@override Widget build(BuildContext context) {
// Time expansion coefficient , Used to reduce the running speed of animation timeDilation = 10.0; return Scaffold( appBar: AppBar( title: Text("Hero The demo ( Jump to the front page )"), ), body: Center( child: HeroWidget( imageUrl: "https://img-blog.csdnimg.cn/20210329101628636.jpg", width: 300, ), ), ); }}
Two 、 Solution
The above problems occur , Because the root component in the interface , Not used MaterialApp Components , stay main.dart Medium main Function , The root component of the running component must be MaterialApp ;
stay Scaffold The outer layer of the component is wrapped with a layer MaterialApp , Problem solvable ;
class HeroAnimation extends StatelessWidget{
@override Widget build(BuildContext context) {
// Time expansion coefficient , Used to reduce the running speed of animation timeDilation = 10.0; return MaterialApp( home: Scaffold( appBar: AppBar( title: Text("Hero The demo ( Jump to the front page )"), ), body: , ), ); }}
边栏推荐
- Cloud native topic sorting (to be updated)
- Create your first Kivy program Hello word (tutorial includes source code)
- Androd gradle's substitution of its use module dependency
- Tp6 fast installation uses mongodb to add, delete, modify and check
- Why can't the start method be called repeatedly? But the run method can?
- [shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio
- C language course information management system
- Summary of interval knowledge
- [机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
- 网络安全-防火墙
猜你喜欢
mysql
QTableWidget懒加载剩内存,不卡!
C application interface development foundation - form control (1) - form form
Using tensorboard to visualize the model, data and training process
Virtual list
MySQL - database query - condition query
C#应用程序界面开发基础——窗体控制(3)——文件类控件
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
Scheme and practice of cold and hot separation of massive data
Installation and use of serial port packet capturing / cutting tool
随机推荐
【数据挖掘】任务6:DBSCAN聚类
[data mining] task 4:20newsgroups clustering
网络安全-扫描
Why can't the start method be called repeatedly? But the run method can?
Qtablewidget lazy load remaining memory, no card!
Work experience of a hard pressed programmer
Related concepts of GDB in embedded system
Mathematical knowledge: divisible number inclusion exclusion principle
Learn the five skills you need to master in cloud computing application development
【数据挖掘】任务2:医学数据库MIMIC-III数据处理
word插入公式/endnote
英语常用词汇
什么是调。调的故事
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge
数学知识:台阶-Nim游戏—博弈论
STM32 - Application of external interrupt induction lamp
Vim 9.0正式发布!新版脚本执行速度最高提升100倍
MySQL - database query - condition query
网络安全-中间人攻击
Openresty cache