appBarWeebiUpdateNotSaved function

PreferredSizeWidget appBarWeebiUpdateNotSaved(
  1. String title, {
  2. Color? backgroundColor,
  3. List<Widget>? actions,
  4. String pushThatRouteInstead = '',
})

Implementation

PreferredSizeWidget appBarWeebiUpdateNotSaved(String title,
    {Color? backgroundColor,
    List<Widget>? actions,
    String pushThatRouteInstead = ''}) {
  return AppBar(
    backgroundColor: backgroundColor,
    leading: Builder(
      builder: (BuildContext context) {
        return IconButton(
          tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
          icon: const Icon(Icons.arrow_back),
          onPressed: () async {
            final isSureAboutQuitting =
                await AskDialog.areYouSureUpdateNotSaved(context);
            if (isSureAboutQuitting) {
              if (pushThatRouteInstead.isNotEmpty) {
                Navigator.of(context).popAndPushNamed(pushThatRouteInstead);
              } else {
                Navigator.of(context).pop();
              }
            }
          },
        );
      },
    ),
    title: Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Text(title, textAlign: TextAlign.start),
      ],
    ),
    actions: actions ?? [],
  );
}