Home > Mobile >  hey guys am new to flutter and dart and I need help. I was following a tutorial and I have this prob
hey guys am new to flutter and dart and I need help. I was following a tutorial and I have this prob

Time:10-05

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home:Scaffold(
        backgroundColor: Colors.blueGrey,
        appBar:AppBar(
          title: Text("I am rich"),
              backgroundColor: Colors.blueGrey[900],
        )
      // ignore: prefer_const_constructors
      body: Image(
          image: NetworkImage('https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png')

      )
      ),
    ),
  );
}

CodePudding user response:

import 'package:flutter/material.dart';

void main() {
 runApp(
  MaterialApp(
  home:Scaffold(
    backgroundColor: Colors.blueGrey,
    appBar:AppBar(
      title: Text("I am rich"),
          backgroundColor: Colors.blueGrey[900],
    ), //I edited. you add , this point *********
  // ignore: prefer_const_constructors
  body: Image(
      image: NetworkImage('https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png')

      )
    ),
  ),
 );
}

CodePudding user response:

You are missing a "," at your AppBar

    appBar:AppBar(
      title: Text("I am rich"),
          backgroundColor: Colors.blueGrey[900],
    ), // This comma is missing

In analysis_options.yaml you can add require_trailing_commas: true (experimental) to your linter options, this will force you to use comma's everywhere and will make your code more legible in the long run.

CodePudding user response:

Your Answer is

void main() {
  runApp(
    MaterialApp(
      home:Scaffold(
        backgroundColor: Colors.blueGrey,
        appBar:AppBar(
          title: Text("I am rich"),
              backgroundColor: Colors.blueGrey[900],
        ),
      // ignore: prefer_const_constructors
      body: Image(
          image: NetworkImage('https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png')

      )
      ),
    ),
  );
}

Just Copy And Paste The Code That I Have Added

CodePudding user response:

Try below code you miss the , before body I think you refer AppBar Widget Image

  • Related