Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 尝试从firestore检索标记并获取';无法加载资产';错误_Android_Ios_Google Maps_Flutter_Dart - Fatal编程技术网

Android 尝试从firestore检索标记并获取';无法加载资产';错误

Android 尝试从firestore检索标记并获取';无法加载资产';错误,android,ios,google-maps,flutter,dart,Android,Ios,Google Maps,Flutter,Dart,我得到这个错误,但它没有告诉我它是什么资产!当调试开始执行时,它突然停止在google map打开的地方,并警告“无法加载资产”,我点击F5继续,最后它检索到标记(但仅从firestore中检索到1个,我存储了6个),并将其显示在地图上。我仔细检查了pubspec.yaml,无法理解为什么会发生这种情况 const double camZoom = 15; const double camTilt = 90; const double camBearing = 30; class Custo

我得到这个错误,但它没有告诉我它是什么资产!当调试开始执行时,它突然停止在google map打开的地方,并警告“无法加载资产”,我点击F5继续,最后它检索到标记(但仅从firestore中检索到1个,我存储了6个),并将其显示在地图上。我仔细检查了pubspec.yaml,无法理解为什么会发生这种情况


const double camZoom = 15;
const double camTilt = 90;
const double camBearing = 30;

class CustomerMap extends StatefulWidget {
  final _CustomerMapState customerMapState = new _CustomerMapState();

  @override
  _CustomerMapState createState() => customerMapState;
  Stream<QuerySnapshot> getGeoPoint(String categoryName) {
    return customerMapState.getGeoPoint(categoryName);
  }
}

class _CustomerMapState extends State<CustomerMap> {
  GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey();
  Completer<GoogleMapController> _controller = Completer();

  Set<Marker> _markers = Set<Marker>();
  Set<Marker> get markers => _markers;

  BitmapDescriptor workerIcon;

  Location location;
  LocationService locationService = LocationService();
  FirestoreService fireservice = FirestoreService();

  StreamSubscription _userSubscription;
  String categoryName;

  @override
  void initState() {
    Future.delayed(Duration.zero, () {
      var authBloc = Provider.of<AuthBloc>(context, listen: false);
      _userSubscription = authBloc.user.listen((user) {
        if (user == null)
          Navigator.of(context)
              .pushNamedAndRemoveUntil('/login', (route) => false);
      });
    });

    getBytesFromAsset('assets/worker-icon.png', 128).then((onValue) {
      workerIcon = BitmapDescriptor.fromBytes(onValue);
    });

    super.initState();
  }

  @override
  void dispose() {
    _userSubscription.cancel();
    super.dispose();
  }

  void showPinOnMap() {
    var userLocation = Provider.of<UserLocation>(context, listen: false);
    var pinPosition = LatLng(userLocation.latitude, userLocation.longitude);

    _markers.add(Marker(
      markerId: MarkerId('customerPin'),
      position: pinPosition,
      icon: BitmapDescriptor.defaultMarker,
    ));
  }

  Stream<QuerySnapshot> getGeoPoint(String categoryName) {
    FirebaseFirestore.instance
        .collection('Workers')
        .where('categoryName', isEqualTo: categoryName)
        .get()
        .then((QuerySnapshot querySnapshot) => {
              querySnapshot.docs.forEach((doc) {
                GeoPoint pos = doc['position']['geopoint'];
                LatLng latLng = new LatLng(pos.latitude, pos.longitude);
                print(latLng);

                if (mounted) {
                  setState(() {
                    _markers.add(Marker(
                      markerId: MarkerId('workerPin'),
                      position: latLng,
                      icon: workerIcon,             
                    ));
                  });
                }
              })
            });
  }

