我是一个飞镖和飞镖的初学者。我一直在尝试navigationBar在我的应用程序的三个不同页面上实现。对于单个页面,切换效果很好,但是我在将所有页面上的活动和非活动标签状态保持不变时遇到问题。似乎当它导航到另一个页面时,我也失去了选项卡的活动状态。这是我的代码。
AppFooter.dart
import 'package:flutter/material.dart';
class AppFooter extends StatefulWidget {
@override
_AppFooterState createState() => _AppFooterState();
}
class _AppFooterState extends State<AppFooter> {
int index = 0;
@override
Widget build(BuildContext context) {
return new Theme(
data: Theme.of(context).copyWith(
// sets the background color of the `BottomNavigationBar`
canvasColor: Colors.white,
// sets the active color of the `BottomNavigationBar` if `Brightness` is light
primaryColor: Colors.green,
textTheme: Theme.of(context)
.textTheme
.copyWith(caption: new TextStyle(color: Colors.grey))),
child: new BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: index,
onTap: (int index) {
setState(() { …Run Code Online (Sandbox Code Playgroud)