Answers for "how to load image from asssets in flutter"

0

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
        ),
      );
    }
  }
Posted by: Guest on May-29-2021

Code answers related to "how to load image from asssets in flutter"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language