diff --git a/lib/NewsItem.dart b/lib/NewsItem.dart new file mode 100644 index 0000000..c5fb387 --- /dev/null +++ b/lib/NewsItem.dart @@ -0,0 +1,46 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; + +class NewsItem extends StatelessWidget { + final String title; + final String description; + final Image image; + + NewsItem({ + required this.title, + required this.description, + required this.image, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: image, + title: Text(title), + subtitle: Text(description), + ); + } +} + + +class NewsList extends StatelessWidget { + @override + Widget build(BuildContext context) { + return ListView( + children: [ + NewsItem( + title: 'News Title 1', + description: 'This is the description for news item 1.', + image: Image.file('C:\\Users\\kevin\\StudioProjects\\demoapp_1\\android\\app\\src\\main\\play_store_512.png') + //network('https://example.com/image1.jpg'), + ), + NewsItem( + title: 'News Title 2', + description: 'This is the description for news item 2.', + image: Image.network('https://example.com/image2.jpg'), + ), + ], + ); + } +} diff --git a/lib/home.dart b/lib/home.dart index 3feae26..c277503 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'NewsItem.dart'; + class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); @@ -151,11 +153,12 @@ class _MyHomePageState extends State { int _selectedIndex = 0; static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); - static const List _widgetOptions = [ - Text( + static /*const*/ List _widgetOptions = [ + /*Text( 'Index 0: News', style: optionStyle, - ), + ),*/ + NewsList(), Text( 'Index 1: Mängel', style: optionStyle,