У меня есть BottomNavigationbar, и я хочу проанализировать данные через параметры!Я получаю сообщение об ошибке: в инициализаторах могут быть доступны только статические члены.
class _LoggedInStudentState extends State<LoggedInStudent> {
final String bearer;
final String username;
_LoggedInStudentState(this.bearer, this.username);
int _selectedPage = 0;
List<Widget> _pageOptions = [
StudentHomePage(bearer, username),
StudentProjectPage(),
StudentStudyplanPage()
];
@override
Widget build(BuildContext context) {
return Scaffold(
endDrawer: Drawer(),
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black54),
elevation: 0,
),
body: _pageOptions[_selectedPage],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedPage,
onTap: (int index) {
setState(() {
_selectedPage = index;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Hem')
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text("Skolprojekt")
),
BottomNavigationBarItem(
icon: Icon(Icons.check_circle_outline),
title: Text("Studieplaner")
),
],
),
);
}}
Подробнее о настройке домашней страницы: Как и вы.Можно ли определить конечный носитель String и конечное имя пользователя String.
class _StudentHomePageState extends State<StudentHomePage> {
final String bearer;
final String username;
_StudentHomePageState(this.bearer, this.username);
@override
Widget build(BuildContext context) {
return Container(
child: ListView(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 20),
alignment: Alignment.centerLeft,
child: Column(
children: <Widget>[
Container(child: Text('Välkommen Tillbaka', style: TextStyle(fontSize: 30, fontWeight: FontWeight.w600),), alignment: Alignment.centerLeft,),
Container(child: Text('${username.toUpperCase()[0]}${username.substring(1)}!', style: TextStyle(fontSize: 30, fontWeight: FontWeight.w600),), alignment: Alignment.centerLeft,),
],
)
)
],
),
);
}
}
Является ли это проблемой, поскольку страницы находятся в массиве?Это всегда работает, когда я делаю navigator.push на страницу.Если у кого-то есть душ.Не стесняйтесь помочь:)