generateOTPVerification static method

String generateOTPVerification(
  1. String projectName
)

Implementation

static String generateOTPVerification(String projectName) {
  return '''
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:$projectName/shared/widgets/widgets.dart';

class OTPVerificationScreen extends StatefulWidget {
final String? phoneNumber;

const OTPVerificationScreen({
  Key? key,
  this.phoneNumber,
}) : super(key: key);

@override
State<OTPVerificationScreen> createState() => _OTPVerificationScreenState();
}

class _OTPVerificationScreenState extends State<OTPVerificationScreen> {
bool _isLoading = false;

Future<void> _verifyOTP(String otp) async {
  setState(() => _isLoading = true);

  // TODO: Implement OTP verification logic here
  await Future.delayed(const Duration(seconds: 2));

  if (mounted) {
    setState(() => _isLoading = false);
    context.go('/');
  }
}

@override
Widget build(BuildContext context) {
  final theme = Theme.of(context);
  final size = MediaQuery.of(context).size;
  final isTablet = size.width > 600;

  return Scaffold(
    appBar: AppBar(
      leading: IconButton(
        icon: const Icon(Icons.arrow_back),
        onPressed: () => context.pop(),
      ),
    ),
    body: SafeArea(
      child: Center(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(24),
          child: ConstrainedBox(
            constraints: BoxConstraints(maxWidth: isTablet ? 400 : double.infinity),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Icon(Icons.message, size: 80, color: theme.colorScheme.primary),
                const SizedBox(height: 24),
                Text('Verify OTP', style: theme.textTheme.displaySmall, textAlign: TextAlign.center),
                const SizedBox(height: 8),
                Text(
                  'Enter the 6-digit code sent to\\n\${widget.phoneNumber ?? 'your phone'}',
                  style: theme.textTheme.bodyMedium,
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 48),
                OTPInput(
                  length: 6,
                  onCompleted: _verifyOTP,
                ),
                const SizedBox(height: 32),
                if (_isLoading)
                  const Center(child: CircularProgressIndicator())
                else
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text("Didn't receive code?", style: theme.textTheme.bodyMedium),
                      TextButton(
                        onPressed: () {},
                        child: const Text('Resend'),
                      ),
                    ],
                  ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}
}
''';
}