import 'package:flutter/material.dart';
class ImageDisplayScreen extends StatelessWidget {
const ImageDisplayScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Image Display Screen')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Asset Image:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
Image.asset('assets/flutter_logo.png', height: 150, fit: BoxFit.contain),
const SizedBox(height: 20),
const Text('Network Image:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
Image.network('https://flutter.dev/assets/images/shared/brand/flutter/logo/flutter-lockup.png', height: 150, fit: BoxFit.contain),
],
),
),
);
}
}
We use a Column to arrange the widgets vertically. Each image is preceded by a Text widget as a label. The asset image is loaded using Image.asset with the path assets/flutter_logo.png. The network image is loaded using Image.network with the Flutter logo URL. Both images have a fixed height of 150 pixels and use BoxFit.contain to keep their aspect ratio without distortion. Spacing is added using SizedBox widgets for a clean layout.
Remember to add the asset image file flutter_logo.png to your project's assets folder and declare it in pubspec.yaml under flutter/assets.