当前位置:网站首页>[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: , ), ); }}边栏推荐
- CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
- 测试右移:线上质量监控 ELK 实战
- Do not log in or log in to solve the problem that the Oracle database account is locked.
- 网络安全-信息收集
- [FPGA tutorial case 5] ROM design and Implementation Based on vivado core
- Wireshark data analysis and forensics a.pacapng
- 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
- wirehark数据分析与取证A.pacapng
- LDC Build Shared Library
- Take you ten days to easily complete the go micro service series (I)
猜你喜欢

简易分析fgui依赖关系工具

Force buckle 204 Count prime

Steps to obtain SSL certificate private key private key file

Wireshark data analysis and forensics a.pacapng

一位苦逼程序员的找工作经历

【數據挖掘】任務6:DBSCAN聚類

LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7

How is the mask effect achieved in the LPL ban/pick selection stage?

Virtual list

Androd gradle's substitution of its use module dependency
随机推荐
【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
STM32 - switch of relay control lamp
Three core issues of concurrent programming - "deep understanding of high concurrent programming"
测试右移:线上质量监控 ELK 实战
[keil5 debugging] debug is stuck in reset_ Handler solution
數學知識:臺階-Nim遊戲—博弈論
How is the mask effect achieved in the LPL ban/pick selection stage?
网络安全-漏洞与木马
[data mining] task 2: mimic-iii data processing of medical database
Swiftui component Encyclopedia: using scenekit and swiftui to build interactive 3D pie charts (tutorial with source code)
Cloud native topic sorting (to be updated)
What operations need attention in the spot gold investment market?
数学知识:台阶-Nim游戏—博弈论
Kivy tutorial - example of using Matplotlib in Kivy app
MySQL - database query - basic query
LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
Main features of transport layer TCP and TCP connection
Using tensorboard to visualize the model, data and training process
Vant implements a simple login registration module and a personal user center
什么是调。调的故事