Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null check operator used on a null value #68

Open
lucian-ma opened this issue Mar 31, 2021 · 1 comment
Open

Null check operator used on a null value #68

lucian-ma opened this issue Mar 31, 2021 · 1 comment

Comments

@lucian-ma
Copy link

The following _CastError was thrown while resolving an image:
Null check operator used on a null value

When the exception was thrown, this was the stack:
#0 ScrollPosition.minScrollExtent (package:flutter/src/widgets/scroll_position.dart:136:49)
#1 _FixedExtentScrollPosition.itemIndex (package:flutter/src/widgets/list_wheel_scroll_view.dart:398:24)
#2 _FixedExtentScrollPosition.copyWith (package:flutter/src/widgets/list_wheel_scroll_view.dart:418:36)
#3 ScrollPosition.recommendDeferredLoading (package:flutter/src/widgets/scroll_position.dart:915:7)
#4 Scrollable.recommendDeferredLoadingForContext (package:flutter/src/widgets/scrollable.dart:295:28)
...
Image provider: ScrollAwareImageProvider()
Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#1863e(), devicePixelRatio: 2.6, locale: en_US, textDirection: TextDirection.ltr, size: Size(30.0, 20.0), platform: android)
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#1863e(), name: "packages/country_pickers/assets/ky.png", scale: 1.0)

this is my code:

Widget _buildSeletedCountryItem(Country country) => Padding(
padding: EdgeInsets.symmetric(vertical: 20.w),
child: Row(
children: [
CountryPickerUtils.getDefaultFlagImage(country),
SizedBox(width: 8.0),
Text("+${country.phoneCode}",style: TextStyle(fontSize: 36.sp),),
SizedBox(width: 8.0),
Flexible(child: Text(country.name,style: TextStyle(fontSize: 36.sp))),
],
),
);

Widget _buildCountryItem(Country country) {
return Row(
children: [
SizedBox(width: 8.0),
CountryPickerUtils.getDefaultFlagImage(country),
SizedBox(width: 8.0),
Text("+${country.phoneCode}"),
SizedBox(width: 8.0),
Flexible(child: Text(country.name)),
],
);
}

void showCountryModal(BuildContext context){
var tmpCountry = state.selectCountry.value;
showCupertinoModalPopup(
context: context,
builder: (BuildContext context) {
return Container(
child:Column(
mainAxisAlignment: MainAxisAlignment.end,
children:[
Container(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
child: Text("取消"),
onPressed: (){
Get.back();
},
),
TextButton(
child: Text("确定"),
onPressed: (){
state.selectCountry.value = tmpCountry;
state.selectCountry.refresh();
Get.back();
},
),
],
),
),
CountryPickerCupertino(
backgroundColor: Colors.white,
initialCountry: state.selectCountry.value,
itemBuilder:(country)=>_buildCountryItem(country) ,
pickerSheetHeight: 500.0.w,
pickerItemHeight:100.w,
onValuePicked: (Country country) {
tmpCountry = country;
},
// itemFilter: (c) =>
// ['AR', 'DE', 'GB', 'CN'].contains(c.isoCode),
priorityList: [
CountryPickerUtils.getCountryByIsoCode('TR'),
CountryPickerUtils.getCountryByIsoCode('US'),
],
)
]
)
);
}
);
}

@ahmedalrifai
Copy link

Hello @lucian-ma did you find solution for this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants