Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatefulWidget {
- @override
- State<MyApp> createState() => _MyAppState();
- }
- class _MyAppState extends State<MyApp> {
- static const TEXT_STYLE_NORMAL = const TextStyle(
- color: Colors.black,fontSize: 18, fontWeight: FontWeight.normal
- );
- static const TEXT_STYLE_SELECTED = const TextStyle(
- color: Colors.black,fontSize: 18, fontWeight: FontWeight.bold
- );
- int _selectedIndex = 0;
- select(index){
- setState(() {
- _selectedIndex = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- appBar: AppBar(title: Text("Latihan Listview"),),
- body: ListView(
- children: [
- ListTile(
- leading: Icon(Icons.accessibility),
- title: Text("Accessibility", style: _selectedIndex == 1 ? TEXT_STYLE_SELECTED : TEXT_STYLE_NORMAL),
- subtitle: Text("Accessibility Settings"),
- trailing: Icon(Icons.settings),
- onTap: ()=> select(1) ,
- ),
- ListTile(
- leading: Icon(Icons.history),
- title: Text("History", style: _selectedIndex == 2 ? TEXT_STYLE_SELECTED : TEXT_STYLE_NORMAL),
- subtitle: Text("History Setting"),
- trailing: Icon(Icons.settings),
- onTap: ()=> select(2) ,
- ),
- ListTile(
- leading: Icon(Icons.language),
- title: Text("Language", style: _selectedIndex == 3 ? TEXT_STYLE_SELECTED : TEXT_STYLE_NORMAL),
- subtitle: Text("Language Setting"),
- trailing: Icon(Icons.settings),
- onTap: ()=> select(3) ,
- ),
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement