View stanica

PHOTO EMBED

Wed May 18 2022 11:55:09 GMT+0000 (Coordinated Universal Time)

Saved by @Vesko_devv #dart

class HomeView extends GetView<HomeController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('ListView Filter'),
        centerTitle: true,
      ),
      body: Padding(
        padding: const EdgeInsets.all(10),
        child: Column(
          children: [
            const SizedBox(
              height: 20,
            ),
            TextField(
             onChanged: (value) => controller.filterPlayer(value), //slanje value iz filtera 
              decoration: const InputDecoration(
                labelText: 'Search',
                suffixIcon: Icon(Icons.search),
              ),
            ),
            const SizedBox(
              height: 20,
            ),
            Expanded(
              child: Obx(
                () => ListView.builder(
                  itemCount: controller.foundPlayers.value.length, // da nam prikaze duzinu
                  itemBuilder: (context, index) => ListTile( 
                    title: Text(
                      controller.foundPlayers.value[index]['name'], // sta vadimo iz liste
                      style:
                          TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
                    ),
                    subtitle:
                      Text(controller.foundPlayers.value[index]['country']),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
content_copyCOPY