当前位置:网站首页>[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: , ), ); }}边栏推荐
- 看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
- Uniapp component -uni notice bar notice bar
- 【数据挖掘】任务3:决策树分类
- Swiftui component Encyclopedia: using scenekit and swiftui to build interactive 3D pie charts (tutorial with source code)
- [self management] time, energy and habit management
- mysql
- [interview question] 1369 when can't I use arrow function?
- Kivy tutorial - example of using Matplotlib in Kivy app
- STM32 - introduction of external interrupts exti and NVIC
- wirehark数据分析与取证A.pacapng
猜你喜欢

给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】

Give you an array numbers that may have duplicate element values. It was originally an array arranged in ascending order, and it was rotated once according to the above situation. Please return the sm
![[data mining] task 2: mimic-iii data processing of medical database](/img/ad/4e7b253d60b29351e3ef252ee5230f.png)
[data mining] task 2: mimic-iii data processing of medical database

Expérience de recherche d'emploi d'un programmeur difficile
![[C language] detailed explanation of pointer and array written test questions](/img/24/c2c372b5c435cbd6eb83ac34b68034.png)
[C language] detailed explanation of pointer and array written test questions

Vant 实现简单的登录注册模块以及个人用户中心

海量数据冷热分离方案与实践

Work experience of a hard pressed programmer

C#应用程序界面开发基础——窗体控制(3)——文件类控件
![[fh-gfsk] fh-gfsk signal analysis and blind demodulation research](/img/8a/8ca80f51a03341c982d52980c54b01.png)
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research
随机推荐
Top ten regular spot trading platforms 2022
Vant 实现简单的登录注册模块以及个人用户中心
网络安全-木马
[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
Take you ten days to easily complete the go micro service series (I)
海量数据冷热分离方案与实践
英语常用词汇
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
电信客户流失预测挑战赛
What operations need attention in the spot gold investment market?
Expérience de recherche d'emploi d'un programmeur difficile
[data mining] task 1: distance calculation
High-Resolution Network (篇一):原理刨析
Swiftui component Encyclopedia: using scenekit and swiftui to build interactive 3D pie charts (tutorial with source code)
[androd] module dependency replacement of gradle's usage skills
[Cao gongzatan] after working in goose factory for a year in 2021, some of my insights
Meituan dynamic thread pool practice ideas, open source
C application interface development foundation - form control (2) - MDI form
[technology development-23]: application of DSP in future converged networks
Give you an array numbers that may have duplicate element values. It was originally an array arranged in ascending order, and it was rotated once according to the above situation. Please return the sm