I've been made a list of Card and ExpansionTile with a list view builder, because of saving last values in textformfields I've used key for ExpansionTile as a type of PageStorKey, everything works good but after removing one of the item of list, this error happen,
The following _CastError was thrown building SingleChildScrollView(dependencies:
[PrimaryScrollController]):
type 'bool' is not a subtype of type 'double?' in type cast
The relevant error-causing widget was:
When the exception was thrown, this was the stack:
#0 ScrollPosition.restoreScrollOffset (package:flutter/src/widgets/scroll_position.dart:420:103)
#1 new ScrollPosition (package:flutter/src/widgets/scroll_position.dart:105:7)
#2 new ScrollPositionWithSingleContext (package:flutter/src/widgets/scroll_position_with_single_context.dart:56:8)
#3 ScrollableState._updatePosition (package:flutter/src/widgets/scrollable.dart:406:10)
#4 ScrollableState.didChangeDependencies (package:flutter/src/widgets/scrollable.dart:431:5)
i have searched a lot in git and stack but didn't find any solution , this is My Code:
List<dynamic> RefrigCarNo = [];
ListView.builder(
shrinkWrap: true,
itemCount: RefrigCarNo.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: getColor(context, index),
key:new PageStorageKey(RefrigCarNo[0].elementAt(index)), <=I do it as string but didnt answer
child: ExpansionTile(
maintainState: CollapseState,
title:RichText(
textDirection: TextDirection.rtl,
text: TextSpan(
style: label_A,
children: [
TextSpan(text: 'refrigCar'),
TextSpan(text: ' ${RefrigCarNo[index][1].toString()} '
]
)
),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.fromLTRB(0, 10, 0, 3),
width: PageWidth * 0.4,
color: Colors.white,
child: Column(
children: [
Text('Kg Of Material', style: label_A,),
AppTextField1(
MyController: Weight,
MyValidation: false,
typeOfInput: TextInputType.number,
myReadOnly: readOnlyChange,
),
],
),
),
Container(
margin: EdgeInsets.fromLTRB(0, 10, 0, 3),
width: PageWidth * 0.3,
color: Colors.white,
child: Column(
children: [
Text('Total Net', style: label_A,),
AppTextField1(
MyController: NetCalcWeight,
MyValidation: false,
typeOfInput: TextInputType.number,
myReadOnly: readOnlyChange,
),
],
),
),
],
),
],
),
);
}),
this is removing function that defined in a button which include index of item:
void onDeleteVar(int _index) async{
setState(() {
RefrigCarNo.removeAt(_index);
});
}