Flutter: Cupertino TabBar

2

How do I adapt the Cupertino TabBar to work in the same way as the BottomNavigationBar?

BottomNavigationBar

    return Scaffold(
      bottomNavigationBar: _bottomNavigationBar(_selectedIndex),
      body: PageStorage(
        child: pages[_selectedIndex],
        bucket: bucket,

Cupertino TabBar

final PageStorageBucket bucket = PageStorageBucket();
  int _selectedIndex = 1;

  Widget _tabBar(int selectedIndex) => CupertinoTabBar(
    onTap: (int index) => setState(() => _selectedIndex = index),
    currentIndex: selectedIndex,
    backgroundColor: Color(0xffffffff),
    iconSize: 20,
    items: ...

  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBuilder: _tabBar(_selectedIndex),
      child: PageStorage(
        child: pages[_selectedIndex],
        bucket: bucket,
flutter
asked on Stack Overflow Apr 14, 2020 by SKdev • edited Apr 14, 2020 by SKdev

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0