@@ -580,6 +580,18 @@ class _AllocationProfileTableState extends State<_AllocationProfileTable> {
580580 @override
581581 void initState () {
582582 super .initState ();
583+ _initColumns ();
584+ }
585+
586+ @override
587+ void didUpdateWidget (covariant _AllocationProfileTable oldWidget) {
588+ super .didUpdateWidget (oldWidget);
589+ if (oldWidget.controller != widget.controller) {
590+ _initColumns ();
591+ }
592+ }
593+
594+ void _initColumns () {
583595 _pinColumn = _PinColumn (controller: widget.controller);
584596 _columns = < ColumnData <ProfileRecord >> [
585597 _pinColumn,
@@ -607,33 +619,26 @@ class _AllocationProfileTableState extends State<_AllocationProfileTable> {
607619 if (profile == null ) {
608620 return const CenteredCircularProgressIndicator ();
609621 }
610- return ValueListenableBuilder <Set <String >>(
611- valueListenable: widget.controller.pinnedClassFullNames,
612- builder: (context, pinnedClassFullNames, _) {
613- return ValueListenableBuilder <bool >(
614- valueListenable: preferences.advancedDeveloperModeEnabled,
615- builder: (context, advancedDeveloperModeEnabled, _) {
616- return FlatTable <ProfileRecord >(
617- keyFactory: (element) => Key (element.heapClass.fullName),
618- data: profile.records,
619- dataKey:
620- 'allocation-profile-${pinnedClassFullNames .length }-'
621- '${pinnedClassFullNames .toList ()..sort ()}' ,
622- columnGroups: advancedDeveloperModeEnabled
623- ? _AllocationProfileTableState ._vmModeColumnGroups
624- : null ,
625- columns: [
626- ..._columns,
627- if (advancedDeveloperModeEnabled)
628- ..._advancedDeveloperModeColumns,
629- ],
630- defaultSortColumn: _AllocationProfileTableState ._fieldSizeColumn,
631- defaultSortDirection: SortDirection .descending,
632- pinBehavior: FlatTablePinBehavior .pinOriginalToTop,
633- includeColumnGroupHeaders: false ,
634- selectionNotifier: widget.controller.selection,
635- );
636- },
622+ return ValueListenableBuilder <bool >(
623+ valueListenable: preferences.advancedDeveloperModeEnabled,
624+ builder: (context, advancedDeveloperModeEnabled, _) {
625+ return FlatTable <ProfileRecord >(
626+ keyFactory: (element) => Key (element.heapClass.fullName),
627+ data: profile.records,
628+ dataKey: 'allocation-profile' ,
629+ columnGroups: advancedDeveloperModeEnabled
630+ ? _AllocationProfileTableState ._vmModeColumnGroups
631+ : null ,
632+ columns: [
633+ ..._columns,
634+ if (advancedDeveloperModeEnabled)
635+ ..._advancedDeveloperModeColumns,
636+ ],
637+ defaultSortColumn: _AllocationProfileTableState ._fieldSizeColumn,
638+ defaultSortDirection: SortDirection .descending,
639+ pinBehavior: FlatTablePinBehavior .pinOriginalToTop,
640+ includeColumnGroupHeaders: false ,
641+ selectionNotifier: widget.controller.selection,
637642 );
638643 },
639644 );
0 commit comments