Search

Add Assets

Add image, fonts, and assets files to the project
This instruction guides users to add image, fonts, and other external asset files to the Flutter project.
Instruction [pubspec.yaml]
1.
Move to the project directory
2.
Create asset folder on root directory
3.
Press Pub get
4.
Open ~/pubspec.yaml
// ~/pubspec.yaml flutter: uses-material-design: true assets: # add assets: and define the folder or file to add - asset/img/ fonts: # add fonts: define family and weight - family: NotoSans fonts: - asset: asset/fonts/NotoSansKR-Black.otf weight: 900 - asset: asset/fonts/NotoSansKR-Bold.otf weight: 700 - asset: asset/fonts/NotoSansKR-Medium.otf weight: 500 - asset: asset/fonts/NotoSansKR-Regular.otf weight: 400 - asset: asset/fonts/NotoSansKR-Light.otf weight: 300 - asset: asset/fonts/NotoSansKR-Thin.otf weight: 100
YAML
복사
5.
Open main.dart
// main.dart import 'package:flutter/material.dart'; void main() { runApp( _App(), ); } class _App extends StatelessWidget { const _App({Key? key}) : super(key: key); Widget build(BuildContext context) { return MaterialApp( // add theme here theme: ThemeData( fontFamily: 'NotoSans', ), debugShowCheckedModeBanner: false, home: HomeScreen(), ), ); } }
Dart
복사

Reference