Assets - wurzelsand/flutter-memos GitHub Wiki
Assets
Images
../pubspec.yaml
../images/penguin.png
Ausführung
pubspec.yaml:
name: untitled
description: A new Flutter project.
...
flutter:
...
uses-material-design: true
...
assets:
- images/penguin.png
...
main.dart:
import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(home: Scaffold(body: ExampleWidget())));
}
class ExampleWidget extends StatelessWidget {
const ExampleWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Image(image: AssetImage('images/penguin.png'));
}
}