build method Null safety

  1. @override
dynamic build(
  1. dynamic context
)

Implementation

@override
Widget build(BuildContext context) {
  final AppLocalizations appLocalizations = AppLocalizations.of(context);
  _tabs = <Widget>[
    _buildOffstageNavigator(BottomNavigationTab.Profile),
    _buildOffstageNavigator(BottomNavigationTab.Scan),
    _buildOffstageNavigator(BottomNavigationTab.History),
  ];

  final ThemeData themeData = Theme.of(context);
  final bool brightnessCheck = themeData.brightness == Brightness.light;
  return WillPopScope(
    onWillPop: () async {
      final bool isFirstRouteInCurrentTab =
          !await _navigatorKeys[_currentPage]!.currentState!.maybePop();
      if (isFirstRouteInCurrentTab) {
        if (_currentPage != BottomNavigationTab.Scan) {
          _selectTab(BottomNavigationTab.Scan, 1);
          return false;
        }
      }
      // let system handle back button if we're on the first route
      return isFirstRouteInCurrentTab;
    },
    child: Scaffold(
      body: Stack(children: _tabs),
      bottomNavigationBar: BottomNavigationBar(
        unselectedItemColor: brightnessCheck ? Colors.black : Colors.grey,
        showSelectedLabels: false,
        showUnselectedLabels: false,
        selectedItemColor: Colors.white,
        backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
        onTap: (int index) {
          final InheritedDataManagerState inheritedDataManager =
              InheritedDataManager.of(context);
          if (_currentPage == BottomNavigationTab.Scan &&
              _pageKeys[index] == BottomNavigationTab.Scan) {
            if (!inheritedDataManager.showSearchCard) {
              inheritedDataManager.resetShowSearchCard(true);
            }
            _selectTab(_pageKeys[index], index);
          } else {
            if (inheritedDataManager.showSearchCard) {
              inheritedDataManager.resetShowSearchCard(false);
            }
            _selectTab(_pageKeys[index], index);
          }
        },
        currentIndex: _currentPage.index,
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: const Icon(Icons.account_circle),
            label: appLocalizations.profile_navbar_label,
          ),
          BottomNavigationBarItem(
            icon: const Icon(Icons.search),
            label: appLocalizations.scan_navbar_label,
          ),
          BottomNavigationBarItem(
            icon: const Icon(Icons.history),
            label: appLocalizations.history_navbar_label,
          ),
        ],
      ),
    ),
  );
}