Rafiullah Rahimi
Rafiullah Rahimi

Reputation: 1

Unable to load assets "assets/images/me.png" flutter using dart framework

[1. create directory : "assets" 2. create directory images inside "assets" and then put in image into it "me.png"

  1. modify pubspec.ymal : flutter: uses-material-design: true assets:

`

import 'package:flutter/material.dart';

void main() {
  runApp(
    const MyApp(),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SafeArea(
        child: Scaffold(
          backgroundColor: Colors.blue,
          body: Center(
            child: Image.asset('assets/images/me.png'),
          ),
        ),
      ),
    );
  }
}

Upvotes: 0

Views: 24

Answers (1)

Harsh
Harsh

Reputation: 41

Here is the solution:

You have to modify pubspec.yaml

assets:
  - assets/images/me.png

Upvotes: 0

Related Questions