This Overlay widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase. The widget on which setState() or markNeedsBuild() was called was: Overlay-[LabeledGlobalKey<OverlayState>#9cc87] state: OverlayState#c130e(entries: [OverlayEntry#b04b5(opaque: true; maintainState: false), OverlayEntry#67dea(opaque: false; maintainState: true), OverlayEntry#fed19(opaque: false; maintainState: false), OverlayEntry#d834c(opaque: false; maintainState: true)]) The widget which was currently being built when the offending call was made was: StreamBuilder<QuerySnapshot<Object?>> dirty dependencies: [_LocalizationsScope-[GlobalKey#76036]] state: _StreamBuilderBaseState<QuerySnapshot<Object?>, AsyncSnapshot<QuerySnapshot<Object?>>>#15351 The relevant error-causing widget was: StreamBuilder<QuerySnapshot<Object?>> StreamBuilder:file:///C:/Users/Administrator/StudioProjects/selam/lib/screens/notes.dart:50:15
notes page:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:selam/constants.dart';
import 'package:selam/screens/noteEditor.dart';
import 'package:selam/screens/notesReader.dart';
import 'package:selam/widget/notesCard.dart';
class Notes extends StatefulWidget {
@override
State<Notes> createState() => _NotesState();
}
class _NotesState extends State<Notes> {
final _firestore = FirebaseFirestore.instance;
final _auth = FirebaseAuth.instance;
User? loggedInUser = FirebaseAuth.instance.currentUser;
void getCurrentUser() async {
try {
final user = _auth.currentUser;
if (user != null) {
loggedInUser = user;
}
} catch (e) {}
}
@override
void initState() {
super.initState();
getCurrentUser();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kColor2,
body: Padding(
padding: EdgeInsets.only(right: 10, left: 10, top: 15),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Text(
'Your Notes',
style: kheaderTextStyle,
)),
StreamBuilder<QuerySnapshot>(
stream: _firestore
.collection('/notes/users/savedNotes')
.snapshots(),
builder: (context, snapshots) {
if (snapshots.connectionState == ConnectionState.waiting) {
showDialog(
context: context,
builder: (context) {
return Center(
child: SpinKitCircle(
size: 125,
itemBuilder: (context, index) {
final colors = [
Color(0xFF091304),
Color(0xFF0b1806),
Color(0xFF0f2208),
Color(0xFF142b0a),
Color(0xFF16300b),
Color(0xFF2d4523),
Color(0xFF45593c),
Color(0xFF5c6e54),
Color(0xFF73836d),
Color(0xFF8b9885),
Color(0xFFa2ac9d),
Color(0xFFb9c1b6)
];
final color = colors[index % colors.length];
return DecoratedBox(
decoration: BoxDecoration(
color: color, shape: BoxShape.circle));
},
));
});
}
if (snapshots.hasData) {
return GridView(
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
children: snapshots.data!.docs
.map(
(note) => NoteCard(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => NotesReader(note)));
},
doc: note,
),
)
.toList(),
);
}
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'No notes',
style: ktextFieldTextStyle,
),
Text('Tap the Add button to create a note.')
],
),
);
},
),
],
),
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => NoteEditor()),
);
},
backgroundColor: kColor2,
foregroundColor: kColor1,
label: Text('Add Note'),
icon: Icon(Icons.edit_note),
),
);
}
}
the above page is called in homepage() in 3rd tab:
body: TabBarView(
controller: _controller,
children: [
Icon(Icons.home),
ChatScreen(),
Notes(),
Icon(Icons.videocam_outlined),
UserProfile(),
],
),
I just want to know where my error is. Also all buttons aren't working on the notes page.