listbox test

This commit is contained in:
Kevin-Bauer
2022-12-15 15:24:29 +01:00
parent 6b5b51d035
commit 7e9fd3b5c1
2 changed files with 52 additions and 3 deletions
+46
View File
@@ -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'),
),
],
);
}
}
+6 -3
View File
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'NewsItem.dart';
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title}); const MyHomePage({super.key, required this.title});
@@ -151,11 +153,12 @@ class _MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 0; int _selectedIndex = 0;
static const TextStyle optionStyle = static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold); TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[ static /*const*/ List<Widget> _widgetOptions = <Widget>[
Text( /*Text(
'Index 0: News', 'Index 0: News',
style: optionStyle, style: optionStyle,
), ),*/
NewsList(),
Text( Text(
'Index 1: Mängel', 'Index 1: Mängel',
style: optionStyle, style: optionStyle,