![](/img/trans.png)
[英]trying to run flutter program and keep getting this error "the method 'HomeScreen' isn't defined for the type 'MyApp'
[英]This method 'Scaffold' isn't defined for the type 'MyApp'
我已將顫振和 Android Studio 重新安裝到我的設備上,之后 Scaffold 小部件無法正常工作。 它說“沒有為類型'MyApp'定義這個方法'Scaffold'”
使用MaterialApp小部件添加 wrap Scaffold
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: const Text('Welcome to Flutter'),
),
body: const Center(
child: Text('Hello World'),
),
),
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.