static 파일 경로 지정하기

개요


../../ 와 같이 상대경로가 아닌
assets/images/a.jpg 와 같이 경로를 지정할떄

pubspec.yaml


notion image
위와 같이 경로만 지정해놓으면 끝

사용예제


const String _imagePath = 'assets/images'; class _Image extends AssetImage { const _Image(String fileName) : super('$_imagePath/$fileName'); } class AppImages { static const test = _Image('test.png'); } AppImages.test // assets/images/test.png
댓글 0

등록된 댓글이 하나도 없습니다...😢