Advertisement
BlackBoY_

Pertemuan 7 Guided

Apr 25th, 2022
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.83 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.   runApp(MyApp());
  5. }
  6.  
  7. class MyApp extends StatefulWidget {
  8.   @override
  9.   State<MyApp> createState() => _MyAppState();
  10. }
  11.  
  12. class _MyAppState extends State<MyApp> {
  13.   static const TEXT_STYLE_NORMAL = const TextStyle(
  14.     color: Colors.black,fontSize: 18, fontWeight: FontWeight.normal
  15.   );
  16.  
  17.   static const TEXT_STYLE_SELECTED = const TextStyle(
  18.     color: Colors.black,fontSize: 18, fontWeight: FontWeight.bold
  19.   );
  20.  
  21.   int _selectedIndex = 0;
  22.  
  23.   select(index){
  24.     setState(() {
  25.       _selectedIndex = index;
  26.     });
  27.   }
  28.  
  29.   @override
  30.   Widget build(BuildContext context) {
  31.     return MaterialApp(
  32.       home: Scaffold(
  33.         appBar: AppBar(title: Text("Latihan Listview"),),
  34.         body: ListView(
  35.           children: [
  36.             ListTile(
  37.               leading: Icon(Icons.accessibility),
  38.               title: Text("Accessibility", style: _selectedIndex == 1 ? TEXT_STYLE_SELECTED : TEXT_STYLE_NORMAL),
  39.               subtitle: Text("Accessibility Settings"),
  40.               trailing: Icon(Icons.settings),
  41.               onTap: ()=> select(1) ,
  42.             ),
  43.             ListTile(
  44.               leading: Icon(Icons.history),
  45.               title: Text("History", style: _selectedIndex == 2 ? TEXT_STYLE_SELECTED : TEXT_STYLE_NORMAL),
  46.               subtitle: Text("History Setting"),
  47.               trailing: Icon(Icons.settings),
  48.               onTap: ()=> select(2) ,
  49.             ),
  50.             ListTile(
  51.               leading: Icon(Icons.language),
  52.               title: Text("Language", style: _selectedIndex == 3 ? TEXT_STYLE_SELECTED : TEXT_STYLE_NORMAL),
  53.               subtitle: Text("Language Setting"),
  54.               trailing: Icon(Icons.settings),
  55.               onTap: ()=> select(3) ,
  56.             ),
  57.           ],
  58.         ),
  59.       ),
  60.      
  61.     );
  62.   }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement