Skip to content

TypeScript code snippet – How to load image from asssets in flutter?

// Edit pubspec.yaml file
      - assets/images/

// in class_name.dart file get image like this
  import 'package:flutter/material.dart';

  void main() => runApp(MyApp());

  class MyApp extends StatelessWidget {
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: Text("Image from assets"),
          body: Image.asset('assets/images/lake.jpg'), //   <--- image
See also  PHP code snippet - How to keep some value on input field?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.