Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.8Found to occur in 2.8Found to occur in 2.8frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Description
Description
I try to have an GridView inside an ExpansionTile wrapped in a Sliverlist. To persist the state of the ExpansionTile I added a PageStorageKey but by expanding the ExpanstionTile, after collapsing it, an error is thrown
Steps to Reproduce
- Execute
flutter runon the code sample
Expected results:
No error.
Actual results:
The following error is thrown upon expanding the ExpansionTile:
The following _CastError was thrown building GridView(scrollDirection: vertical, primary: using primary controller, NeverScrollableScrollPhysics, shrinkWrap: shrink-wrapping, dependencies: [MediaQuery, PrimaryScrollController]):
type 'bool' is not a subtype of type 'double?' in type cast
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const TestScreen());
}
class TestScreen extends StatelessWidget {
const TestScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
body: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
// SliverAppBar comes here
SliverList(
delegate: SliverChildListDelegate([
_expansionTile(),
]))
],
),
),
);
}
Widget _expansionTile() {
return ExpansionTile(
initiallyExpanded: true,
key: const PageStorageKey("some-key"), // <-- produces the error
title: const Text("Expansoion Tile"),
children: [_grid()],
);
}
Widget _grid() {
return GridView.count(
shrinkWrap: true,
crossAxisCount: 3,
physics: const NeverScrollableScrollPhysics(),
children: const [
Text("1"),
Text("2"),
Text("3"),
Text("4"),
Text("5"),
],
);
}
}Reacted by Maatteogekko, Adam Bridges, Gülsen Keskin, Christian Navolskyi, Jannis Rosenbaum, cosminbodnariuc, Logan Parker and Hiroshi Kikuchi
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.8Found to occur in 2.8Found to occur in 2.8frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Activity
maheshj01 commentedon Feb 2, 2022
Hi @lukaskirner, Thanks for filing the issue, I am able to reproduce the issue on stable and the master channel error is thrown when collapsing the expansionTile.
code sample
flutter doctor -v
flutter run
lukaskirner commentedon Feb 2, 2022
Thx. This also happens with ListView.
goderbauer commentedon Feb 2, 2022
Can you post the full stack trace that shows at what line this crashes?
lukaskirner commentedon Feb 3, 2022
Sure.
Stack Trace
4 remaining items
khuntia commentedon Jul 28, 2022
This is also happening if SingleChildScrollView is having PaginatedDataTable as child with both having PageStorageKey. The pagestoragekey for the paginateddatatable throws a casting error of "type 'double' is not a subtype of type 'int?' in type cast".
bobekos commentedon Aug 25, 2022
@TahaTesser
hi any progress here?
AdamBridges commentedon Jun 5, 2023
Why not just let the developer handle the state and set
_isExpandedto whatever is provided to the widget viainitiallyExpanded, changingexpansion_tile.dartlike so:_isExpanded = widget.initiallyExpanded;Note that in my particular case, I am receiving this error:
sinnaj-r commentedon Feb 3, 2025
@maheshj01 Any updates on this? This bug makes the ExpansionTile bairly usable for us.
loganpar commentedon Nov 11, 2025
Any updates on this? Still seems to be an issue, though it might be better classified as a design oversight.
suhail-121 commentedon Jul 13, 2026
I wrapped my expansion tile with pagestorage widget it was resolved for me.
Fix crash when unfolding OMEMO2 section in Verify screen