Skip to content
Snippets Groups Projects
Commit c36e8826 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

add: searching function with fuzzy, not tested

parent f5737bf7
No related branches found
No related tags found
1 merge request!10Clhp map
import 'dart:async';
import 'package:flutter/material.dart';
import 'dart:typed_data';
import 'package:fuzzy/fuzzy.dart';
import 'package:flutter/material.dart';
import '../consts.dart';
import 'loading_page.dart';
......@@ -25,6 +26,26 @@ class _DefaultPageState extends State<DefaultPage> {
late Future<List<Measurement>> markerListFuture;
late Future<Uint8List> relationFuture;
late List<String> testSearchNames = [
"Mjøsa",
"Bogstadsvannet",
"Einavatnet",
"Femsjøen",
"Femunden",
"Fjellsjøen",
"Gjende",
"Gjersjøen"
];
// Searching function for lake names using Fuzzy library
List<String> searchLakeNames(String query) {
final options = FuzzyOptions(threshold: 0.3, findAllMatches: true);
final matcher = Fuzzy(testSearchNames, options: options);
final results = matcher.search(query);
// Extracting lake names from the results and casting them to strings
return results.map((result) => result.item as String).toList();
}
@override
void initState() {
super.initState();
......
......@@ -120,6 +120,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
fuzzy:
dependency: "direct main"
description:
name: fuzzy
sha256: af5fbd36f2f8de0663a5b562ef5ca209aea957e81a2f0e97f97475cfbed044ec
url: "https://pub.dev"
source: hosted
version: "0.5.1"
google_fonts:
dependency: "direct main"
description:
......@@ -453,6 +461,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
stringr:
dependency: transitive
description:
name: stringr
sha256: "2846b6811c3cbb34c8937a35e623986e3fbf7203b3bb33ffe7f80e496ea3eff2"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
syncfusion_flutter_core:
dependency: "direct main"
description:
......
......@@ -16,9 +16,10 @@ dependencies:
fl_chart: ^0.20.0-nullsafety1 # Charts and diagrams
google_fonts: any # Fonts
syncfusion_flutter_maps: ^20.4.41 # Choropleth map_handler
syncfusion_flutter_core: any # Choropleth shape selection
syncfusion_flutter_core: any # Choropleth shape selection
path_provider: ^2.0.8
shared_preferences: any # Persistent data storage
fuzzy: any # Search algorithm
dev_dependencies:
flutter_test:
......
File added
Mjøsa - mjosa
TestLake - testlake
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment