参数“ body”未定义

时间:2019-05-28 20:48:13

标签: android flutter dart

Compiler message:
lib/main.dart:12:11: Error: No named parameter with the name 'body'.
          body: Image(
          ^^^^
import 'package:flutter/material.dart';

//main fuction is the starting point for all our apps.
void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.blueGrey[150],
        appBar: AppBar(
          title: Text('I Am Rich'),
          backgroundColor: Colors.deepOrange,
          body: Image(
            image:
                NetworkImage('https://www.w3schools.com/w3css/img_lights.jpg'),
          ),
        ),
      ),
    ),
  );
}

1 个答案:

答案 0 :(得分:1)

bodyScaffold的参数,而不是AppBar

     Scaffold(
            backgroundColor: Colors.blueGrey[150],
            appBar: AppBar(
              title: Text('I Am Rich'),
              backgroundColor: Colors.deepOrange,

            ),
            body: Image(
                image:
                    NetworkImage('https://www.w3schools.com/w3css/img_lights.jpg'),
              ),
          ),

此处有更多信息:https://api.flutter.dev/flutter/material/Scaffold-class.html