ExpansionTile error in ListView.builder

904 views
Skip to first unread message

Gökçen Merve Horuk

unread,
Jun 22, 2020, 6:11:16 AM6/22/20
to Flutter Development (flutter-dev)
Hi,

I am using ExpansionTile in ListView.builder. When I scroll down when I open one on the screen, the rest of it opens up on its own and then throws an error.

Codes;

@override
 
Widget build(BuildContext context) {
   
return ChangeNotifierProvider<HomeModel>(
     
create: (context) => locator<HomeModel>(),
     
child: Consumer<HomeModel>(
       
builder: (context, model, child) =>
       
model.state == ViewState.girisSonucLoadingState
           
? Center(
             
child: CircularProgressIndicator(
         
backgroundColor: Colors.white,
       
),
           
)
           
: ListView.builder(
           
itemCount: 10,
           
itemBuilder: (context, index) {
             
return ExpansionTile(
               
subtitle: Text("Ad Soyad "+index.toString()),
                title
: Text("
Şube :"+index.toString()),
               
children: <Widget>[
                 
Container(
                   
padding: EdgeInsets.all(4),
                   
child: Column(
                     
crossAxisAlignment: CrossAxisAlignment.stretch,
                     
children: <Widget>[
                       
Row(
                         
mainAxisAlignment: MainAxisAlignment.spaceBetween,
                         
children: <Widget>[
                           
Column(
                             
children: <Widget>[
                               
Padding(
                                 
padding: const EdgeInsets.all(8.0),
                                 
child: Text(
                                   
"Ad Soyad "+index.toString(),
                                   
style: TextStyle(
                                       
fontWeight: FontWeight.w700,
                                       
fontSize: 14),
                                 
),
                               
),
                               
Padding(
                                 
padding: const EdgeInsets.all(8.0),
                                 
child: Text(
                                   
"Şube "+index.toString(),
                                   
style: TextStyle(
                                       
fontWeight: FontWeight.w700,
                                       
fontSize: 14),
                                 
),
                               
),
                               
Padding(
                                 
padding: const EdgeInsets.all(8.0),
                                 
child: Text(
                                   
"Bölüm "+index.toString(),
                                   
style: TextStyle(
                                       
fontWeight: FontWeight.w700,
                                       
fontSize: 14),
                                 
),
                               
),
                               
Padding(
                                 
padding: const EdgeInsets.all(8.0),
                                 
child: Text(
                                   
"Tel "+index.toString(),
                                   
style: TextStyle(
                                       
fontWeight: FontWeight.w700,
                                       
fontSize: 14),
                                 
),
                               
),
                             
],
                           
),
                         
],
                       
),
                       
ButtonBar(
                         
alignment: MainAxisAlignment.end,
                         
mainAxisSize: MainAxisSize.min,
                         
children: <Widget>[
                           
RaisedButton(
//                                borderSide: BorderSide(
//                                    color: Colors.red),
                               
onPressed: () {},
                               
color: Colors.white,
                               
child: Text(
                                 
"SİL",
                                 
style: TextStyle(
                                     
color: Colors.red,
                                     
fontSize: 16,
                                     
fontWeight: FontWeight.w700),
                               
)),
                           
RaisedButton(
//                                borderSide: BorderSide(
//                                    color: Colors.green),
                               
onPressed: () {
                                   
Navigator.of(context).push(MaterialPageRoute(
                                               
builder: (context) => DanismanGuncelle()));
                               
},
                               
color: Colors.white,
                               
child: Text(
                                 
"GÜNCELLE",
                                 
style: TextStyle(
                                     
color: Colors.green,
                                     
fontSize: 16,
                                     
fontWeight: FontWeight.w700),
                               
)),
                         
],
                       
),
                     
],
                   
),
                 
),
               
],
             
);
           
}),
     
),
   
);
 
}

}


The error that occurs is as follows;


════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following _CastError was thrown building NotificationListener<KeepAliveNotification>: type 'double' is not a subtype of type 'bool' in type cast The relevant error-causing widget was: ListView file:///C:/Users/gmh/AndroidStudioProjects/flutter_app/app/lib/views/danisman_listesi.dart:37:24 When the exception was thrown, this was the stack: #0 _ExpansionTileState.initState (package:flutter/src/material/expansion_tile.dart:118:63) #1 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4640:58) #2 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5) ... Normal element mounting (33 frames) #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14) ... ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 263 pos 16: 'child == null || indexOf(child) > index': is not true. The relevant error-causing widget was: ListView file:///C:/Users/gmh/AndroidStudioProjects/flutter_app/app/lib/views/danisman_listesi.dart:37:24 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 263 pos 16: 'child == null || indexOf(child) > index': is not true. The relevant error-causing widget was: ListView file:///C:/Users/gmh/AndroidStudioProjects/flutter_app/app/lib/views/danisman_listesi.dart:37:24 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 263 pos 16: 'child == null || indexOf(child) > index': is not true. The relevant error-causing widget was: ListView file:///C:/Users/gmh/AndroidStudioProjects/flutter_app/app/lib/views/danisman_listesi.dart:37:24 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by rendering library ═════════════════════════════════════════════════════ 'package:flutter/src/widgets/framework.dart': Failed assertion: line 2611 pos 20: '_debugCurrentBuildTarget == context': is not true. The relevant error-causing widget was: ListView file:///C:/Users/gmh/AndroidStudioProjects/flutter_app/app/lib/views/danisman_listesi.dart:37:24 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by rendering library ═════════════════════════════════════════════════════ The method '-' was called on null. Receiver: null Tried calling: -(322.642939390356) The relevant error-causing widget was: ListView file:///C:/Users/gmh/AndroidStudioProjects/flutter_app/app/lib/views/danisman_listesi.dart:37:24 ════════════════════════════════════════════════════════════════════════════════════════════════════

I can not understand why it stems. I would be glad if you can help. 

Best regards,

Suzuki Tomohiro

unread,
Jun 22, 2020, 7:34:59 AM6/22/20
to Gökçen Merve Horuk, Flutter Development (flutter-dev)
Add a breakpoint At the problematic line (the top of the stacktrace) to see why doublee-bool mismatch happens.

<span class="hljs-string" style="box-sizing: border-box; color: rgb(3, 47, 98); font-family: source-code-pro, Monac
Reply all
Reply to author
Forward
0 new messages