Dart 分析工具列
當我在 Android Studio 中撰寫這段代碼時,我的飛鏢分析工具列中出現了這樣的內容: 我撰寫的代碼 如何防止這種情況發生?
uj5u.com熱心網友回復:
您缺少一個)括號,請在分號之前添加它。
此鏈接解釋了關于位置和命名引數。而且您嘗試的程序不是一個好習慣。您需要分解小部件,以便更容易維護。
嘗試如下:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: const Text('I am rich'),
backgroundColor: Colors.blueGrey[900],
),
body: Center(
child: Image.asset('images/diamond.png'),
),
),
);
}
}
uj5u.com熱心網友回復:
最后在分號前加一個括號
uj5u.com熱心網友回復:
用這個替換你MaterialApp的:
MaterialApp(
title: 'SaHomeDecor',
home: Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: Text('I am rich'),
backgroundColor: Colors.blueGrey[900],
),
body: Center(
child: Image.asset('images/diamond.png'),
),
),
);
如果您正在使用AppBar,則必須提供Scaffold.appBar類似Scaffold(appBar:AppBar()).
對于影像,您必須使用Scaffold.body屬性。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/441087.html
上一篇:AndroidStudio-將模擬器與作業室本身分開
下一篇:如何將一列字符更改為日期形式?
