Код с горизонтальным списком отображается на сером экране на некоторых реальных устройствах после установки apk. В эмуляторе работает нормально, но на реальных устройствах проблема. Я прокомментировал часть кода, вызывающую проблему.
Это полный код:
WillPopScope(
onWillPop: onWillPop,
child: SafeArea(
child: Scaffold(
appBar: AppBar(
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage: AssetImage(
'assets/images/ShortLogo.jpeg',
),
backgroundColor: Colors.red,
),
),
title: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Morning",
style: TextStyle(
color: Colors.black,
fontSize: _width * 0.04,
),
),
Text(
" ${name} !",
style: TextStyle(
color: Colors.black,
fontSize: _width * 0.04,
fontWeight: FontWeight.bold),
),
],
),
backgroundColor: Colors.transparent,
elevation: 0,
actions: [
IconButton(
icon: ImageIcon(
AssetImage('assets/images/icons/Notification.png'),
color: Colors.black,
),
onPressed: () => Get.toNamed('/notification'),
),
Builder(
builder: (context) => IconButton(
icon: ImageIcon(
AssetImage('assets/images/icons/menu.png'),
color: Colors.black,
),
splashColor: primaryColor,
onPressed: () => Scaffold.of(context).openEndDrawer(),
)),
],
),
endDrawer: CustomDrawer(),
// drawer: CustomDrawer(),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: _height * 0.01, horizontal: _width * 0.02),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Obx(() {
if (productCategoryController.isLoading())
return Center(child: CircularProgressIndicator());
return Container(
height: _height * .3, //.4
width: double.infinity,
child: CarouselSlider.builder(
itemCount: productCategoryController.bannerList.length,
options: CarouselOptions(
autoPlay: true,
enlargeCenterPage: true,
viewportFraction: 1,
initialPage: 0,
onPageChanged: (index, reason) =>
setState(() => currentImage = index),
),
itemBuilder: (context, index, realIndex) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
///10
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(productCategoryController
.bannerList[index]
.toString()),
),
color: Colors.grey[100],
),
alignment: Alignment.bottomLeft,
width: double.infinity,
padding: EdgeInsets.symmetric(
vertical: 5, horizontal: 5)
);
},
),
);
}),
Padding(
padding: const EdgeInsets.all(.0),
child: Column(
children: [
Row(
children: [
Expanded(
child: Hero(
tag: 'topUpButton',
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 50, maxHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: yellow,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
),
onPressed: () => Get.to(RechargeTab1()),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/TopUp.png",
)),
SizedBox(width: _width * 0.04),
Text(
'Top-Up',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
),
SizedBox(width: 20),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 50, maxHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: green,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
foregroundColor: Colors.white),
onPressed: () async {
showLoaderDialog(context);
await productCategoryController
.getCategories();
Get.back();
Get.to(ProductCategoriesScreen());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/store.png",
)),
SizedBox(width: 10),
Text(
'Store',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
],
),
SizedBox(height: 20),
Row(
children: [
Expanded(
child: Hero(
tag: 'donationButton',
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 50, minHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: blue,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
),
onPressed: () => Get.toNamed('/donate'),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/onate.png",
)),
SizedBox(width: 10),
Text(
'Donation',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
),
SizedBox(width: 20),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 50, minHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
backgroundColor: red,
foregroundColor: Colors.white),
onPressed: () async {
Get.toNamed('/event');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/event.png",
)),
SizedBox(width: 10),
Text(
'Event',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
],
)
],
),
),
Padding(
padding: EdgeInsets.only(
top: 20.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Top Products",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: _width * 0.06),
),
TextButton(
onPressed: () async {
showLoaderDialog(context);
await productCategoryController.getCategories();
Get.back();
Get.to(ProductCategoriesScreen());
//Get.to(ProductCategoriesScreen());
},
child: Text(
"View More",
style: TextStyle(
fontSize: _width * 0.035,
fontWeight: FontWeight.w600),
))
],
),
),
// представление списка ниже является частью, вызывающей проблему
productCategoryController.isLoading()
? Center(child: CircularProgressIndicator())
: SizedBox(
height: _height * 0.27,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: topProductsLength,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
newProductController.product =
productCategoryController
.topProducts[index];
Get.to(() => TopProductDetailScreen());
},
child: Padding(
padding: EdgeInsets.all(_width * 0.02),
child: Container(
width: _height * 0.2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: Column(
// mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Container(
decoration: BoxDecoration(
color: prideGrey,
borderRadius:
BorderRadius.circular(8),
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(
"
productCategoryController
.topProducts[
index]
.imageUrl"),
),
),
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: _width * 0.03,
vertical: _width * 0.01),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
productCategoryController
.topProducts[index]
.productName
.replaceRange(
8,
productCategoryController
.topProducts[index]
.productName
.length,
'...'),
style: TextStyle(
overflow:
TextOverflow.ellipsis,
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: _width * 0.035),
),
Text(
"\$${productCategoryController.topProducts[index].currentPrice.toInt().toString()}",
style: TextStyle(
color: prideBlue,
fontWeight:
FontWeight.bold,
fontSize:
_width * 0.035)),
],
),
),
Padding(
padding:
EdgeInsets.all(_height * 0.01),
child: Container(
height: 28,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: Size(
double.infinity, 28),
textStyle: TextStyle(
fontSize:
_width * 0.03),
backgroundColor:
Color(0xffBF0A30)),
onPressed: () {
newProductController.product =
productCategoryController
.topProducts[index];
Get.to(() =>
TopProductDetailScreen());
},
child: Text("View Details")),
),
)
],
),
),
),
);
},
),
)
],
),
),
),
),
),
);
Подробнее здесь: https://stackoverflow.com/questions/758 ... grey-scree
Создавая APK-файл приложения Flutter в режиме выпуска, на некоторых устройствах часть кода показывает серый экран. ⇐ Android
Форум для тех, кто программирует под Android
1764080491
Anonymous
Код с горизонтальным списком отображается на сером экране на некоторых реальных устройствах после установки apk. В эмуляторе работает нормально, но на реальных устройствах проблема. Я прокомментировал часть кода, вызывающую проблему.
Это полный код:
WillPopScope(
onWillPop: onWillPop,
child: SafeArea(
child: Scaffold(
appBar: AppBar(
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage: AssetImage(
'assets/images/ShortLogo.jpeg',
),
backgroundColor: Colors.red,
),
),
title: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Morning",
style: TextStyle(
color: Colors.black,
fontSize: _width * 0.04,
),
),
Text(
" ${name} !",
style: TextStyle(
color: Colors.black,
fontSize: _width * 0.04,
fontWeight: FontWeight.bold),
),
],
),
backgroundColor: Colors.transparent,
elevation: 0,
actions: [
IconButton(
icon: ImageIcon(
AssetImage('assets/images/icons/Notification.png'),
color: Colors.black,
),
onPressed: () => Get.toNamed('/notification'),
),
Builder(
builder: (context) => IconButton(
icon: ImageIcon(
AssetImage('assets/images/icons/menu.png'),
color: Colors.black,
),
splashColor: primaryColor,
onPressed: () => Scaffold.of(context).openEndDrawer(),
)),
],
),
endDrawer: CustomDrawer(),
// drawer: CustomDrawer(),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: _height * 0.01, horizontal: _width * 0.02),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Obx(() {
if (productCategoryController.isLoading())
return Center(child: CircularProgressIndicator());
return Container(
height: _height * .3, //.4
width: double.infinity,
child: CarouselSlider.builder(
itemCount: productCategoryController.bannerList.length,
options: CarouselOptions(
autoPlay: true,
enlargeCenterPage: true,
viewportFraction: 1,
initialPage: 0,
onPageChanged: (index, reason) =>
setState(() => currentImage = index),
),
itemBuilder: (context, index, realIndex) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
///10
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(productCategoryController
.bannerList[index]
.toString()),
),
color: Colors.grey[100],
),
alignment: Alignment.bottomLeft,
width: double.infinity,
padding: EdgeInsets.symmetric(
vertical: 5, horizontal: 5)
);
},
),
);
}),
Padding(
padding: const EdgeInsets.all(.0),
child: Column(
children: [
Row(
children: [
Expanded(
child: Hero(
tag: 'topUpButton',
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 50, maxHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: yellow,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
),
onPressed: () => Get.to(RechargeTab1()),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/TopUp.png",
)),
SizedBox(width: _width * 0.04),
Text(
'Top-Up',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
),
SizedBox(width: 20),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 50, maxHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: green,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
foregroundColor: Colors.white),
onPressed: () async {
showLoaderDialog(context);
await productCategoryController
.getCategories();
Get.back();
Get.to(ProductCategoriesScreen());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/store.png",
)),
SizedBox(width: 10),
Text(
'Store',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
],
),
SizedBox(height: 20),
Row(
children: [
Expanded(
child: Hero(
tag: 'donationButton',
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 50, minHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: blue,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
),
onPressed: () => Get.toNamed('/donate'),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/onate.png",
)),
SizedBox(width: 10),
Text(
'Donation',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
),
SizedBox(width: 20),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 50, minHeight: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
backgroundColor: red,
foregroundColor: Colors.white),
onPressed: () async {
Get.toNamed('/event');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(AssetImage(
"assets/images/icons/event.png",
)),
SizedBox(width: 10),
Text(
'Event',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: _width * 0.04),
),
],
),
),
),
),
],
)
],
),
),
Padding(
padding: EdgeInsets.only(
top: 20.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Top Products",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: _width * 0.06),
),
TextButton(
onPressed: () async {
showLoaderDialog(context);
await productCategoryController.getCategories();
Get.back();
Get.to(ProductCategoriesScreen());
//Get.to(ProductCategoriesScreen());
},
child: Text(
"View More",
style: TextStyle(
fontSize: _width * 0.035,
fontWeight: FontWeight.w600),
))
],
),
),
[b]// представление списка ниже является частью, вызывающей проблему[/b]
productCategoryController.isLoading()
? Center(child: CircularProgressIndicator())
: SizedBox(
height: _height * 0.27,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: topProductsLength,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
newProductController.product =
productCategoryController
.topProducts[index];
Get.to(() => TopProductDetailScreen());
},
child: Padding(
padding: EdgeInsets.all(_width * 0.02),
child: Container(
width: _height * 0.2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: Column(
// mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Container(
decoration: BoxDecoration(
color: prideGrey,
borderRadius:
BorderRadius.circular(8),
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(
"
productCategoryController
.topProducts[
index]
.imageUrl"),
),
),
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: _width * 0.03,
vertical: _width * 0.01),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
productCategoryController
.topProducts[index]
.productName
.replaceRange(
8,
productCategoryController
.topProducts[index]
.productName
.length,
'...'),
style: TextStyle(
overflow:
TextOverflow.ellipsis,
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: _width * 0.035),
),
Text(
"\$${productCategoryController.topProducts[index].currentPrice.toInt().toString()}",
style: TextStyle(
color: prideBlue,
fontWeight:
FontWeight.bold,
fontSize:
_width * 0.035)),
],
),
),
Padding(
padding:
EdgeInsets.all(_height * 0.01),
child: Container(
height: 28,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: Size(
double.infinity, 28),
textStyle: TextStyle(
fontSize:
_width * 0.03),
backgroundColor:
Color(0xffBF0A30)),
onPressed: () {
newProductController.product =
productCategoryController
.topProducts[index];
Get.to(() =>
TopProductDetailScreen());
},
child: Text("View Details")),
),
)
],
),
),
),
);
},
),
)
],
),
),
),
),
),
);
Подробнее здесь: [url]https://stackoverflow.com/questions/75843218/building-the-flutter-app-apk-in-release-mode-a-portion-of-code-shows-grey-scree[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия