import 'package:flutter/material.dart'; class StorageAction extends StatelessWidget { const StorageAction({ super.key, required this.label, required this.onPressed, this.destructive = false, }); final String label; final VoidCallback? onPressed; final bool destructive; @override Widget build(BuildContext context) => TextButton( onPressed: onPressed, style: destructive ? TextButton.styleFrom( foregroundColor: Theme.of(context).colorScheme.error, ) : null, child: Text(label), ); } class StorageSwitch extends StatelessWidget { const StorageSwitch({ super.key, required this.label, required this.value, required this.onChanged, }); final String label; final bool value; final ValueChanged? onChanged; @override Widget build(BuildContext context) => Row( children: [ Expanded(child: Text(label)), Semantics( label: label, child: Switch(value: value, onChanged: onChanged), ), ], ); } class StorageInput extends StatelessWidget { const StorageInput({ super.key, required this.label, required this.controller, required this.onChanged, required this.enabled, this.decimal = false, }); final String label; final TextEditingController controller; final ValueChanged onChanged; final bool enabled; final bool decimal; @override Widget build(BuildContext context) { final keyboard = TextInputType.numberWithOptions(decimal: decimal); return TextField( controller: controller, enabled: enabled, keyboardType: keyboard, onChanged: onChanged, decoration: InputDecoration( labelText: label, hintText: 'No limit', border: const OutlineInputBorder(), ), ); } } Widget storagePadding(Widget child) => Padding(padding: const EdgeInsets.all(16), child: child);