Skip to content

Instantly share code, notes, and snippets.

@cubehouse cubehouse/test.dart
Created Aug 12, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.