我正在使用弯曲的导航栏创建一个应用程序,并以此导航应用程序中的其他屏幕。
现在问题区域是,当我在使用弧形导航栏的班级中使用Future Builder时,按钮无法移动。单击底部的五个按钮时,将显示空白屏幕1秒钟,然后导航到实际屏幕,并且当我们单击假定索引为no时,按钮也不会移动。 3。
下面,我在使用curved_navigation_bar的地方共享了我的代码
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter_svg/svg.dart';
import 'package:matchstixx/Models/userAccount/userAccount.dart';
import 'package:matchstixx/constants/application.dart';
import 'package:matchstixx/logic/login.dart';
import 'package:matchstixx/styles/colors.dart';
import 'challenges.dart';
import 'create_challenge.dart';
import 'friends_top_navigation.dart';
import 'home_page.dart';
import 'intro_screen.dart';
import 'login_page.dart';
void main() => runApp(MaterialApp(home: BottomNavBar()));
class BottomNavBar extends StatefulWidget {
@override
_BottomNavBarState createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
UserAccount userDetails;
int _indexforNav = 0;
int loggedIn ;
Future<void> intiUserModel() async {
Login loginObject = new Login();
await loginObject.verifySession().then((data) {
if(data!=null){
if (data["sessionStatus"] == SessionType.active) {
this.userDetails = new UserAccount.fromJson(json.decode(data["userData"]));
this.loggedIn = SessionType.active;
} else{
this.loggedIn = SessionType.expired;
}
}else{
this.loggedIn = SessionType.newUser;
}
});
}
int _pageIndex = 0;
GlobalKey _bottomNavigationKey = GlobalKey();
MyRoute routeList(index){
List pages;
pages = [
MyRoute(
page: HomePage(this.userDetails),
),
MyRoute(
page: page2(),
),
MyRoute(
page: CreateChallenge(this.userDetails),
),
MyRoute(
page: FriendList(),
),
MyRoute(
page: Challenges(),
)
];
return pages[index];
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: intiUserModel(),
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if(SessionType.active == this.loggedIn){
return this.makeBottomNav();
}else if(SessionType.expired == this.loggedIn){
return LoginPage();
} else{
return IntroScreen();
}
} else {
return CircularProgressIndicator();
}
});
}
Widget makeBottomNav(){
return SafeArea(
child: Scaffold(
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
height: 60,
animationDuration: Duration(
milliseconds: 200
),
animationCurve: Curves.easeOut,
index: 0,
backgroundColor: bgGray,
items: <Widget>[
SvgPicture.asset(
"assets/bottom-nav-icons/Outline/home.svg",
height: 30,
fit: BoxFit.scaleDown,
),
SvgPicture.asset(
"assets/bottom-nav-icons/Outline/chat.svg",
height: 30,
fit: BoxFit.scaleDown,
),
SvgPicture.asset(
"assets/actions/add.svg",
height: 30,
fit: BoxFit.scaleDown,
),
SvgPicture.asset(
"assets/bottom-nav-icons/Outline/friends.svg",
height: 30,
fit: BoxFit.scaleDown,
),
SvgPicture.asset(
"assets/bottom-nav-icons/Outline/challenges.svg",
height: 30,
fit: BoxFit.scaleDown,
),
],
onTap: (index) {
setState(() {
_pageIndex = index;
});
},
),
body: routeList(_pageIndex).page,
),
);
}
}
class MyRoute {
final Widget page;
MyRoute({this.page});
}
class page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: bgGray,
child:Align(
alignment: Alignment(0, 0),
child: Text('Under Maintenance',style: TextStyle(fontWeight: FontWeight.bold,fontSize: 25.0),)
)
);
}
}
过去5天来我一直在努力解决此问题,有人可以帮我吗?