[英]Flutter - OTP Verification works in debug mode but not release mode iOS
[英]Grey screen in release mode (IOS - Flutter)
我在我的應用程序的兩個頁面上出現灰色屏幕,當我從 TestFlight 安裝它時,我只在發布模式下遇到這個問題。 調試模式下沒有錯誤,當我從 android studio 以發布模式運行時它也能正常工作。
這是我在兩個屏幕上的代碼:
第一個屏幕:
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(),
);
第二個屏幕:
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(),
);
我一直在各種設備上測試它,我遇到了同樣的問題。
正如@Amina Bekir 所提到的,問題是他們有兩個項目副本,所以 Android Studio 有新副本,而 Xcode 有舊副本。
然后將舊代碼上傳到 TestFlight,使此行為出現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.