Created
June 30, 2022 14:06
-
-
Save henry2man/5c1c0dab58d5052b2eee605dd3f23cb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const DemoBugCupertinoTabView()); | |
} | |
class DemoBugCupertinoTabView extends StatelessWidget { | |
const DemoBugCupertinoTabView({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return CupertinoApp( | |
theme: CupertinoThemeData( | |
brightness: Brightness.light, | |
primaryColor: CupertinoColors.destructiveRed, | |
primaryContrastingColor: CupertinoColors.white, | |
scaffoldBackgroundColor: CupertinoColors.white, | |
barBackgroundColor: CupertinoColors.white.withOpacity(0.4), | |
), | |
builder: (context, x) => CupertinoTabScaffold( | |
tabBar: CupertinoTabBar( | |
items: const [ | |
BottomNavigationBarItem( | |
icon: Icon(CupertinoIcons.home), | |
label: 'Demo', | |
), | |
BottomNavigationBarItem( | |
icon: Icon(CupertinoIcons.home), | |
label: 'Other Demo', | |
), | |
], | |
), | |
tabBuilder: (context, index) => Home())); | |
} | |
} | |
class Home extends StatefulWidget { | |
const Home({Key? key}) : super(key: key); | |
@override | |
State<Home> createState() => _HomeState(); | |
} | |
class _HomeState extends State<Home> { | |
bool useTabView = false; | |
@override | |
Widget build(BuildContext context) { | |
return SafeArea( | |
child: Column( | |
children: [ | |
CupertinoButton( | |
child: const Text("Toggle"), | |
onPressed: () => setState(() => useTabView = !useTabView)), | |
Expanded( | |
child: useTabView | |
? CupertinoTabView( | |
builder: (context) => | |
const Center(child: Text("With Tabview"))) | |
: const Center(child: Text("Without Tabview"))) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment