db_username_suggester 1.0.0+1 copy "db_username_suggester: ^1.0.0+1" to clipboard
db_username_suggester: ^1.0.0+1 copied to clipboard

A Flutter package for suggesting alternative usernames when a given username already exists in the database. This package helps ensure unique usernames by automatically generating and suggesting avail [...]

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:db_username_suggester/db_username_suggester.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Username Plugin example app'),
        ),
        body:Padding(
          padding: const EdgeInsets.only(left: 10,right: 10),
          child: Column(
            children: [
              DbUsernameSuggesterField(
                label: "Username",
                validator: (value) {
                  if (value == null || value.isEmpty) {
                    return 'Please enter a username';
                  }
                  return null;
                },
                checkUsernameInDb: (username) async {
                  /// Replace with your logic to check if the username exists in the DB
                  if(username.isNotEmpty && username=='username'){
                    return Future.value(true);
                  }
                  else
                  {
                    return Future.value(false);
                  }
                },
                textCapitalization: TextCapitalization.none,
                onChange: (value) {
                  if (kDebugMode) {
                    print('Username changed: $value');
                  }
                },
                borderRadius: BorderRadius.circular(10),
                hintText: "Please Enter Username.",
                hintTextStyle: TextStyle(fontSize: 12,fontWeight: FontWeight.w400,color: Colors.black.withOpacity(0.5)),
                borderColor: Colors.green,
                errorText: "Please Enter username for checking user name is exist or not",
              ),
            ],
          ),
        )
      ),
    );
  }
}
1
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for suggesting alternative usernames when a given username already exists in the database. This package helps ensure unique usernames by automatically generating and suggesting available alternatives based on the initial username input. It's designed to work seamlessly across all supported platforms, including iOS, Android, and web.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, gap

More

Packages that depend on db_username_suggester