I am new to flutter and I have an error that I cant fix no matter what I try, tried to isolate the code that causeing it but no success the error I recieve is
> > ======== Exception caught by Flutter framework ===================================================== The following _CastError was thrown during a service extension callback for "ext.flutter.inspector.getRootWidgetSummaryTree": Null check operator
> used on a null value
>
> When the exception was thrown, this was the stack:
> #0 WidgetInspectorService._registerObjectGroupServiceExtension.<anonymous
> closure> (package:flutter/src/widgets/widget_inspector.dart:793:84)
> #1 WidgetInspectorService._registerObjectGroupServiceExtension.<anonymous
> closure> (package:flutter/src/widgets/widget_inspector.dart:792:17)
> #2 BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:597:32) <asynchronous
> suspension>
> ====================================================================================================
the error occurrce when I scroll ,I have the newest stable version of flutter installed (2.2.1) my 2 widgets are : an Home page
class Home extends StatelessWidget {
const Home({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: Drawer(
child: ListView(
children: <Widget>[DrawerHeader(child: Text("sadsa"))],
),
),
body: NestedScrollView(
floatHeaderSlivers: true,
scrollDirection: Axis.vertical,
clipBehavior: Clip.antiAlias,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
MyAppBar(),
];
},
body: ListView.separated(
itemBuilder: (context, i) {
return Container(
height: 100,
width: 200.0,
color:
Colors.primaries[Random().nextInt(Colors.primaries.length)],
);
},
separatorBuilder: (context, i) => Divider(height: 1.0),
itemCount: 30,
)),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.arrow_back), label: "asdsa"),
BottomNavigationBarItem(icon: Icon(Icons.arrow_back), label: "asdsa"),
],
currentIndex: 0,
onTap: (int i) {},
),
);
}
}
and another widget which called MyAppBar, its customised silverAppBar that I built
class MyAppBar extends StatefulWidget {
const MyAppBar({Key key}) : super(key: key);
@override
_MyAppBarState createState() => _MyAppBarState();
}
class _MyAppBarState extends State<MyAppBar> {
@override
void initState() {
super.initState();
}
Widget build(BuildContext context) {
return SliverAppBar(
title: Text("my App"),
floating: true,
snap: true,
actions: [
GestureDetector(
onTap: () {},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: IconButton(
icon: Icon(Icons.search_rounded),
onPressed: () {},
iconSize: 35.0,
),
),
),
GestureDetector(
onTap: () {},
child: CircleAvatar(
radius: 20.0,
child: Text("asdsa"),
),
)
],
bottom: PreferredSize(
preferredSize: Size.fromHeight(70.0),
child: Container(
height: 70.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: List.generate(10, (index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 7.0, vertical: 10.0),
child: Chip(label: Text('$index')));
})
),
)
),
);
}
}