我想寻求一些帮助。我有一个与firebase连接的登录表单。我还有3个显示当前用户电子邮件的页面。但是,我决定实现一个底部导航菜单栏,我卡住了。正如你从图片中看到的,我不能通过底部导航栏中的当前用户电子邮件。目前,它是硬编码的。有人能给予我任何建议吗?
//底部导航菜单
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:test_honours/db/auth_controller.dart';
import 'package:test_honours/screens/profile_page.dart';
import 'package:test_honours/screens/welcome_page.dart';
import 'package:test_honours/screens/bmi_input_page.dart';
import 'package:custom_navigation_bar/custom_navigation_bar.dart';
import 'package:test_honours/screens/welcome_page.dart';
import 'package:test_honours/screens/bmi_input_page.dart';
import 'package:test_honours/screens/profile_page.dart';
class MyNavigationBar extends StatefulWidget {
String? email;
MyNavigationBar({Key? key, required this.email}) : super(key: key);
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
int _selectedIndex = 0;
final currentUser = FirebaseAuth.instance;
final List<Widget> _widgetOptions = <Widget>[
WelcomePage(email: ""),
BMICalculator(),
BMICalculator(),
ProfilePage(email: "email")
];
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: _widgetOptions[_selectedIndex],
bottomNavigationBar: CustomNavigationBar(
isFloating: true,
elevation: 2,
iconSize: 30,
selectedColor: Colors.blueAccent,
items: [
CustomNavigationBarItem(
icon: Icon(Icons.home_outlined)), //welcome page
CustomNavigationBarItem(
icon: Icon(Icons.location_on_outlined)), //gps location page
CustomNavigationBarItem(
icon: Icon(Icons
.medical_services_outlined)), //bmi calculator or future appointments
CustomNavigationBarItem(icon: Icon(Icons.settings))
],
onTap: (i) {
setState(() {
_selectedIndex = i;
});
},
currentIndex: _selectedIndex,
),
));
}
}
//欢迎页面:
class WelcomePage extends StatelessWidget {
String email;
WelcomePage({Key? key, required this.email}) : super(key: key);
.............
2条答案
按热度按时间jexiocij1#
您可以收到电子邮件,如
nhhxz33t2#
你可以这样做:
更智能: