Good afternoon, I am developing my application and I want to implement a blue tick visualization system using FireStore database,
here is a screenshot of the user’s document:
here is the whole code
class ProfileMainWidget extends StatefulWidget {
final UserEntity currentUser;
const ProfileMainWidget({Key? key, required this.currentUser}) : super(key: key);
@override
State<ProfileMainWidget> createState() => _ProfileMainWidgetState();
}
class _ProfileMainWidgetState extends State<ProfileMainWidget> {
bool isVerify = true;
@override
void initState() {
BlocProvider.of<PostCubit>(context).getPosts(post: PostEntity());
super.initState();
}
@override
Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (lightColorScheme, darkColorScheme,) {
return Scaffold(
appBar: AppBar(
title:
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'${widget.currentUser.username}', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 25, ),
),
Visibility(
visible: (isVerify) ? false : true,
child: Icon(Icons.verified_sharp, color: Colors.blue,size: 17,),
),
]
),
I need to hide or show a widget icon from a value in a firestore document, if anyone can help I would really appreciate it, hope my question helps someone.
I’ve looked all over the internet and haven’t found anything, I’ve tried to figure it out myself, but nothing helps.
2
Answers
The expression tests the value of the boolean variable isVerify. If isVerify is true, then the expression evaluates to false. Otherwise, it evaluates to true.
As mentioned above, you are trying to hide the blue mark when its true or the user is verified and show it when the user is not verified or false.
if you are trying to show the blue mark when the user is verified, you need to change the ‘false and true’ positions like:
visible: (isVerify) ? true: false,
this is all i knew about the problem and i hope this was your answer
best wishes…
As you are getting UserEntity passed from previous page. Then you should be using the "widget.currentUser.verification" for Visibility.
Not the isVerify bool because it’s already set to true and you’re using it wrong in visibility parameter.