Skip to content

Commit

Permalink
Change _DashboardPageFAB from StatefulWidget to StatelessWidget (
Browse files Browse the repository at this point in the history
…#1123)

The widget `_DashboardPageFAB` was a `StatefulWidget` but never used
`setState` or similar. It could also maybe fix the [issue with the
context](https://console.firebase.google.com/u/0/project/sharezone-c2bd8/crashlytics/app/ios:de.codingbrain.sharezone.app/issues/03874eb9a8392a1e6308fa7f3c040db2)
that we have tracked in Crashlytics.

Related to: flutter/flutter#135389
  • Loading branch information
nilsreichardt authored Oct 11, 2023
1 parent 0c60138 commit b0c4c97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/lib/dashboard/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _DashboardPageState extends State<DashboardPage> {
),
navigationItem: NavigationItem.overview,
body: const DashboardPageBody(),
floatingActionButton: _DashboardPageFAB(),
floatingActionButton: const _DashboardPageFAB(),
);
}
}
Expand Down
41 changes: 18 additions & 23 deletions app/lib/dashboard/widgets/dashboard_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,10 @@ part of '../dashboard_page.dart';

enum _DashboardFabResult { homework, exam, event, lesson, blackboard }

class _DashboardPageFAB extends StatefulWidget {
@override
_DashboardPageFABState createState() => _DashboardPageFABState();
}

class _DashboardPageFABState extends State<_DashboardPageFAB> {
bool open = false;
class _DashboardPageFAB extends StatelessWidget {
const _DashboardPageFAB();

@override
Widget build(BuildContext context) {
return MatchingTypeOfUserBuilder(
expectedTypeOfUser: TypeOfUser.parent,
matchesTypeOfUserWidget: Container(),
notMatchingWidget: ModalFloatingActionButton(
heroTag: 'sharezone-fab',
tooltip: 'Neue Elemente hinzufügen',
label: 'Hinzufügen',
icon: const Icon(Icons.add),
onPressed: () => openDashboardFabSheet(context),
),
);
}

Future<void> openDashboardFabSheet(BuildContext buildContext) async {
Future<void> openDashboardFabSheet(BuildContext context) async {
final analytics = DashboardAnalytics(Analytics(getBackend()));
analytics.logOpenFabSheet();

Expand Down Expand Up @@ -70,6 +50,21 @@ class _DashboardPageFABState extends State<_DashboardPageFAB> {
break;
}
}

@override
Widget build(BuildContext context) {
return MatchingTypeOfUserBuilder(
expectedTypeOfUser: TypeOfUser.parent,
matchesTypeOfUserWidget: Container(),
notMatchingWidget: ModalFloatingActionButton(
heroTag: 'sharezone-fab',
tooltip: 'Neue Elemente hinzufügen',
label: 'Hinzufügen',
icon: const Icon(Icons.add),
onPressed: () => openDashboardFabSheet(context),
),
);
}
}

class _DashboardFabSheet extends StatelessWidget {
Expand Down

0 comments on commit b0c4c97

Please sign in to comment.