Skip to content

Instantly share code, notes, and snippets.

@cubehouse
Created August 12, 2018 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cubehouse/6502bf06c21301a189e2dc4928931732 to your computer and use it in GitHub Desktop.
Save cubehouse/6502bf06c21301a189e2dc4928931732 to your computer and use it in GitHub Desktop.
Flutter Tab Crash #11895
import 'package:flutter/material.dart';
void main() {
runApp(TabBarDemo());
}
class TabBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
Tab(icon: Icon(Icons.directions_boat)),
],
),
title: Text('Tabs Demo'),
),
body: TabBarView(
children: [
StateTest(),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
Icon(Icons.directions_boat),
],
),
),
),
);
}
}
class StateTest extends StatefulWidget
{
@override
State<StatefulWidget> createState() {
return new StateTestState();
}
}
class StateTestState extends State<StateTest> with AutomaticKeepAliveClientMixin
{
@override
Widget build(BuildContext context) {
return Icon(Icons.directions_car);
}
@override
bool get wantKeepAlive => true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment