■ Import 키워드를 사용해 파일을 임포트하는 방법을 보여준다.
▶ ImagePage.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import 'package:flutter/material.dart'; class ImagePage extends StatefulWidget { @override State<StatefulWidget> createState() { return _ImagePageState(); } } class _ImagePageState extends State<ImagePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Test Application'), ), body: Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'image/flutter.png', width: 200, height: 200, fit: BoxFit.fill, ), ], ), ) ), ); } } |
▶ MainPage.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import 'package:flutter/material.dart'; import 'imagePage.dart'; void main() { runApp(TestApplication()); } class TestApplication extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Test Application', theme: ThemeData( primarySwatch: Colors.blue, ), home: ImagePage(), ); } } |