AbdulRahmanAlHamali / flutter_typeahead

A TypeAhead widget for Flutter, where you can show suggestions to users as they type
BSD 2-Clause "Simplified" License
831 stars 351 forks source link

[Bug] Unwanted vibrations on init or onSelect #603

Open im-sacha-cohen opened 2 months ago

im-sacha-cohen commented 2 months ago

Steps to reproduce

  1. Run the code on an iPhone

Expected results

The component should initialize, show the list and select an item without the device vibration.

Actual results

On iOS (not tested yet on Android's real device), when the TypeAheadField component is initiated or the list shown, or an item selected, it triggers un unwanted Haptick Feedback.

Package Version

5.2.0

Platform

iOS

Code sample

Code sample ```dart import 'dart:convert'; import 'package:auralib/screens/professional/insitutes.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; class HomeJob extends StatefulWidget { const HomeJob({ super.key, required this.onSelect, }); final void Function(Map) onSelect; @override State createState() => _HomeJobState(); } class _HomeJobState extends State { List> _jobs = []; final _selectedJob = TextEditingController(); @override void initState() { super.initState(); _findJobs(); } void _findJobs() async { final jobs = await request.get('/job-referential'); setState(() { _jobs = List>.from(json.decode(jobs.body)['object']); }); } Widget _getColumn(controller, focusNode) { return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'What are you searching for ?', style: Theme.of(context).textTheme.titleSmall, ), const SizedBox(height: 5), CupertinoTextField( placeholder: 'Search for a job type', controller: controller, autofocus: false, focusNode: focusNode, padding: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), border: Border.all( color: Colors.grey[200]!, ), ), ) ], ); } @override Widget build(BuildContext context) { return _jobs.isNotEmpty ? TypeAheadField( controller: _selectedJob, decorationBuilder: (context, child) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), border: Border.all( color: Colors.grey[200]!, ), ), child: child, ); }, suggestionsCallback: (search) { return _jobs.where((job) { return job['name'].toLowerCase().contains(search.toLowerCase()); }).toList(); }, builder: (context, controller, focusNode) { return _getColumn(controller, focusNode); }, itemBuilder: (context, job) { return ListTile( title: Text( job['name'], style: Theme.of(context).textTheme.bodyMedium, ), ); }, onSelected: (job) { widget.onSelect(job); setState(() { _selectedJob.text = job['name']; }); }, ) : _getColumn(_selectedJob, null); } } ```

Logs

Logs ```console [Paste your logs here] ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]