I am a Korean who is making an app using Flutter. This app is in Korean, and I wrote the code to automatically reflect the search results directly to Listview.builder according to the real-time API input values when searching (mostly in Korean) during app development. I checked with debugging mode to see if it worked well on the actual device, it worked very well on Android as I wanted, but on iOS, I had a problem where the value didn't appear in the list view even though I had input. Is this a problem caused by the different iOS processing methods of Korean Alphabet? Also, when you take a real-time search word with Query, Hangeul appears well.
class FoundGroupPage extends StatefulWidget {
const FoundGroupPage({super.key});
@override
State<FoundGroupPage> createState() => _FoundGroupPageState();
}
class _FoundGroupPageState extends State<FoundGroupPage> {
final TextEditingController alertTextController = TextEditingController();
final TextEditingController groupSearchController = TextEditingController();
late List<Group> searchResults;
bool isLoading = false;
@override
void initState() {
super.initState();
searchResults = [];
_loadInitialData();
groupSearchController.addListener(_onSearchChanged);
eventBus.on<TokenExpiredEvent>().listen((event) {
Navigator.of(context)
.pushNamedAndRemoveUntil('/login', (Route<dynamic> route) => false);
});
}
void _onSearchChanged() {
final searchText = groupSearchController.text;
if (searchText.trim().isEmpty) {
_loadInitialData();
} else {
handleSearchCallBack(searchText);
}
}
@override
void dispose() {
super.dispose();
_debounce?.cancel();
alertTextController.dispose();
groupSearchController.dispose();
}
Future<void> _loadInitialData() async {
try {
List<Group> initialGroups = await getGroupList();
setState(() {
searchResults = initialGroups;
});
} catch (e) {
setState(() {
searchResults = [];
});
debugPrint('Error loading initial data: $e');
}
}
Future<void> handleSearchCallBack(String searchText) async {
if (searchText.isEmpty) {
_loadInitialData();
}
try {
List<Group> results = await searchGroups(searchText);
setState(() {
searchResults = results;
});
} catch (e) {
debugPrint('Error searching groups: $e');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
color: mainBackgroundColor,
child: SafeArea(
top: true,
child: Center(
child: Column(
children: [
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: searchInput(
'그룹명을 입력하세요.', groupSearchController, handleSearchCallBack),
),
const SizedBox(height: 40),
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Row(
children: [
Text(
'그룹 리스트',
style: TextStyle(
color: Colors.white.withOpacity(0.85),
fontSize: 24,
fontWeight: FontWeight.w600,
),
),
],
),
),
const SizedBox(height: 20),
Expanded(
child: isLoading
? Center(
child: Platform.isIOS
? const CupertinoActivityIndicator(
color: Colors.white70)
: const CircularProgressIndicator(
color: Colors.white70),
)
: searchResults.isEmpty
? const Center(
child: Text('검색 결과가 존재하지 않습니다.',
style: TextStyle(color: Colors.white)))
: ListView.builder(
itemCount: searchResults.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 12.0),
child: groupButton(
// remove `!`
searchResults[index].groupName,
() async {
await openPasswordDialog(
context,
alertTextController,
searchResults[index].groupId,
);
},
),
);
},
),
),
],
),
)),
),
);
}
}
Disconnect the search widget to use the search widget to use it to be used as a double function.Can you have a problem in this nose?
Widget searchInput(String placeHolder, TextEditingController controller, Future<void> Function(String searchText) onSearchSubmitted) {
return TextFormField(
controller: controller,
keyboardType: TextInputType.text,
style: const TextStyle(color: Colors.white),
autofocus: false,
decoration: InputDecoration(
hintText: placeHolder,
hintStyle: const TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.bold),
focusColor: Colors.white,
border: InputBorder.none,
prefixIcon: const Icon(Icons.search, color: Colors.white,),
enabledBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(40)),
borderSide: BorderSide(color: Colors.grey),
),
focusedBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(40)),
borderSide: BorderSide(color: Colors.grey),
),
),
onFieldSubmitted: (searchText) {
onSearchSubmitted(searchText);
},
);
}
I haven't found any meaningful data on the internet about the fact that it works fine on Flutter Android but not on iOS.. please help..!
Debugging Android and iOS Devices, Verifying Behavior in Simulator After Downgrading to iOS 16, Ask GPT-4 and googling