- μ΄λ―Έμ§λ₯Ό νμνλ μμ ―
- μ§μλλ μ΄λ―Έμ§ νμ : JPEG, PNG, GIF, μ λλ©μ΄μ GIF, WebP, μ λλ©μ΄μ WebP, BMP λ° WBMP
const Image({ Key? key, required this.image, this.frameBuilder, this.loadingBuilder, this.errorBuilder, this.semanticLabel, this.excludeFromSemantics = false, this.width, this.height, this.color, this.colorBlendMode, this.fit, this.alignment = Alignment.center, this.repeat = ImageRepeat.noRepeat, this.centerSlice, this.matchTextDirection = false, this.gaplessPlayback = false, this.isAntiAlias = false, this.filterQuality = FilterQuality.low, }) : assert(image != null), assert(alignment != null), assert(repeat != null), assert(filterQuality != null), assert(matchTextDirection != null), assert(isAntiAlias != null), super(key: key);
- width, height : μ΄λ―Έμ§μ κ°λ‘, μΈλ‘ ν¬κΈ°
- fit : μνλ 곡κ°μ μ΄λ―Έμ§κ° λ€μ΄λ§λλ‘ νλ μμ±
- alignment : μ΄λ―Έμ§ μ λ ¬
- semanticLabel : μ΄λ―Έμ§λ₯Ό μ€λͺ νλ μκ°κΈ
- Image.asset() : μ±μ μ μ₯λ λμμ λμ΄μ μ΄λ―Έμ§λ₯Ό λμ => λ€λ₯Έ λ²μ Όλ€μ μ μ₯ν΄ pubspec.yaml μμ λμ΄νλ©΄ λ¨
- Image.file() : μ¬μ©μ μ₯μΉμμ μ΄λ―Έμ§λ₯Ό κ°μ Έμμ λμ
- Image. memory() : λ©λͺ¨λ¦¬μ μ μ₯λ μ΄λ―Έμ§λ₯Ό λ°μ΄νΈ λ°°μ΄λ‘ λνλΌ λ
- Image.network() : URLμμ μ΄λ―Έμ§λ₯Ό κ°μ Έμ λμ => Flutterκ° μ΄λ―Έμ§ νμΌμ λ€μ΄λ‘λν΄μ μΊμλ₯Ό μ μ₯νκ³ νλ©΄μ λμ
import 'package:flutter/material.dart';
import 'package:file/file.dart';
void main() => runApp(MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
debugShowCheckedModeBanner: false,
home: ImageWidget(),
);
}
}
class ImageWidget extends StatefulWidget {
_ImageWidgetState createState() => _ImageWidgetState();
}
class _ImageWidgetState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(25.0),
child: ListView(
children: [
Text(
"image asset μ΄μ©",
style: TextStyle(fontSize: 25),
),
Image.asset(
'assets/IMG_0239.jpeg',
fit: BoxFit.cover,
),
SizedBox(height: 2),
Text(
"image network μ΄μ©",
style: TextStyle(fontSize: 25),
),
Image.network(
'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg',
fit: BoxFit.cover,
),
SizedBox(height: 2),
Text(
"image file μ΄μ© - μΆν μμ μμ ",
style: TextStyle(fontSize: 25),
),
SizedBox(height: 2),
Text(
"image memory μ΄μ© - μΆν μμ μμ ",
style: TextStyle(fontSize: 25),
),
SizedBox(height: 2),
],
),
),
),
);
}
}