Created
April 9, 2021 11:09
-
-
Save royarg02/c7bcd2cf9bc1aa450def9d804db4f3af to your computer and use it in GitHub Desktop.
TabBar incorrect interactive region
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/material.dart'; | |
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
| home: MyHomePage(), | |
| ); | |
| } | |
| } | |
| class MyHomePage extends StatefulWidget { | |
| final List<Widget> pages = [ | |
| PageOne(), | |
| PageTwo(), | |
| PageThree(), | |
| ]; | |
| @override | |
| _MyHomePageState createState() => _MyHomePageState(); | |
| } | |
| class _MyHomePageState extends State<MyHomePage> | |
| with SingleTickerProviderStateMixin { | |
| late final _tabController; | |
| @override | |
| void initState() { | |
| super.initState(); | |
| _tabController = TabController(length: 3, vsync: this); | |
| } | |
| @override | |
| void dispose() { | |
| _tabController.dispose(); | |
| super.dispose(); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text('Region outside the overlay isn\'t interactive'), | |
| bottom: TabBar( | |
| overlayColor: MaterialStateColor.resolveWith((states) => (Colors.deepPurple)), | |
| tabs: [ | |
| Tab(icon: Icon(Icons.add),text: 'Icon & text'), | |
| Tab(text: 'Text'), | |
| Tab(icon: Icon(Icons.undo)), | |
| ], | |
| controller: _tabController, | |
| ), | |
| ), | |
| body: TabBarView( | |
| controller: _tabController, | |
| children: widget.pages, | |
| ), | |
| ); | |
| } | |
| } | |
| class PageOne extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Center( | |
| child: Text('Page one'), | |
| ); | |
| } | |
| } | |
| class PageTwo extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Center( | |
| child: Text('Page two'), | |
| ); | |
| } | |
| } | |
| class PageThree extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Center( | |
| child: Text('Page three'), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment