簡體   English   中英

沒有為“MyApp”類型定義此方法“Scaffold”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM