Flutter 仅为电子邮件验证用户显示浮动按钮
这个浮动按钮显示所有用户,但我需要显示这个浮动按钮只为电子邮件验证用户。我已经完成了电子邮件验证的编码,并且工作正常。我尝试了这个浮动按钮的可见性,但它不工作。我不能纠正这个错误 我的代码:Flutter 仅为电子邮件验证用户显示浮动按钮,flutter,dart,firebase-realtime-database,floating-action-button,Flutter,Dart,Firebase Realtime Database,Floating Action Button,这个浮动按钮显示所有用户,但我需要显示这个浮动按钮只为电子邮件验证用户。我已经完成了电子邮件验证的编码,并且工作正常。我尝试了这个浮动按钮的可见性,但它不工作。我不能纠正这个错误 我的代码: class FeedPage extends StatelessWidget { const FeedPage({Key key, this.scaffoldKey, this.refreshIndicatorKey}) : super(key: key); final GlobalK
class FeedPage extends StatelessWidget {
const FeedPage({Key key, this.scaffoldKey, this.refreshIndicatorKey})
: super(key: key);
final GlobalKey<ScaffoldState> scaffoldKey;
final GlobalKey<RefreshIndicatorState> refreshIndicatorKey;
Widget _floatingActionButton(BuildContext context) {
return FloatingActionButton(
onPressed: () {
Navigator.of(context).pushNamed('/CreateFeedPage/post');
},
child: customIcon(
context,
icon: AppIcon.plus,
istwitterIcon: true,
iconColor: Theme.of(context).colorScheme.onPrimary,
size: 25,
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: _floatingActionButton(context),
backgroundColor: TwitterColor.mystic,
body: SafeArea(
child: Container(
height: fullHeight(context),
width: fullWidth(context),
child: RefreshIndicator(
key: refreshIndicatorKey,
onRefresh: () async {
/// refresh home page feed
var feedState = Provider.of<FeedState>(context, listen: false);
feedState.getDataFromDatabase();
return Future.value(true);
},
child: _FeedPageBody(
refreshIndicatorKey: refreshIndicatorKey,
scaffoldKey: scaffoldKey,
),
),
),
),
);
}
}
class FeedPage扩展了无状态小部件{
常量提要页({Key,this.scaffoldKey,this.refreshIndicatorKey})
:super(key:key);
最终GlobalKey脚手架钥匙;
最终的全球指标;
小部件_floatingActionButton(构建上下文){
返回浮动操作按钮(
已按下:(){
Navigator.of(context.pushNamed('/CreateFeedPage/post');
},
子项:自定义图标(
上下文
图标:AppIcon.plus,
伊斯特维特瑞克:是的,
iconColor:Theme.of(context).colorScheme.onPrimary,
尺码:25,
),
);
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
floatingActionButton:_floatingActionButton(上下文),
背景颜色:TwitterColor.mystic,
正文:安全区(
子:容器(
高度:全高(上下文),
宽度:全宽度(上下文),
子:刷新指示器(
关键字:刷新指示灯市场,
onRefresh:()异步{
///刷新主页提要
var feedState=Provider.of(上下文,侦听:false);
feedState.getDataFromDatabase();
返回未来值(true);
},
子项:_FeedPageBody(
refreshIndicatorKey:refreshIndicatorKey,
脚手架钥匙:脚手架钥匙,
),
),
),
),
);
}
}
试试这个:
floatingActionButton: Offstage(
offstage: _isVerified? false : true,
child: _floatingActionButton(context),
),
您可以尝试以下代码
floatingActionButton: _floating(context, FirebaseAuth.instance.currentUser.emailVerified),
小部件
Widget _floating(BuildContext context,bool isVerified){
if (isVerified)
return FloatingActionButton(
//TODO: customise according to your needs
onPressed:() async{
},
tooltip: 'Increment',
child: Icon(Icons.add),
);
else
return Container();
}
}
布尔错误..:/谢谢你,兄弟。。它起作用了。。