颤音:从行页上加载脚手架时的错误分开文件
我有一个包含底部应用程序栏的主文件,我使用它在脚手架的Body属性中返回其他4页来浏览其他4页,我也有一个身份验证文件,该文件还返回主页或登录页面,根据在Firebase Auth实例上。 Meaning it's one page among 4 inside a home page inside an authentification page, when I load it I get this error:
Restarted application in 1 057ms.
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
Scaffold.geometryOf() must only be accessed during the paint phase.
The ScaffoldGeometry is only available during the paint phase, because its value is computed during
the animation and layout phases prior to painting.
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49 throw_
packages/flutter/src/material/scaffold.dart 769:10 .
.
.
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/initialization.dart 128:45 <fn>
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: Assertion failed:
Another exception was thrown: Assertion failed:
Error: Assertion failed:
!_debugDuringDeviceUpdate
is not true
.
.
.
at loggedHandler (http://localhost:51235/dart_sdk.js:172062:11)
I get no errors when I load the Sign-In/Sign-Up pages instead of the home page, sometimes I get this error and sometimes I don't even when I do the exact same navigations, here's the code of the home file:
import 'package:application/Pages/barcode.dart';
import 'package:application/Pages/clients.dart';
import 'package:application/Pages/history.dart';
import 'package:application/Pages/menu.dart';
import 'package:application/Pages/more.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
int _currentIndex = 4;
var bnbActions = [
const Menu(),
const History(),
const Barcode(),
const Clients(),
const More()
];
@override
Widget build(BuildContext context) {
return Scaffold(
extendBody: true,
body: bnbActions[_currentIndex],
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
heroTag: "scan",
backgroundColor: Colors.tealAccent[400],
onPressed: () {
_currentIndex != 2
? setState(() {
_currentIndex = 2;
})
: null;
},
child: Icon(
FontAwesomeIcons.expand,
),
),
bottomNavigationBar: BottomAppBar(
shape: const CircularNotchedRectangle(),
color: Colors.grey[50],
child: IconTheme(
data: IconThemeData(color: Colors.tealAccent[400]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () {
_currentIndex != 0
? setState(() {
_currentIndex = 0;
})
: null;
},
child: Icon(
_currentIndex != 0
? Icons.shopping_basket_outlined
: Icons.shopping_basket,
color: Colors.tealAccent[400]),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 0
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
ElevatedButton(
onPressed: () {
_currentIndex != 1
? setState(() {
_currentIndex = 1;
})
: null;
},
child: Icon(
_currentIndex != 1 ? Icons.receipt_outlined : Icons.receipt,
color: Colors.tealAccent[400],
),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 1
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
SizedBox(width: 24.0),
ElevatedButton(
onPressed: () {
_currentIndex != 3
? setState(() {
_currentIndex = 3;
})
: null;
},
child: Icon(
_currentIndex != 3
? Icons.perm_contact_cal_outlined
: Icons.perm_contact_cal,
color: Colors.tealAccent[400],
),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 3
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
ElevatedButton(
onPressed: () {
_currentIndex != 4
? setState(() {
_currentIndex = 4;
})
: null;
},
child: Icon(
_currentIndex != 4
? Icons.settings_outlined
: Icons.settings,
color: Colors.tealAccent[400],
),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 4
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
],
),
),
),
),
);
}
}
Update: The error only shows when I have the mouse cursor inside the app while it's loading.
I have a home file that contains a bottom app bar, I use it to navigate through 4 other pages by returning them in the Scaffold's body property, I also have an authentification file which also returns either the home page or the sign-in page depending on a Firebase Auth instance.
Meaning it's one page among 4 inside a home page inside an authentification page, when I load it I get this error:
Restarted application in 1 057ms.
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
Scaffold.geometryOf() must only be accessed during the paint phase.
The ScaffoldGeometry is only available during the paint phase, because its value is computed during
the animation and layout phases prior to painting.
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49 throw_
packages/flutter/src/material/scaffold.dart 769:10 .
.
.
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/initialization.dart 128:45 <fn>
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: Assertion failed:
Another exception was thrown: Assertion failed:
Error: Assertion failed:
!_debugDuringDeviceUpdate
is not true
.
.
.
at loggedHandler (http://localhost:51235/dart_sdk.js:172062:11)
I get no errors when I load the Sign-In/Sign-Up pages instead of the home page, sometimes I get this error and sometimes I don't even when I do the exact same navigations, here's the code of the home file:
import 'package:application/Pages/barcode.dart';
import 'package:application/Pages/clients.dart';
import 'package:application/Pages/history.dart';
import 'package:application/Pages/menu.dart';
import 'package:application/Pages/more.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
int _currentIndex = 4;
var bnbActions = [
const Menu(),
const History(),
const Barcode(),
const Clients(),
const More()
];
@override
Widget build(BuildContext context) {
return Scaffold(
extendBody: true,
body: bnbActions[_currentIndex],
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
heroTag: "scan",
backgroundColor: Colors.tealAccent[400],
onPressed: () {
_currentIndex != 2
? setState(() {
_currentIndex = 2;
})
: null;
},
child: Icon(
FontAwesomeIcons.expand,
),
),
bottomNavigationBar: BottomAppBar(
shape: const CircularNotchedRectangle(),
color: Colors.grey[50],
child: IconTheme(
data: IconThemeData(color: Colors.tealAccent[400]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () {
_currentIndex != 0
? setState(() {
_currentIndex = 0;
})
: null;
},
child: Icon(
_currentIndex != 0
? Icons.shopping_basket_outlined
: Icons.shopping_basket,
color: Colors.tealAccent[400]),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 0
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
ElevatedButton(
onPressed: () {
_currentIndex != 1
? setState(() {
_currentIndex = 1;
})
: null;
},
child: Icon(
_currentIndex != 1 ? Icons.receipt_outlined : Icons.receipt,
color: Colors.tealAccent[400],
),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 1
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
SizedBox(width: 24.0),
ElevatedButton(
onPressed: () {
_currentIndex != 3
? setState(() {
_currentIndex = 3;
})
: null;
},
child: Icon(
_currentIndex != 3
? Icons.perm_contact_cal_outlined
: Icons.perm_contact_cal,
color: Colors.tealAccent[400],
),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 3
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
ElevatedButton(
onPressed: () {
_currentIndex != 4
? setState(() {
_currentIndex = 4;
})
: null;
},
child: Icon(
_currentIndex != 4
? Icons.settings_outlined
: Icons.settings,
color: Colors.tealAccent[400],
),
style: ButtonStyle(
elevation: MaterialStateProperty.resolveWith((states) {
return 0;
}),
backgroundColor:
MaterialStateProperty.resolveWith((states) {
return _currentIndex == 4
? Color.fromARGB(20, 29, 233, 182)
: Colors.transparent;
}),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
],
),
),
),
),
);
}
}
Update: The error only shows when I have the mouse cursor inside the app while it's loading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为最好使用pageView()。
I think it would be better to use PageView().