import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.lightGreen), useMaterial3: true, ), home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { List<_CardData> data = [ _CardData( textData: "250x150 picture", imageUrl: "https://loremflickr.com/250/150/kitty"), _CardData( textData: "200x250 picture", imageUrl: "https://loremflickr.com/200/250/kitty"), _CardData( textData: "200x200 picture", imageUrl: "https://loremflickr.com/200/200/kitty"), _CardData( textData: "100x150 picture", imageUrl: "https://loremflickr.com/100/150/kitty"), _CardData( textData: "300x150 picture", imageUrl: "https://loremflickr.com/350/150/kitty"), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text( 'Item list', ), ), body: SingleChildScrollView( child: Column( children: data.map((d) => _Card.withData(d)).toList(), ), )); } } class _CardData { final String textData; final String imageUrl; const _CardData({required this.textData, required this.imageUrl}); } class _Card extends StatelessWidget { final String text; final String imageUrl; const _Card({required this.text, required this.imageUrl}); factory _Card.withData(_CardData d) => _Card( text: d.textData, imageUrl: d.imageUrl, ); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: Container( margin: EdgeInsets.all(5.0), padding: EdgeInsets.all(8.0), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 3, offset: const Offset(0, 2), blurRadius: 4) ], color: Theme.of(context).colorScheme.inversePrimary, borderRadius: BorderRadius.circular(20)), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( borderRadius: BorderRadius.circular(20), child: SizedBox( width: 150, height: 150, child: Image.network( imageUrl == "" ? "https://loremflickr.com/150/150?random=1" : imageUrl, fit: BoxFit.cover, ), ), ), Expanded( child: Padding( padding: const EdgeInsets.only(left: 16.0, top: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( text, style: Theme.of(context).textTheme.headlineSmall, ), Text( "This is card with picture and text", style: Theme.of(context).textTheme.labelSmall, ), ], ), ), ) ], )), ); } }