صحح الكود التالي
await showDialog(
  context: context,
  builder: (context) {
    return Directionality(
      textDirection: TextDirection.rtl,
      child: Dialog(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(24),
        elevation: 8,
        child: ConstrainedBox(
          constraints: BoxConstraints(
            maxWidth: MediaQuery.of(context).size.width * 0.9,
            maxHeight: MediaQuery.of(context).size.height * 0.8,
          ),
          child: SingleChildScrollView(
            child: Container(
              padding: const EdgeInsets.all(24),
              decoration: BoxDecoration(
                color: Theme.of(context).colorScheme.surface,
                borderRadius: BorderRadius.circular(24),
              ),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  // Header
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      IconButton(
                        icon: Icon(
                          Icons.close,
                          color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
                        onPressed: () => Navigator.pop(context),
                      ),
                      Text(
                        'المحفظة الرقمية',
                        style: TextStyle(
                          fontFamily: tajawalFont,
                          fontSize: 20,
                          fontWeight: FontWeight.bold,
                          color: Theme.of(context).colorScheme.primary,
                        ),
                      ),
                      Icon(
                        Icons.account_balance_wallet_rounded,
                        color: Theme.of(context).colorScheme.primary,
                      ),
                    ],
                  ),
                  
                  const SizedBox(height: 24),
                  
                  // Amount Cards Grid
                  if (_savedAmounts.isNotEmpty)
                    GridView.builder(
                      shrinkWrap: true,
                      physics: const NeverScrollableScrollPhysics(),
                      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        mainAxisSpacing: 12,
                        crossAxisSpacing: 12,
                        childAspectRatio: 1.8,
                      ),
                      itemCount: _savedAmounts.length,
                      itemBuilder: (context, index) {
                        final amt = _savedAmounts[index];
                        return Container(
                          decoration: BoxDecoration(
                            color: Theme.of(context).colorScheme.primaryContainer,
                            borderRadius: BorderRadius.circular(16),
                          ),
                          padding: const EdgeInsets.all(12),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Row(
                                mainAxisAlignment: MainAxisAlignment.start,
                                children: [
                                  IconButton(
                                    icon: Icon(
                                      Icons.delete_outline,
                                      size: 20,
                                      color: Theme.of(context).colorScheme.error,
                                    ),
                                    onPressed: () {
                                      setState(() {
                                        _savedAmounts.removeAt(index);
                                      });
                                    },
                                  ),
                                ],
                              ),
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text(
                                    'المبلغ',
                                    style: TextStyle(
                                      fontFamily: tajawalFont,
                                      fontSize: 12,
                                      color: Theme.of(context).colorScheme.onPrimaryContainer.withOpacity(0.8),
                                    ),
                                  ),
                                  Text(
                                    '${_formatWithThousandsSeparator(amt)} ريال',
                                    style: TextStyle(
                                      fontFamily: tajawalFont,
                                      fontSize: 18,
                                      fontWeight: FontWeight.bold,
                                      color: Theme.of(context).colorScheme.onPrimaryContainer,
                                    ),
                                  ),
                                ],
                              ),
                            ],
                          ),
                        );
                      },
                    )
                  else
                    Container(
                      padding: const EdgeInsets.symmetric(vertical: 32),
                      child: Column(
                        children: [
                          Icon(
                            Icons.wallet_outlined,
                            size: 48,
                            color: Theme.of(context).colorScheme.onSurface.withOpacity(0.3),
                          ),
                          const SizedBox(height: 16),
                          Text(
                            'لا توجد مبالغ محفوظة',
                            style: TextStyle(
                              fontFamily: tajawalFont,
                              color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
                            ),
                          ),
                          const SizedBox(height: 8),
                          Text(
                            'قم بإضافة مبالغك المفضلة',
                            style: TextStyle(
                              fontFamily: tajawalFont,
                              fontSize: 12,
                              color: Theme.of(context).colorScheme.onSurface.withOpacity(0.4),
                            ),
                          ),
                        ],
                      ),
                    ),
                  
                  const SizedBox(height: 24),
                  
                  // Add Amount Section
                  Container(
                    decoration: BoxDecoration(
                      color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.1),
                      borderRadius: BorderRadius.circular(16),
                    ),
                    padding: const EdgeInsets.all(16),
                    child: Column(
                      children: [
                        TextField(
                          controller: amountsController,
                          keyboardType: TextInputType.number,
                          inputFormatters: [ThousandsSeparatorInputFormatter()],
                          style: TextStyle(
                            fontFamily: tajawalFont,
                            fontSize: 16,
                            color: Theme.of(context).colorScheme.onSurface,
                          ),
                          decoration: InputDecoration(
                            hintText: 'أدخل المبلغ',
                            hintStyle: TextStyle(
                              fontFamily: tajawalFont,
                              color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
                            ),
                            prefixIcon: Icon(
                              Icons.attach_money_rounded,
                              color: Theme.of(context).colorScheme.primary,
                            ),
                            suffixText: 'ريال سعودي',
                            suffixStyle: TextStyle(
                              fontFamily: tajawalFont,
                              color: Theme.of(context).colorScheme.primary,
                            ),
                            border: OutlineInputBorder(
                              borderRadius: BorderRadius.circular(12),
                              borderSide: BorderSide.none,
                            ),
                            filled: true,
                            fillColor: Theme.of(context).colorScheme.surface,
                          ),
                          onChanged: (value) {
                            setState(() {});
                          },
                          onSubmitted: (value) {
                            if (isValidInput(value)) {
                              addAmount(value, () {});
                            }
                          },
                        ),
                        const SizedBox(height: 16),
                        SizedBox(
                          width: double.infinity,
                          child: FilledButton.icon(
                            onPressed: isValidInput(amountsController.text)
                                ? () => addAmount(amountsController.text, () {})
                                : null,
                            icon: const Icon(Icons.add),
                            label: const Text(
                              'إضافة إلى المحفظة',
                              style: TextStyle(fontFamily: tajawalFont),
                            ),
                            style: FilledButton.styleFrom(
                              padding: const EdgeInsets.symmetric(vertical: 16),
                              shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(12),
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  
                  const SizedBox(height: 16),
                  
                  // Save Button
                  SizedBox(
                    width: double.infinity,
                    child: ElevatedButton(
                      onPressed: () async {
                        await _saveSavedAmounts();
                        Navigator.pop(context);
                        _showSnackBar('تم تحديث المحفظة بنجاح');
                      },
                      style: ElevatedButton.styleFrom(
                        backgroundColor: Theme.of(context).colorScheme.primary,
                        padding: const EdgeInsets.symmetric(vertical: 16),
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(12),
                        ),
                      ),
                      child: Text(
                        'حفظ التغييرات',
                        style: TextStyle(
                          fontFamily: tajawalFont,
                          color: Theme.of(context).colorScheme.onPrimary,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  },
);
واجعلة يعمل بنفس عمل هذا الكود
await showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: const Text(
            'إدارة المبالغ المحفوظة',
            style: TextStyle(fontFamily: tajawalFont),
            textAlign: TextAlign.center,
          ),
          content: StatefulBuilder(
            builder: (context, setDialogState) {
              return SizedBox(
                width: double.maxFinite,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    if (_savedAmounts.isEmpty)
                      Padding(
                        padding: const EdgeInsets.symmetric(vertical: 12),
                        child: Text(
                          'لا توجد مبالغ محفوظة حالياً',
                          style: Theme.of(
                            context,
                          ).textTheme.bodyMedium?.copyWith(
                            fontFamily: tajawalFont,
                            color:
                                Theme.of(context).colorScheme.onSurfaceVariant,
                          ),
                        ),
                      ),
                    if (_savedAmounts.isNotEmpty)
                      Container(
                        constraints: BoxConstraints(maxHeight: 150),
                        child: SingleChildScrollView(
                          child: Wrap(
                            spacing: 8,
                            runSpacing: 6,
                            children:
                                _savedAmounts
                                    .map(
                                      (amt) => Tooltip(
                                        message: 'حذف هذا المبلغ',
                                        child: Chip(
                                          label: Text(
                                            _formatWithThousandsSeparator(amt),
                                            style: const TextStyle(
                                              fontFamily: tajawalFont,
                                              fontWeight: FontWeight.w600,
                                            ),
                                          ),
                                          backgroundColor:
                                              Theme.of(
                                                context,
                                              ).colorScheme.primaryContainer,
                                          shape: RoundedRectangleBorder(
                                            borderRadius: BorderRadius.circular(
                                              20,
                                            ),
                                          ),
                                          onDeleted: () {
                                            setDialogState(() {
                                              _savedAmounts.remove(amt);
                                            });
                                          },
                                          deleteIconColor:
                                              Theme.of(
                                                context,
                                              ).colorScheme.error,
                                        ),
                                      ),
                                    )
                                    .toList(),
                          ),
                        ),
                      ),
                    const Divider(height: 25, thickness: 1),
                    TextField(
                      controller: amountsController,
                      keyboardType: TextInputType.number,
                      inputFormatters: [ThousandsSeparatorInputFormatter()],
                      decoration: InputDecoration(
                        labelText: 'إضافة مبلغ جديد',
                        suffixIcon: IconButton(
                          icon: const Icon(Icons.add_circle_rounded),
                          tooltip: 'إضافة المبلغ',
                          onPressed:
                              isValidInput(amountsController.text)
                                  ? () => addAmount(
                                    amountsController.text,
                                    setDialogState,
                                  )
                                  : null,
                        ),
                      ),
                      onChanged: (value) {
                        setDialogState(() {}); // لتحديث زر الإضافة
                      },
                      onSubmitted: (value) {
                        addAmount(value, setDialogState);
                      },
                    ),
                  ],
                ),
              );
            },
          ),
          actionsAlignment: MainAxisAlignment.spaceBetween,
          actions: [
            TextButton(
              onPressed: () => Navigator.pop(context),
              child: const Text(
                'إغلاق',
                style: TextStyle(fontFamily: tajawalFont),
              ),
            ),
            FilledButton.tonal(
              onPressed: () async {
                await _saveSavedAmounts();
                Navigator.pop(context);
                _showSnackBar('تم حفظ المبالغ بنجاح');
              },
              child: const Text(
                'حفظ',
                style: TextStyle(fontFamily: tajawalFont),
              ),
            ),
          ],
        );
      },
    );