Reputation: 270
I am getting a grey screen on two pages in my app, I m facing this problem only in release mode when I installed it from TestFlight. there is no error in debug mode, and it works fine also when I run it in release mode from android studio.
this is my code on two screens:
First screen:
ViewModelBuilder<TraineeCoachViewModel>.nonReactive(
builder: (context, model, child) => Layout(
title: coachFullName,
body:
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(Assets.rightBackground),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.2), BlendMode.dstATop),
),
),
child:
SingleChildScrollView(
child: Column(
children: [
FutureBuilder(
future: model.getCoachModel,
initialData: null,
builder: (BuildContext context,
AsyncSnapshot<CoachModel?> snapshot) {
if (!snapshot.hasData || snapshot.data == null) {
return const Loading();
}
final CoachModel coachmodel = snapshot.data!;
final List<String> additionalPhotos = coachmodel.album ?? [];
final String profilePhoto = coachmodel.profilePhoto ?? "";
final List<String?> imagesToSlide = [
profilePhoto,
...additionalPhotos
];
final _slideImageItemwidth =
MediaQuery.of(context).size.width / 2;
final _slideImageItemHeight =
MediaQuery.of(context).size.width / 2.5;
return
SingleChildScrollView(
padding: const EdgeInsets.all(10.0),
child:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
height: _slideImageItemwidth,
width: _slideImageItemHeight,
decoration: BoxDecoration(
border: Border.all(
color: Colors.yellowAccent,
width: 1.0,
)),
child: PageView.builder(
itemCount: imagesToSlide.length,
itemBuilder: (_, index) {
final String? image = imagesToSlide[index];
return Hero(
tag: index.toString() + "S",
child: GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
fullscreenDialog: true,
builder: (BuildContext
context) =>
HeroPhoto(
imageUrl: image,
tag:
index.toString() +
"S"))),
child: CardItemProfilePhoto(
iconSize: 50,
imageUrl: image,
withBorderDecoration: false,
size: Size(_slideImageItemwidth,
_slideImageItemwidth),
),
));
}),
),
),
verticalSpaceMedium,
additionalPhotos.isNotEmpty
? GridView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: additionalPhotos.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 0.7,
mainAxisSpacing: 5.0,
crossAxisSpacing: 5.0),
itemBuilder: (_, index) {
return Hero(
tag: "${index + 1}",
child: GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
fullscreenDialog: true,
builder: (BuildContext context) =>
HeroPhoto(
imageUrl:
additionalPhotos[
index],
tag: "${index + 1}"),
)),
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints constraints) {
return CardItemProfilePhoto(
iconSize: 20,
imageUrl: additionalPhotos[index],
size: constraints.biggest,
);
},
),
),
);
})
: Container(),
coachmodel.bio != null
? verticalSpaceMediumS
: Container(),
coachmodel.bio != null
? AppText.headingTwo(
localizations.bio + ":",
)
: Container(),
verticalSpaceNormal,
Text(
coachmodel.bio ?? "",
style: captionStyle,
),
coachmodel.bio != null
? verticalSpaceMediumS
: Container(),
StreamBuilder(
stream: model.coursesStream,
builder: (BuildContext context,
AsyncSnapshot<List<CourseModel>> snapshot) {
if (!snapshot.hasData || snapshot.data == null) {
return const Loading(
showBackgroundColor: false,
);
}
final courses = snapshot.data
?.where((element) =>
element.isSameType(courseType))
.toList();
if (model.isBusy) {
WidgetsBinding.instance!
.addPostFrameCallback((timeStamp) {
model.setBusy(false);
});
}
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: courses!.length,
itemBuilder: (_, index) {
final courseModel = courses[index];
bool found = false;
if (courses[index].traineesIn != null &&
model.userId != '') {
found = courses[index]
.traineesIn!
.contains(model.userId);
}
///Subscription button
return SizedBox(
height: screenHeightPercentage(context,
percentage: 0.10),
width: double.infinity,
child: SubscriptionItemShaped(
params: getParams(courseModel,
model, localizations,
traineeIdFound: found,
context: context)));
});
},
),
]),
);
},
),
],
),
),
),
resizeToAvoidBottomInset: true,
),
viewModelBuilder: () => getIt<TraineeCoachViewModel>()
..coachId = coachID
..coachName = coachFullName
..init(),
);
Second screen:
ViewModelBuilder<NotificationsViewModel>.nonReactive(
builder: (context, model, child) {
return Layout(
title: localizations.subs_detail,
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(Assets.rightBackground),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.2), BlendMode.dstATop),
),
),
child: SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(
top: screenHeightPercentage(context, percentage: 0.03)),
child: Column(
children: [
FutureBuilder<TraineeModel?>(
future: model.getTraineeModel(subsModel.traineeId!),
initialData: null,
builder: (BuildContext context,
AsyncSnapshot<TraineeModel?> snapshot) {
if (!snapshot.hasData || snapshot.data == null) {
return const Loading();
}
final TraineeModel userModel = snapshot.data!;
return Padding(
padding: EdgeInsets.only(
left: screenWidthPercentage(context,
percentage: 0.05)),
child: Column(
children: [
Text(localizations.trainee_detail.toUpperCase(),
style:
heading1Style.copyWith(fontSize: 20)),
verticalSpaceMedium,
CircularProfilePhoto(
imageurl: userModel.profilePhoto,
iconSize: 30,
height: screenHeightPercentage(context,
percentage: 0.17),
width: screenHeightPercentage(context,
percentage: 0.17),
),
verticalSpaceMedium,
Padding(
padding: langauge.appLocal.languageCode ==
'ar'
? EdgeInsets.only(
left: screenWidthPercentage(context,
percentage: 0.20),
right: screenWidthPercentage(context,
percentage: 0.2),
)
: EdgeInsets.only(
left: screenWidthPercentage(context,
percentage: 0.23),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
userModel.fullName!.toUpperCase(),
style: heading1Style.copyWith(
fontSize: 15,
color: kcWhiteColor),
),
verticalSpaceMedium,
Text(
userModel.gender.toUpperCase(),
style: heading1Style.copyWith(
fontSize: 15,
color: kcWhiteColor),
),
],
),
Column(
children: [
userModel.height != null
? verticalSpaceMedium
: Container(),
// userModel.height != null ?
Container(
margin: EdgeInsets.only(
right: screenWidthPercentage(
context,
percentage: 0.25)),
child: Text(
userModel.height != null
? '${userModel.height!.toString()} ${localizations.cm}'
: '0.0 ${localizations.cm}',
style: heading1Style.copyWith(
fontSize: 15,
color: kcWhiteColor),
),
),
//: Container(),
verticalSpaceMedium,
Container(
margin: EdgeInsets.only(
right: screenWidthPercentage(
context,
percentage: 0.25)),
child: Text(
userModel.weight != null
? '${userModel.weight!.toString()} ${localizations.kg}'
: '0.0 ${localizations.kg}',
style: heading1Style.copyWith(
fontSize: 15,
color: kcWhiteColor),
),
)
],
)
],
),
),
],
),
);
}),
verticalSpaceMedium,
Container(
height: 1,
color: kcWhiteColor,
margin: EdgeInsets.symmetric(horizontal: 30),
),
verticalSpaceMedium,
Text(localizations.course_detail.toUpperCase(),
style: heading1Style.copyWith(fontSize: 20)),
verticalSpaceMedium,
Text(subsModel.courseName!.toUpperCase(),
style: heading1Style.copyWith(
fontSize: 25, color: kcWhiteColor)),
verticalSpaceMedium,
Text(
'${subsModel.coursePrice} ${localizations.currency_code}',
style: heading1Style.copyWith(
fontSize: 25, color: kcWhiteColor)),
StreamBuilder<SubscriptionModel>(
stream: model.getSubscription(subsModel.id!),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Loading(
showBackgroundColor: false,
);
}
return Container(
margin: EdgeInsets.only(
top: screenHeightPercentage(context,
percentage: 0.1)),
child: snapshot.data!.subscriptionStatus.value ==
SUBSCRIPTION_STATUS
.WAITING_PAYMENT.value ||
snapshot.data!.subscriptionStatus.value ==
SUBSCRIPTION_STATUS.REJECTED.value ||
snapshot.data!.subscriptionStatus.value ==
SUBSCRIPTION_STATUS.BLOCKED.value
? StatusText(
status: snapshot
.data!.subscriptionStatus.value,
subscriptionModel: snapshot.data!,
localizations: localizations,
notificationsViewModel: model,
)
: Row(
children: [
Expanded(
child: ButtonWidget(
subscriptionModel: snapshot.data!,
localizations: localizations,
notificationsViewModel: model,
text: localizations.accept
.toUpperCase(),
color: Colors.green,
onPressed: () {
model.accept(snapshot.data!);
},
),
),
// ),
Expanded(
child: ButtonWidget(
subscriptionModel: snapshot.data!,
localizations: localizations,
notificationsViewModel: model,
text: localizations.chat_status
.toUpperCase(),
color: Colors.blueGrey,
onPressed: () {
model.chat(snapshot.data!);
},
),
),
Expanded(
child: ButtonWidget(
subscriptionModel: snapshot.data!,
localizations: localizations,
notificationsViewModel: model,
color: Colors.redAccent,
onPressed: () {
model.reject(
snapshot.data!, context);
},
text: localizations.reject
.toUpperCase(),
),
),
Expanded(
child: ButtonWidget(
subscriptionModel: snapshot.data!,
localizations: localizations,
notificationsViewModel: model,
color: Colors.red,
onPressed: () {
model.block(
snapshot.data!, context);
},
text: localizations.block
.toUpperCase(),
),
),
],
));
})
],
),
),
),
),
);
},
viewModelBuilder: () => getIt<NotificationsViewModel>()..init(),
);
I have been testing it on various devices, and I got the same problem.
Upvotes: 0
Views: 735
Reputation: 3789
As mentioned by @Amina Bekir, the issue was that they had two copies of the project, so Android Studio had the new copy while Xcode has the old one.
Then the old code was uploaded to TestFlight making this behavior to appear.
Upvotes: 1