AppbarWidget.story constructor

AppbarWidget.story(
  1. BuildContext context, {
  2. Key? key,
  3. String? title,
  4. Function? onSave,
  5. Widget? icon,
  6. Function? onDelete,
  7. Function? onClose,
})

Implementation

AppbarWidget.story(
  BuildContext context, {
  super.key,
  String? title,
  Function? onSave,
  Widget? icon,
  Function? onDelete,
  Function? onClose,
}) : super(
        backgroundColor: Theme.of(context).colorScheme.surface,
        leading: IconButton(
          icon: icon ??
              Icon(
                Icons.arrow_back_ios,
                color: Theme.of(context).colorScheme.secondary,
                size: 24,
              ),
          onPressed: () {
            onClose?.call();
            Navigator.pop(context);
          },
        ),
        title: Text(
          title ?? ' ',
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.w600,
            color: Theme.of(context).colorScheme.secondary,
          ),
        ),
        actions: <Widget>[
          if (onSave != null)
            TextButton(
              onPressed: () {
                onSave();
                Navigator.pop(context);
              },
              child: Text(
                'Save',
                style: TextStyle(
                    fontSize: 16, color: Theme.of(context).primaryColor),
              ),
            ),
          if (onDelete != null)
            IconButton(
              onPressed: onDelete as void Function()?,
              icon: const Icon(
                Icons.delete_forever,
                color: Colors.red,
              ),
            ),
          const SizedBox(width: 20)
        ],
      );