Selam Arkadaşlar,
aranıza yeni katıldım ve flutter ogrenmeye calısıyorum… kendimce birşeyler yapmaya calısıyorum,bir yerde tıkandım.Bu konuda bana yardımcı olabilirmisiniz?
deneme 1 alt kısımda yere tıkladıgım zaman listview ile json data üzerinden local yada internet üzerinden veriyi oraya yazdırmak istiyorum,yardımcı olabilirseniz memnun olurum.
Kod Kısmı:
import ‘package:flutter/material.dart’;
import ‘dart:convert’;
void main() => runApp(MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = ‘Flutter Code Sample’;
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
title: _title,
home: MyStatefulWidget(),
);
}
}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
late List<Widget> _widgetOptions;
get body => null;
@override
void initState() {
super.initState();
final bucket = PageStorageBucket();
_widgetOptions = <Widget>[
PageStorage(
bucket: bucket,
child: ListView(
key: PageStorageKey<String>(‘0’),
children: <Widget>[
Text(
‘Sismograf’,
style: optionStyle,
),
],
),
),
PageStorage(
bucket: bucket,
child: ListView(
key: PageStorageKey<String>(‘1’),
children: <Widget>[
ListTile(
title: Text(“dd1”),
subtitle: Text(“alt”),
),
ListTile(
title: Text(“ddd”),
subtitle: Text(“alt”),
),
],
),
),
PageStorage(
bucket: bucket,
child: ListView(
key: PageStorageKey<String>(‘2’),
children: <Widget>[
Image(
image: AssetImage(‘images/seviye.png’),
width: 600,
height: 600,
),
],
)),
PageStorage(
bucket: bucket,
child: ListView(
key: PageStorageKey<String>(‘3’),
children: <Widget>[
Text(
‘Contact\n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Please contact us if you have any questions or feature requests at info@test.com \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Deneme(s) \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Deneme \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Deneme \n\n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Deneme(s) \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Deneme \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘Legal \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘ * All intellectual property rights are reserved. \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘ * This application is designed to wake you up during the initial shakes of a potential earthquake.’
‘However, it does not guarantee that it will save your life nor wake you up. \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
Text(
‘ * Updates are received from USGS Earthquake Hazards Program and their web site www.earthquake.usgs.gov \n’,
style: TextStyle(color: Colors.white.withOpacity(0.8)),
),
],
),
),
];
}
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xfff505051),
appBar: AppBar(
centerTitle: true,
title: Text(‘Deneme’),
backgroundColor: Color(0xfff353535),
),
body: Center(
child: widgetOptions.elementAt(selectedIndex),
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: ‘Deneme’,
backgroundColor: Colors.red),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: ‘Deneme1’,
backgroundColor: Colors.red),
BottomNavigationBarItem(
icon: Icon(Icons.school),
label: ‘Deneme2’,
backgroundColor: Colors.red),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: ‘Deneme3’,
backgroundColor: Colors.red),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
);
}
}