<script setup lang="ts">
const clear = (names: Map<string, number>) => {
// ...
};
</script>
<template>
<Child1
:clear="clear" />
<Child2
:clear="clear" />
</template>
<script setup lang="ts">
const props = defineProps<{
clear: (names: Map<string, number>) => void
}>();
const names: Map<string, number> = ref(new Map<string, number>());
</script>
<template>
<button @click="clear(names)">Очистить</button>
</template>
<div class="navbar bg-base-100">
<div class="navbar-start">
<div class="dropdown">
<div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16" /></svg>
</div>
<ul tabindex="0" class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52">
<li><a>Item 1</a></li>
<li>
<a>Parent</a>
<ul class="p-2">
<li><a>Submenu 1</a></li>
<li><a>Submenu 2</a></li>
</ul>
</li>
<li><a>Item 3</a></li>
</ul>
</div>
<a class="btn btn-ghost text-xl">daisyUI</a>
</div>
<div class="navbar-center hidden lg:flex">
<ul class="menu menu-horizontal px-1">
<li><a>Item 1</a></li>
<li>
<details>
<summary>Parent</summary>
<ul class="p-2">
<li><a>Submenu 1</a></li>
<li><a>Submenu 2</a></li>
</ul>
</details>
</li>
<li><a>Item 3</a></li>
</ul>
</div>
<div class="navbar-end">
<a class="btn">Button</a>
</div>
</div>
class ContactItem extends StatefulWidget {
final Contact contact;
final bool isAllChecked;
const ContactItem({super.key, required this.contact, required this.isAllChecked});
@override
State<ContactItem> createState() => _ContactItem(this.contact, this.isAllChecked);
}
class _ContactItem extends State<ContactItem> {
final Contact contact;
final bool isAllChecked;
bool isChecked = false;
_ContactItem(this.contact, this.isAllChecked);
@override
void initState() {
super.initState();
}
@override
void didUpdateWidget(ContactItem oldWidget) {
print(contact.id);
super.didUpdateWidget(oldWidget);
}
@override
Widget build(BuildContext context) {
return CheckboxListTile(
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = !isChecked;
});
},
title: Text('${contact.name}'),
subtitle: Text('${contact.id}'),
controlAffinity: ListTileControlAffinity.leading,
);
}
}
Widget contactsList() {
return Expanded(
child: Center(
child: isLoaded ? (_filteredContactsList.isNotEmpty ? ListView(
children: [
for (Contact contact in _filteredContactsList)
ContactItem(contact: contact, isAllChecked: isAllChecked,)
// contactItem(contact)
],
) : Text('Контактов нет')) : Text('Идет загрузка...'),
),
);
}
Ref<Map<string, number>>
- наверно так)