fix: auto expand again after reorder app

This commit is contained in:
appflowy 2022-04-28 16:30:04 +08:00
parent ecd2dc3e72
commit 0285b286a6
2 changed files with 8 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import 'section/section.dart';
class MenuApp extends StatefulWidget {
final App app;
MenuApp(this.app, {Key? key}) : super(key: ValueKey(app.hashCode));
const MenuApp(this.app, {Key? key}) : super(key: key);
@override
State<MenuApp> createState() => _MenuAppState();
@ -95,6 +95,11 @@ class _MenuAppState extends State<MenuApp> {
);
}
@override
void didUpdateWidget(covariant MenuApp oldWidget) {
super.didUpdateWidget(oldWidget);
}
@override
void dispose() {
viewDataContext.dispose();

View File

@ -108,7 +108,7 @@ class HomeMenu extends StatelessWidget {
child: ScrollConfiguration(
behavior: const ScrollBehavior().copyWith(scrollbars: false),
child: BlocSelector<MenuBloc, MenuState, List<Widget>>(
selector: (state) => state.apps.map((app) => MenuApp(app)).toList(),
selector: (state) => state.apps.map((app) => MenuApp(app, key: ValueKey(app.id))).toList(),
builder: (context, menuItems) {
return ReorderableListView.builder(
itemCount: menuItems.length,
@ -128,7 +128,7 @@ class HomeMenu extends StatelessWidget {
physics: StyledScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return ReorderableDragStartListener(
key: ValueKey(menuItems[index].hashCode),
key: ValueKey(menuItems[index].key),
index: index,
child: Padding(
padding: EdgeInsets.symmetric(vertical: MenuAppSizes.appVPadding / 2),