Final push for today. Listen mit text und bildern inklusive ausgabe auf der gui
This commit is contained in:
@@ -1,46 +0,0 @@
|
|||||||
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'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class UserDefinedItem extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String description;
|
||||||
|
final Image image;
|
||||||
|
|
||||||
|
const UserDefinedItem({super.key,
|
||||||
|
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: [
|
||||||
|
UserDefinedItem(
|
||||||
|
title: 'Rosalia Kapelle',
|
||||||
|
description: 'Kapelle bei der Ausfahrt von Oggau',
|
||||||
|
image: Image.network('https://upload.wikimedia.org/wikipedia/commons/d/d7/Oggau_Rosaliakapelle.JPG'),
|
||||||
|
),
|
||||||
|
|
||||||
|
UserDefinedItem(
|
||||||
|
title: 'Gemeinde Amt Oggau',
|
||||||
|
description: 'Gemeide Amt der Marktgemeinde Oggau. SPÖ regierend',
|
||||||
|
image: Image.network('https://upload.wikimedia.org/wikipedia/commons/a/a1/Oggau_am_Neusiedler_See_-_Gemeindeamt_%2801%29.jpg'),
|
||||||
|
),
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IssueList extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListView(
|
||||||
|
children: [
|
||||||
|
UserDefinedItem(
|
||||||
|
title: 'Licht ausgebrannt',
|
||||||
|
description: 'Licht ist ausgebrannt in der Sebastianstraße',
|
||||||
|
image: Image.network('https://www.best-of-burgenland.com/assets/img/gemeinden/oggau/oggau_feuerwehr_2022-04-12_003.jpg'),
|
||||||
|
),
|
||||||
|
|
||||||
|
UserDefinedItem(
|
||||||
|
title: 'test2',
|
||||||
|
description: 'Gemeide Amt der Marktgemeinde Oggau. SPÖ regierend',
|
||||||
|
image: Image.network('https://upload.wikimedia.org/wikipedia/commons/a/a1/Oggau_am_Neusiedler_See_-_Gemeindeamt_%2801%29.jpg'),
|
||||||
|
),
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-145
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'NewsItem.dart';
|
import 'UserDefinedList.dart';
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({super.key, required this.title});
|
const MyHomePage({super.key, required this.title});
|
||||||
@@ -10,160 +10,19 @@ class MyHomePage extends StatefulWidget {
|
|||||||
@override
|
@override
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
State<MyHomePage> createState() => _MyHomePageState();
|
||||||
}
|
}
|
||||||
//Da haben wir letztes mal gemacht aber ich weiß jetzt nicht warum es nicht funktioniert
|
|
||||||
//??????
|
|
||||||
/*class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _selectedIndex = 0;
|
|
||||||
static final List<Widget> _widgetOptions = <Widget>
|
|
||||||
[
|
|
||||||
Table(border: TableBorder.all(),
|
|
||||||
columnWidths:const<
|
|
||||||
|
|
||||||
int, TableColumnWidth>{
|
|
||||||
0: IntrinsicColumnWidth(),
|
|
||||||
1: FlexColumnWidth(),
|
|
||||||
2: FixedColumnWidth(64),
|
|
||||||
},
|
|
||||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
|
||||||
children: <TableRow>[
|
|
||||||
TableRow(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
height: 32,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
|
||||||
TableCell(
|
|
||||||
verticalAlignment: TableCellVerticalAlignment.top,
|
|
||||||
child: Container(
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
color: Colors.red,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 64,
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
TableRow(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
height: 64,
|
|
||||||
width: 128,
|
|
||||||
color: Colors.purple,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 32,
|
|
||||||
color: Colors.yellow,
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = index;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
/*
|
|
||||||
child: Column(
|
|
||||||
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
const Text(
|
|
||||||
'Knopfdruck:',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'$_counter',
|
|
||||||
style: Theme.of(context).textTheme.headline4,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),*/
|
|
||||||
child: _widgetOptions.elementAt(_selectedIndex),
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: _incrementCounter,
|
|
||||||
tooltip: 'Increment',
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomAppBar(
|
|
||||||
color: const Color(0xFF1601FD),
|
|
||||||
child: IconTheme(
|
|
||||||
data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'News',
|
|
||||||
icon: const Icon(Icons.newspaper),
|
|
||||||
onPressed: /*() {}*/() => _onItemTapped(0),
|
|
||||||
),
|
|
||||||
//if (centerLocations.contains(fabLocation)) const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Mängel',
|
|
||||||
icon: const Icon(Icons.warning),
|
|
||||||
onPressed: () => /*{_pushMangel()}*/ _onItemTapped(1),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Profil',
|
|
||||||
icon: const Icon(Icons.person),
|
|
||||||
onPressed: () => /*{_pushProfile()}*/ _onItemTapped(2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
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*/ final List<Widget> _widgetOptions = <Widget>[
|
||||||
/*Text(
|
/*Text(
|
||||||
'Index 0: News',
|
'Index 0: News',
|
||||||
style: optionStyle,
|
style: optionStyle,
|
||||||
),*/
|
),*/
|
||||||
NewsList(),
|
NewsList(),
|
||||||
Text(
|
IssueList(),
|
||||||
'Index 1: Mängel',
|
const Text(
|
||||||
style: optionStyle,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Index 2: Profil',
|
'Index 2: Profil',
|
||||||
style: optionStyle,
|
style: optionStyle,
|
||||||
)
|
)
|
||||||
|
|||||||
-363
@@ -21,366 +21,3 @@ class MyApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
const MyHomePage({super.key, required this.title});
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*class ProfilePage extends StatefulWidget {
|
|
||||||
const ProfilePage({super.key, required this.title});
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ProfilePage> createState() => _ProfilePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MangelPage extends StatefulWidget {
|
|
||||||
const MangelPage({super.key, required this.title});
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MangelPage> createState() => _MangelPageState();
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _selectedIndex = 0;
|
|
||||||
static const List<Widget> _widgetOptions = <Widget>[
|
|
||||||
ListView(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
height: 50,
|
|
||||||
color: Colors.amber[600],
|
|
||||||
child: const Center(child: Text('Entry A')),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 50,
|
|
||||||
color: Colors.amber[500],
|
|
||||||
child: const Center(child: Text('Entry B')),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 50,
|
|
||||||
color: Colors.amber[100],
|
|
||||||
child: const Center(child: Text('Entry C')),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
Text(
|
|
||||||
'Index 1: Mängel',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Index 2: Profil',
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = index;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* void _pushMangel(){
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const MangelPage(title: 'Mängel'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _pushProfile(){
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const ProfilePage(title: 'Profil'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
/*
|
|
||||||
child: Column(
|
|
||||||
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
const Text(
|
|
||||||
'Knopfdruck:',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'$_counter',
|
|
||||||
style: Theme.of(context).textTheme.headline4,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),*/
|
|
||||||
child: _widgetOptions.elementAt(_selectedIndex),
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: _incrementCounter,
|
|
||||||
tooltip: 'Increment',
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomAppBar(
|
|
||||||
color: const Color(0xFF1601FD),
|
|
||||||
child: IconTheme(
|
|
||||||
data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'News',
|
|
||||||
icon: const Icon(Icons.newspaper),
|
|
||||||
onPressed: /*() {}*/() => _onItemTapped(0),
|
|
||||||
),
|
|
||||||
//if (centerLocations.contains(fabLocation)) const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Mängel',
|
|
||||||
icon: const Icon(Icons.warning),
|
|
||||||
onPressed: () => /*{_pushMangel()}*/ _onItemTapped(1),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Profil',
|
|
||||||
icon: const Icon(Icons.person),
|
|
||||||
onPressed: () => /*{_pushProfile()}*/ _onItemTapped(2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
class _ProfilePageState extends State<ProfilePage> {
|
|
||||||
|
|
||||||
void _pushMangel(){
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const MangelPage(title: 'Mängel'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _pushNews(){
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
|
|
||||||
child: Column(
|
|
||||||
),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomAppBar(
|
|
||||||
color: const Color(0xFF1601FD),
|
|
||||||
child: IconTheme(
|
|
||||||
data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'News',
|
|
||||||
icon: const Icon(Icons.newspaper),
|
|
||||||
onPressed: () => {_pushNews()},
|
|
||||||
),
|
|
||||||
//if (centerLocations.contains(fabLocation)) const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Mängel',
|
|
||||||
icon: const Icon(Icons.warning),
|
|
||||||
onPressed: () => {_pushMangel()},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Profil',
|
|
||||||
icon: const Icon(Icons.person),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MangelPageState extends State<MangelPage> {
|
|
||||||
|
|
||||||
void _pushProfile(){
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const ProfilePage(title: 'Profil'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _pushNews(){
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
|
|
||||||
child: Column(
|
|
||||||
),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomAppBar(
|
|
||||||
color: const Color(0xFF1601FD),
|
|
||||||
child: IconTheme(
|
|
||||||
data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'News',
|
|
||||||
icon: const Icon(Icons.newspaper),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
//if (centerLocations.contains(fabLocation)) const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Mängel',
|
|
||||||
icon: const Icon(Icons.warning),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: 'Profil',
|
|
||||||
icon: const Icon(Icons.person),
|
|
||||||
onPressed: () => {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html
|
|
||||||
/*
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
void main() => runApp(const MyApp());
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
const MyApp({super.key});
|
|
||||||
|
|
||||||
static const String _title = 'Flutter Code Sample';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const MaterialApp(
|
|
||||||
title: _title,
|
|
||||||
home: MyStatefulWidget(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyStatefulWidget extends StatefulWidget {
|
|
||||||
const MyStatefulWidget({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
|
||||||
int _selectedIndex = 0;
|
|
||||||
static const TextStyle optionStyle =
|
|
||||||
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
|
||||||
static const List<Widget> _widgetOptions = <Widget>[
|
|
||||||
Text(
|
|
||||||
'Index 0: Home',
|
|
||||||
style: optionStyle,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Index 1: Business',
|
|
||||||
style: optionStyle,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Index 2: School',
|
|
||||||
style: optionStyle,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Index 3: Settings',
|
|
||||||
style: optionStyle,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = index;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('BottomNavigationBar Sample'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: _widgetOptions.elementAt(_selectedIndex),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
|
||||||
items: const <BottomNavigationBarItem>[
|
|
||||||
BottomNavigationBarItem(
|
|
||||||
icon: Icon(Icons.home),
|
|
||||||
label: 'Home',
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
|
||||||
icon: Icon(Icons.business),
|
|
||||||
label: 'Business',
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
|
||||||
icon: Icon(Icons.school),
|
|
||||||
label: 'School',
|
|
||||||
backgroundColor: Colors.purple,
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
|
||||||
icon: Icon(Icons.settings),
|
|
||||||
label: 'Settings',
|
|
||||||
backgroundColor: Colors.pink,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
currentIndex: _selectedIndex,
|
|
||||||
selectedItemColor: Colors.amber[800],
|
|
||||||
onTap: _onItemTapped,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user