我在Flutter上写的代码昨天还可以,今天就黑屏了
The code I wrote on Flutter was working yesterday, but today it just gives a black screen
我在Flutter上写的代码昨天还可以,今天就黑屏了。我不明白。我正在学习并且没有任何错误地执行此操作非常烦人。 199 / 5,000
输入这些部分是因为需要有关 post 的更多详细信息。它仍然在等待我进一步解释这个问题。黑屏了,不知道怎么解释。
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
bool _valuehidra = true;
bool _valuelight = true;
bool _valuewebasto = true;
bool _valueusb = true;
bool _valuealter = true;
void main() {
runApp(const MaterialApp(
));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_State createState() => _State();
}
class _State extends State<MyApp> {
bool isSwitched = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.fromLTRB(10, 30, 0, 0),
child: Image.asset('assets/images/logoisim.png', height: 125.0, fit: BoxFit.cover,),
),
],
),
Container(
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 20),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('AYDINLATMA', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuelight,
onChanged: (value) {
setState(() {
_valuelight = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('WEBASTO', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuewebasto,
onChanged: (value) {
setState(() {
_valuewebasto = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('HİDRAFOR', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuehidra,
onChanged: (value) {
setState(() {
_valuehidra = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('ALTERNATÖR', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuealter,
onChanged: (value) {
setState(() {
_valuealter = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('USB (12V)', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valueusb,
onChanged: (value) {
setState(() {
_valueusb = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 90,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 30),
child: Image.asset('assets/images/caravan.png', height: 40.0, fit: BoxFit.cover,),
),
Container(
margin: const EdgeInsets.only(left: 10),
alignment: Alignment.center,
child: const Text('KARAVANIM', style: TextStyle(color: Colors.white, fontSize: 31,fontFamily: 'YesevaOne' )),
),
Container(
margin: const EdgeInsets.only(left: 10),
child: Image.asset('assets/images/caravan2.png', height: 40.0, fit: BoxFit.cover,),
),
],
),
),
],
),
),
);
}
}
您不是 运行 MyApp
小部件,而是 MaterialApp
void main() {
runApp(const MyApp(
));
}
将 void main 更改为这些
void main(){
runApp(MyApp())
}
我在Flutter上写的代码昨天还可以,今天就黑屏了。我不明白。我正在学习并且没有任何错误地执行此操作非常烦人。 199 / 5,000
输入这些部分是因为需要有关 post 的更多详细信息。它仍然在等待我进一步解释这个问题。黑屏了,不知道怎么解释。
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
bool _valuehidra = true;
bool _valuelight = true;
bool _valuewebasto = true;
bool _valueusb = true;
bool _valuealter = true;
void main() {
runApp(const MaterialApp(
));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_State createState() => _State();
}
class _State extends State<MyApp> {
bool isSwitched = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.fromLTRB(10, 30, 0, 0),
child: Image.asset('assets/images/logoisim.png', height: 125.0, fit: BoxFit.cover,),
),
],
),
Container(
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 20),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('AYDINLATMA', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuelight,
onChanged: (value) {
setState(() {
_valuelight = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('WEBASTO', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuewebasto,
onChanged: (value) {
setState(() {
_valuewebasto = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('HİDRAFOR', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuehidra,
onChanged: (value) {
setState(() {
_valuehidra = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('ALTERNATÖR', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valuealter,
onChanged: (value) {
setState(() {
_valuealter = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 70,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
SizedBox(width: 200,
child: Container(
margin: const EdgeInsets.only(left: 30),
alignment: Alignment.centerLeft,
child: const Text('USB (12V)', style: TextStyle(color: Colors.white, fontSize: 25,fontFamily: 'YesevaOne' )),
),
),
Transform.scale( scale: 1.3,
child: Container(
margin: const EdgeInsets.only(left:50),
child: CupertinoSwitch(
value: _valueusb,
onChanged: (value) {
setState(() {
_valueusb = value;
});
},
),
),
),
],
),
),
Container(
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(30.0),
),
width: 350,
height: 90,
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 30),
child: Image.asset('assets/images/caravan.png', height: 40.0, fit: BoxFit.cover,),
),
Container(
margin: const EdgeInsets.only(left: 10),
alignment: Alignment.center,
child: const Text('KARAVANIM', style: TextStyle(color: Colors.white, fontSize: 31,fontFamily: 'YesevaOne' )),
),
Container(
margin: const EdgeInsets.only(left: 10),
child: Image.asset('assets/images/caravan2.png', height: 40.0, fit: BoxFit.cover,),
),
],
),
),
],
),
),
);
}
}
您不是 运行 MyApp
小部件,而是 MaterialApp
void main() {
runApp(const MyApp(
));
}
将 void main 更改为这些
void main(){
runApp(MyApp())
}