-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add geoflutterfire_plus fetchWithin sample
- Loading branch information
1 parent
c8c4e82
commit 665b396
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/mottai_flutter_app/lib/development/geoflutterfire_plus/geoflutterfire_plus.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:geoflutterfire_plus/geoflutterfire_plus.dart'; | ||
|
||
/// geoflutterfire_plus パッケージの動作確認用 Widget. | ||
class GeoflutterfirePlusSample extends StatelessWidget { | ||
const GeoflutterfirePlusSample({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(), | ||
body: ListView( | ||
children: [ | ||
ListTile( | ||
leading: const Icon(Icons.map), | ||
title: const Text('Call fetchWithin method'), | ||
onTap: () async { | ||
final locationCollectionRef = | ||
FirebaseFirestore.instance.collection('locations'); | ||
const center = GeoFirePoint(GeoPoint(35.681236, 139.767125)); | ||
final result = await GeoCollectionReference(locationCollectionRef) | ||
.fetchWithin( | ||
center: center, | ||
radiusInKm: 6, | ||
field: 'geo', | ||
strictMode: true, | ||
geopointFrom: (data) => (data['geo'] | ||
as Map<String, dynamic>)['geopoint'] as GeoPoint, | ||
); | ||
debugPrint(result.toString()); | ||
}, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |