Flutter plugin for Phone Number Hint Api on Android, provides a frictionless way to show a user's (SIM-based) phone numbers as a hint.
import com.technikb.phone_hint_android.PhoneHintAndroidMethodCallHandler
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterFragmentActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
PhoneHintAndroidMethodCallHandler.register(flutterEngine, this)
}
}
- Replace FlutterActivity with FlutterFragmentActivity
- Add PhoneHintAndroidMethodCallHandler.register(flutterEngine, this) in configureFlutterEngine method
Example usage:
final phoneNumber = await PhoneHintAndroid().getPhoneNumber();
- No additional permission requests are needed
- Eliminates the need for the user to manually type in the phone number
- No Google account is needed
- Not directly tied to sign in/up workflows
- Wider support for Android versions compared to Autofill
Utilised Google's Phone Number Hint Api
You can support phone_hint_android by liking it on Pub and staring it on Github, sharing ideas on how we can enhance a certain functionality or by reporting any problems you encounter.