问题描述
我的代码遇到了一个新问题,老实说,我不知道我的错误在哪里,我在另一个文件中制作了完全相同的小部件,并且运行正常。 我开始相信某些小部件可能存在一个问题。
我粘贴了我的代码,以便您可以检查出来并告诉我我的错误在哪里(很常见),或者是某些小部件/代码行破坏了代码。
import 'package:Flutter/material.dart';
void main(List<String> args) {
runApp(MaterialApp(
home: Scaffold(
body: Products(),),));
}
class Products extends StatefulWidget {
Products({Key key}) : super(key: key);
@override
_Productsstate createState() => _Productsstate();
}
Class _Productsstate extends State<Products> {
@override
Widget build(BuildContext context) {
bool valoractual;
@override
void initState() {
super.initState();
valoractual = false;
}
return Scaffold(
appBar: AppBar(
backgroundColor: Color.fromrGBO(239,180,185,1),actions: <Widget>[
Icon(
Icons.search,size: 25,Switch(
activeColor: Colors.white,inactiveThumbColor: Colors.blue[900],value: valoractual,onChanged: (bool cambio) {
setState(() {
valoractual = cambio;
});
//cambiovalor();
if (valoractual) {
showDialog(
context: context,barrierdismissible: false,builder: (context) => AlertDialog(
content: Text(" delete option"),actions: [
FlatButton(
onpressed: () {
print("****************");
print(valoractual);
Navigator.of(context).pop();
return valoractual;
},child: Text("Continue"),)
],);
} else {
showDialog(
context: context,builder: (context) => AlertDialog(
content:
Text("view option"),actions: [
FlatButton(
onPreenter code heressed: () {
print("****************");
print(valoractual);
Navigator.of(context).pop();
return valoractual;
},child: Text("Aceptar"),);
}
},Icon(Icons.delete,size: 20),],body: Container(
margin: EdgeInsets.only(top: 10),child: Text("this is sample text"),);
}
}