Untitled

 avatar
unknown
plain_text
2 years ago
2.4 kB
17
Indexable
FutureBuilder(
            future: controller.dbHelper!.getCreditCards(),
            builder: (BuildContext context,
                AsyncSnapshot<List<CreditCard>> snapshot) {
              if (!snapshot.hasData) return const CircularProgressIndicator();
              if (snapshot.data!.isEmpty) {
                return const Text("Your contact list empty");
              }
              return ListView.builder(
                  shrinkWrap: true,
                  padding: EdgeInsets.zero,
                  itemCount: snapshot.data!.length,
                  itemBuilder: (BuildContext context, int index) {
                    CreditCard creditCard = snapshot.data![index];
                    return Padding(
                      padding: AppPadding.guideLine,
                      child: Card(
                        color: controller.selectedCardValue.value == index
                            ? Colors.orange
                            : Colors.white,
                        child: Theme(
                          data: ThemeData(
                            unselectedWidgetColor:
                                controller.selectedCardValue.value == index
                                    ? Colors.white
                                    : Colors.orange,
                          ),
                          child: RadioListTile<int>(
                            toggleable: true,
                            value: index,
                            groupValue: controller.selectedCardValue.value,
                            activeColor: Colors.white,
                            title: Text(
                              snapshot.data![index].cardNumber!
                                  .replaceAll(RegExp(r'[^\s](?=.{4})'), '*'),
                              style: appTextStyle.getCreditCardFont_Size16(
                                controller.selectedCardValue.value == index
                                    ? Colors.white
                                    : Colors.grey,
                              ),
                            ),
                            onChanged: (value) {
                              controller.selectedCardValue.value = value!;
                              controller.update();
                            },
                          ),
                        ),
                      ),
                    );
                  });
            },
          ),
Editor is loading...