Tab crash in complex_layout (#7744)
This commit is contained in:
parent
8e3ea7523e
commit
64d3647084
@ -50,16 +50,15 @@ class ComplexLayout extends StatefulWidget {
|
|||||||
ComplexLayoutState createState() => new ComplexLayoutState();
|
ComplexLayoutState createState() => new ComplexLayoutState();
|
||||||
|
|
||||||
static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher<ComplexLayoutState>());
|
static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher<ComplexLayoutState>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FancyItemDelegate extends LazyBlockDelegate {
|
class FancyItemDelegate extends LazyBlockDelegate {
|
||||||
@override
|
@override
|
||||||
Widget buildItem(BuildContext context, int index) {
|
Widget buildItem(BuildContext context, int index) {
|
||||||
if (index % 2 == 0)
|
if (index % 2 == 0)
|
||||||
return new FancyImageItem(index, key: new Key('Item $index'));
|
return new FancyImageItem(index, key: new ValueKey<int>(index));
|
||||||
else
|
else
|
||||||
return new FancyGalleryItem(index, key: new Key('Item $index'));
|
return new FancyGalleryItem(index, key: new ValueKey<int>(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -84,7 +83,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
|||||||
tooltip: 'Search',
|
tooltip: 'Search',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
print('Pressed search');
|
print('Pressed search');
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
new TopBarMenu()
|
new TopBarMenu()
|
||||||
]
|
]
|
||||||
@ -93,14 +92,13 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Expanded(
|
new Expanded(
|
||||||
child: new LazyBlock(
|
child: new LazyBlock(
|
||||||
key: new Key('main-scroll'),
|
delegate: new FancyItemDelegate(),
|
||||||
delegate: new FancyItemDelegate()
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new BottomBar()
|
new BottomBar(),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
drawer: new GalleryDrawer()
|
drawer: new GalleryDrawer(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,7 +476,7 @@ class ItemGalleryBox extends StatelessWidget {
|
|||||||
child: new TabBarView(
|
child: new TabBarView(
|
||||||
children: tabNames.map((String tabName) {
|
children: tabNames.map((String tabName) {
|
||||||
return new Container(
|
return new Container(
|
||||||
key: new Key('Tab $index - $tabName'),
|
key: new Key(tabName),
|
||||||
child: new Padding(
|
child: new Padding(
|
||||||
padding: new EdgeInsets.all(8.0),
|
padding: new EdgeInsets.all(8.0),
|
||||||
child: new Card(
|
child: new Card(
|
||||||
@ -487,10 +485,10 @@ class ItemGalleryBox extends StatelessWidget {
|
|||||||
new Expanded(
|
new Expanded(
|
||||||
child: new Container(
|
child: new Container(
|
||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
backgroundColor: Theme.of(context).primaryColor
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
child: new Center(
|
child: new Center(
|
||||||
child: new Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white))
|
child: new Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -498,16 +496,16 @@ class ItemGalleryBox extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new IconButton(
|
new IconButton(
|
||||||
icon: new Icon(Icons.share),
|
icon: new Icon(Icons.share),
|
||||||
onPressed: () { print('Pressed share'); }
|
onPressed: () { print('Pressed share'); },
|
||||||
),
|
),
|
||||||
new IconButton(
|
new IconButton(
|
||||||
icon: new Icon(Icons.event),
|
icon: new Icon(Icons.event),
|
||||||
onPressed: () { print('Pressed event'); }
|
onPressed: () { print('Pressed event'); },
|
||||||
),
|
),
|
||||||
new Expanded(
|
new Expanded(
|
||||||
child: new Padding(
|
child: new Padding(
|
||||||
padding: new EdgeInsets.only(left: 8.0),
|
padding: new EdgeInsets.only(left: 8.0),
|
||||||
child: new Text('This is item $tabName')
|
child: new Text('This is item $tabName'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -866,6 +866,7 @@ class TabPageSelector extends StatelessWidget {
|
|||||||
final ColorTween selectedColor = new ColorTween(begin: Colors.transparent, end: color);
|
final ColorTween selectedColor = new ColorTween(begin: Colors.transparent, end: color);
|
||||||
final ColorTween previousColor = new ColorTween(begin: color, end: Colors.transparent);
|
final ColorTween previousColor = new ColorTween(begin: color, end: Colors.transparent);
|
||||||
final TabController tabController = controller ?? DefaultTabController.of(context);
|
final TabController tabController = controller ?? DefaultTabController.of(context);
|
||||||
|
assert(tabController != null);
|
||||||
final Animation<double> animation = new CurvedAnimation(
|
final Animation<double> animation = new CurvedAnimation(
|
||||||
parent: tabController.animation,
|
parent: tabController.animation,
|
||||||
curve: Curves.fastOutSlowIn,
|
curve: Curves.fastOutSlowIn,
|
||||||
@ -874,11 +875,11 @@ class TabPageSelector extends StatelessWidget {
|
|||||||
animation: animation,
|
animation: animation,
|
||||||
builder: (BuildContext context, Widget child) {
|
builder: (BuildContext context, Widget child) {
|
||||||
return new Semantics(
|
return new Semantics(
|
||||||
label: 'Page ${controller.index + 1} of ${controller.length}',
|
label: 'Page ${tabController.index + 1} of ${tabController.length}',
|
||||||
child: new Row(
|
child: new Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: new List<Widget>.generate(controller.length, (int tabIndex) {
|
children: new List<Widget>.generate(tabController.length, (int tabIndex) {
|
||||||
return _buildTabIndicator(tabIndex, controller, selectedColor, previousColor);
|
return _buildTabIndicator(tabIndex, tabController, selectedColor, previousColor);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user