image from assed in flutter code example
Example: how to load image from asssets in flutter
// Edit pubspec.yaml file
flutter:
assets:
- assets/images/
// in class_name.dart file get image like this
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Image from assets"),
),
body: Image.asset('assets/images/lake.jpg'), // <--- image
),
);
}
}