Android 抖动一些按钮不';我不能在某些设备上工作
大家好,我在我的应用程序中有一个简单的+-按钮,我在lenove p2,note 4,k20 pro上测试了它,它工作得很好,但在OnePlus 5T OxygenOs V10和Android V10上,它不工作,无论我点击它时做什么,它都不工作,就像一个空按钮。下面是代码Android 抖动一些按钮不';我不能在某些设备上工作,android,flutter,button,Android,Flutter,Button,大家好,我在我的应用程序中有一个简单的+-按钮,我在lenove p2,note 4,k20 pro上测试了它,它工作得很好,但在OnePlus 5T OxygenOs V10和Android V10上,它不工作,无论我点击它时做什么,它都不工作,就像一个空按钮。下面是代码 void showPricingSheet(context , article){ List<int> quantities = []; List<int> serviceIds = []
void showPricingSheet(context , article){
List<int> quantities = [];
List<int> serviceIds = [];
List<double> totalPrices = [];
double currentTotalPrice = 0.0;
int servicesLength;
//theses variables will be used to store values locally then send them to server
Future<List<Prices>> _prices = _fetchPrices(article['id']);
bool alreadyExc = false;
showModalBottomSheet(
isDismissible: false,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
context: context,
builder: (BuildContext context){
var responsivenessController = ResponsivenessController(context);
return StatefulBuilder(
builder: (BuildContext context , setState){
return FutureBuilder<List<Prices>>(
future: _prices,
builder: (context , snapshot){
if(snapshot.hasData){
List<Prices> price = snapshot.data;
if(alreadyExc == false){
// initializing the list with the length provided
servicesLength = price.length;
for(int i = 0; i < price.length; i++){
quantities.add(0);
serviceIds.add(price[i].serviceId);
totalPrices.add(0);
}
alreadyExc = true;
}
return Container(
padding: EdgeInsets.all(30),
child: Stack(
children: <Widget>[
ListView(
children: <Widget>[
Column(
children: <Widget>[
articleName(article),
Column(
children: List.generate(price.length, (index) =>
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(10),
child: Text(
translator.currentLanguage == 'ar' ?
'${price[index].serviceNameAr}'
:'${price[index].serviceNameEn}',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: responsivenessController.bodyFont1,
),
),
),
),
Text('${price[index].price}' ,
style: TextStyle(
fontSize: responsivenessController.bodyFont1,
),
),
Container(
child: Row(
children: <Widget>[
// the problem is in this section
//
//
//
//
IconButton(
onPressed: (){
setState(() {
double oldPrice = (quantities[index] * price[index].price).toDouble();
quantities[index] = quantities[index] + 1;
double newPrice = (quantities[index] * price[index].price).toDouble();
totalPrices[index] = newPrice.toDouble();
currentTotalPrice = (currentTotalPrice - oldPrice).toDouble();
currentTotalPrice = (currentTotalPrice + newPrice).toDouble();
});
},
icon: Icon(Icons.add , color: Color(0xffff9900),),
),
Text(
'${quantities[index]}'
),
IconButton(
onPressed: (){
setState(() {
if(quantities[index] > 0){
double oldPrice = (quantities[index] * price[index].price).toDouble();
quantities[index] = quantities[index] - 1;
double newPrice = (quantities[index] * price[index].price).toDouble();
totalPrices[index] = newPrice.toDouble();
currentTotalPrice = (currentTotalPrice - oldPrice).toDouble();
currentTotalPrice = (currentTotalPrice + newPrice).toDouble();
}
DoNothingAction();
});
},
icon: Icon(Icons.remove , color: Color(0xffff9900),),
),
//ends here
//
//
//
],
),
)
],
)
)
)
],
),
],
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: DeviceInformation(context).width,
child: RaisedButton(
onPressed: currentTotalPrice <= 0.0 ? null
: (){
for(int i = 0; i < servicesLength; i++){
savePurchase(
article['id'],
serviceIds[i],
quantities[i],
totalPrices[i],
);
}
return _customStoredSuccessfully(context);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
color: Color(0xffff9900),
child: Text(
translator.currentLanguage == 'ar' ?
'اضافة ${currentTotalPrice.toStringAsFixed(2)} الى الطلب'
: 'Add ${currentTotalPrice.toStringAsFixed(2)} To Order',
style: TextStyle(color: Colors.white),
),
),
),
)
],
)
);
}
if(snapshot.hasError){
return SomeThingWrongHappened();
}
return LoadingIndicator();
},
);
},
);
}
);
}
void showPricingSheet(上下文、文章){
清单数量=[];
列表serviceIds=[];
列出总价格=[];
双倍电流总价=0.0;
国际服务长度;
//这些变量将用于本地存储值,然后将它们发送到服务器
未来价格=(第['id'条]);
bool-alreadyExc=false;
showModalBottomSheet(
isDismissible:错误,
形状:圆形矩形边框(
borderRadius:borderRadius.vertical(
顶部:半径。圆形(20),
),
),
上下文:上下文,
生成器:(BuildContext上下文){
var ResponsivesController=ResponsivesController(上下文);
返回状态生成器(
生成器:(BuildContext上下文,setState){
回归未来建设者(
未来:_价格,
生成器:(上下文,快照){
if(snapshot.hasData){
标价=snapshot.data;
如果(alreadyExc==false){
//使用提供的长度初始化列表
服务长度=price.length;
对于(int i=0;i
划船(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
扩大(
子:容器(
填充:边缘设置。全部(10),
子:文本(
translator.currentLanguage==“ar”?
“${price[index].servicenamer}”
:“${price[index].serviceNameEn}”,
溢出:TextOverflow.省略号,
样式:TextStyle(
fontSize:ResponsenessController.bodyFont1,
),
),
),
),
文本(${price[index].price}),
样式:TextStyle(
fontSize:ResponsenessController.bodyFont1,
),
),
容器(
孩子:排(
儿童:[
//问题就在这一部分
//
//
//
//
图标按钮(
已按下:(){
设置状态(){
double oldPrice=(数量[指数]*价格[指数].price).toDouble();
数量[索引]=数量[索引]+1;
double newPrice=(数量[指数]*价格[指数].price).toDouble();
totalPrices[指数]=newPrice.toDouble();
currentTotalPrice=(currentTotalPrice-oldPrice).toDouble();
currentTotalPrice=(currentTotalPrice+newPrice).toDouble();
});
},
图标:图标(Icons.add,颜色:color(0xffff9900)),
),
正文(
“${数量[索引]}”
),
图标按钮(
已按下:(){