  static Future<Uint8List> getBytesFromAsset(String path, int width) async {
    ByteData data = await rootBundle.load(path);
    ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
        targetWidth: width);
    ui.FrameInfo fi = await codec.getNextFrame();
    return (await fi.image.toByteData(format: ui.ImageByteFormat.png))
        .buffer
        .asUint8List();
  }

  void _onMapCreated(GoogleMapController controller) {
    setState(() {
      _controller.complete(controller);
      showPinOnMap();
      getGeoPoint(categoryName);
    });
  }

  @override
  Widget build(BuildContext context) {
    var authBloc = Provider.of<AuthBloc>(context);
    var userLocation = Provider.of<UserLocation>(context);

    var pinPosition = LatLng(userLocation.latitude, userLocation.longitude);

    CameraPosition initialCameraPosition = CameraPosition(
        zoom: camZoom, tilt: camTilt, bearing: camBearing, target: pinPosition);

    return Scaffold(
      resizeToAvoidBottomInset: false,
      key: _scaffoldKey,
      drawer: Drawer(
        child: HomeMenuDrawer(),
      ),
      body: Stack(
        children: <Widget>[
          GoogleMap(
            initialCameraPosition: initialCameraPosition,
            compassEnabled: false,
            tiltGesturesEnabled: true,
            mapType: MapType.normal,
            markers: Set<Marker>.of(markers),
            myLocationEnabled: true,
            myLocationButtonEnabled: true,
            onMapCreated: _onMapCreated,
          ),
          SearchBar(),
          Positioned(
            left: 0,
            top: 0,
            right: 0,
            child: Column(
              children: <Widget>[
                AppBar(
                  backgroundColor: Colors.transparent,
                  elevation: 0.0,
                  leading: FlatButton(
                    onPressed: () {
                      _scaffoldKey.currentState.openDrawer();
                    },
                    child: Icon(
                      Icons.menu,
                      color: Colors.black,
                    ),
                  ),
                ),
              ],
            ),
          ),
          Positioned(
            child: Align(
              alignment: Alignment.bottomCenter,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  FunctionalButton(
                    icon: Icons.settings,
                    title: "Ayarlar",
                    onPressed: () {},
                  ),
                  FunctionalButton(
                    icon: Icons.home,
                    title: "Ana Sayfa",
                    onPressed: () {},
                  ),
                  FunctionalButton(
                    icon: Icons.exit_to_app,
                    title: "Çıkış",
                    onPressed: () {
                      authBloc.logout();
                    },
                  ),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}


您是否尝试过
flatter pub get
class SearchBar extends StatefulWidget {
  @override
  _SearchBarState createState() => _SearchBarState();
}

class _SearchBarState extends State<SearchBar> {
  TextEditingController searchController = TextEditingController();
  CustomerMap customerMap = new CustomerMap();

  @override
  Widget build(BuildContext context) {
    return Positioned(
      top: 100.0,
      right: 30.0,
      left: 30.0,
      child: Container(
        height: 50.0,
        width: double.infinity,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(30.0),
          color: Colors.white,
          boxShadow: [
            BoxShadow(
                color: Colors.grey,
                offset: Offset(1.0, 5.0),
                blurRadius: 10,
                spreadRadius: 3)
          ],
        ),
        child: TextField(
          cursorColor: Colors.black,
          controller: searchController,
          textInputAction: TextInputAction.go,
          onSubmitted: (value) {
           //This is where I want to display markers on the map!
            customerMap.getGeoPoint(value);
          },
          decoration: InputDecoration(
            icon: Container(
              margin: EdgeInsets.only(left: 20, top: 0),
              width: 10,
              height: 10,
              child: Icon(
                Icons.search,
                color: Colors.black,
              ),
            ),
            hintText: "Ne arayorsun?",
            border: InputBorder.none,
            contentPadding: EdgeInsets.only(left: 15.0, top: 10),
          ),
        ),
      ),
    );
  }
}

════════ Exception caught by image resource service ════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset:

When the exception was thrown, this was the stack
#0      PlatformAssetBundle.load 
package:flutter/…/services/asset_bundle.dart:225
<asynchronous suspension>
#1      AssetBundleImageProvider._loadAsync 
package:flutter/…/painting/image_provider.dart:668
#2      AssetBundleImageProvider.load 
package:flutter/…/painting/image_provider.dart:651
#3      ImageProvider.resolveStreamForKey.<anonymous closure> 
package:flutter/…/painting/image_provider.dart:504
...
Image provider: AssetImage(bundle: null, name: "  ")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#0a112(), name: "  ", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════
W/com.mems.ustam(11573): JNI critical lock held for 16.410ms on Thread[58,tid=12691,Runnable,Thread*=0xbe395800,peer=0x13b81460,"FirestoreWorker"]
W/com.mems.ustam(11573): JNI critical lock held for 37.390ms on Thread[1,tid=11573,Runnable,Thread*=0xef237800,peer=0x7277e1f0,"main"]
I/flutter (11573): LatLng(40.1980517, 29.065976699999993)
I/flutter (11573): LatLng(40.1953817, 29.069189999999992)
I/flutter (11573): LatLng(40.1970215, 29.069447700000012)
I/flutter (11573): LatLng(40.199256, 29.06912700000001)
I/flutter (11573): LatLng(40.203605, 29.070316700000006)
I/flutter (11573): LatLng(40.200805, 29.06842499999999)

flutter:

  uses-material-design: true

  assets:
    - assets/