mail_check 0.0.1 copy "mail_check: ^0.0.1" to clipboard
mail_check: ^0.0.1 copied to clipboard

outdated

A Flutter package for both android, iOS and web. which provides email validate and make email suggestion.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:mail_check/mail_check.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MailCheck Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      debugShowCheckedModeBanner: false,
      home: const MyHomePage(title: 'MailCheck Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController controller = TextEditingController();
  String _message = "";

  void _checkEmail() {
    var email = controller.value.text;
    MailCheck.run(email, callBack: (response) {
      var message = "$email is a valid email";
      if (response.isValidEmail) {
        if (response.suggestion != null) {
          message =
              "Are you sure with email: $email\nSuggestion: ${response.suggestion?.fullEmail}";
        }
      } else {
        message = "$email is an invalid email";
      }
      setState(() {
        _message = message;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              const SizedBox(
                height: 50,
              ),
              Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(16),
                ),
                child: TextField(
                  controller: controller,
                  decoration: const InputDecoration(
                    hintStyle: TextStyle(fontSize: 17),
                    hintText: 'Email',
                    prefixIcon: Icon(Icons.email),
                    // suffixIcon: Icon(Icons.search),
                    border: InputBorder.none,
                    contentPadding: EdgeInsets.all(20),
                  ),
                ),
              ),
              const SizedBox(
                height: 10,
              ),
              TextButton(
                onPressed: () {
                  _checkEmail();
                },
                child: const Text('Tap to check'),
              ),
              const SizedBox(
                height: 10,
              ),
              Text(
                _message,
              ),
            ],
          ),
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
12
likes
0
points
85
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for both android, iOS and web. which provides email validate and make email suggestion.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on mail_check