flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.02k stars 27.19k forks source link

Firestore GeoPoint Type #12468

Closed pauldemarco closed 6 years ago

pauldemarco commented 6 years ago

Similar to issue #12437, the Firestore plugin should convert GeoPoint data types from the store to an official Dart type, if one exists.

GeoPoint Reference Firestore Data Types

Hixie commented 6 years ago

I don't think we have a defined type for this yet, but we could create one.

sethladd commented 6 years ago

Is this a request for the Dart team? Should we move it over to the Dart SDK?

cc @kasperl

Hixie commented 6 years ago

This would just be a trivial type (class with two final doubles) in the plugin.

sethladd commented 6 years ago

Ah, I see. Thanks. Would we accept a PR for it?

bjornbjorn commented 6 years ago

Looks like this issue will cause the app to crash with the following exception:

Unsupported value: <FIRGeoPoint: (59.583559, 11.167059)> of type FIRGeoPoint
*** Assertion failure in -[FlutterStandardWriter writeValue:], ../../flutter/shell/platform/darwin/ios/framework/Source/FlutterStandardCodec.mm:321
Lost connection to device.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported value for standard codec'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x000000010d885b0b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x000000010d2ea141 objc_exception_throw + 48
        2   CoreFoundation                      0x000000010d889cf2 +[NSException raise:format:arguments:] + 98

(just some added context in case anyone is Googling for a solution to the above error)

niamh-power commented 6 years ago

Any update on this? I'm running into the same issue

fvisticot commented 6 years ago

Any update ? , i need to create this kind o document: .setData({'value': 12, 'location': new GeoPoint(longitude: 3.4, latitude: 4.5) });

niamh-power commented 6 years ago

The fork mentioned in this PR https://github.com/flutter/plugins/pull/343 works for me for now :) seems close to merging

Skylled commented 6 years ago

Can be closed, via flutter/plugins#429

kroikie commented 4 years ago

@pauldemarco

This issue has been moved to https://github.com/FirebaseExtended/flutterfire/issues/956. Any further collaboration will be done there.

chinu999 commented 4 years ago

hi can anyone tell me how can i retrieve geopoint from firebase. i am getting an error "type Geopoint is not a subtype of type String".In phone

code to add: IconButton( icon: Icon(Icons.search, color: Colors.black), onPressed: (){ Firestore.instance.collection('Location').add({ 'location': new GeoPoint(position.latitude,position.longitude), });

      },),

code to retrieve: class _PageeetState extends State { @override Widget build(BuildContext context) { return Scaffold( body: StreamBuilder( stream: Firestore.instance.collection('Location'.toString()).snapshots(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) return Text("There is no expense"); return ListView(children: getExpenseItems(snapshot)); }, ), ); }

getExpenseItems(AsyncSnapshot snapshot) { return snapshot.data.documents .map( (doc) => Card(

    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(20.0),),
    child: Padding(
      padding: const EdgeInsets.all(8.0),
      child: ListTile(
        title: Text.rich(
          TextSpan(
            text: 'location: ', // default text style
            children: <TextSpan>[
              TextSpan(text: doc['location'],),
            ],
          ),
        ),
      ),
    ),
  ),
)
    .toList();

} }

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.