使用google_maps_autocomplete后,Flutter无法运行

时间:2019-08-10 03:38:54

标签: android google-maps flutter dart google-maps-autocomplete

我从flutter_google_places_autocomplete复制了此代码,但是我的应用无法启动。

我该如何解决这个问题?

import 'package:flutter/material.dart';
import 'package:flutter_google_places_autocomplete/flutter_google_places_autocomplete.dart';
import 'package:flutter_prayer_times/place_search_banner_field.dart';


// Google Api Key
const googleMapsApiKey = "......";

// to get places detail (lat/lng)
GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: googleMapsApiKey);
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
Kotlin plugin should be enabled before 'kotlin-android-extensions'

Compiler message:
file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_google_places_autocomplete-0.1.0/lib/src/flutter_google_places_autocomplete.dart:327:35: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
    _places = new GoogleMapsPlaces(widget.apiKey);
                                  ^
file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_webservice-0.0.14/lib/src/places.dart:22:3: Context: Found this candidate, but the arguments don't match.
  GoogleMapsPlaces({
  ^
Compiler failed on C:\Users\GaminKh\Desktop\MyProjects\prayertimes\flutter_prayer_times\lib\main.dart
Finished with error: Gradle task assembleDebug failed with exit code 1

1 个答案:

答案 0 :(得分:1)

class Video extends React.Component { constructor(props) { super(props); this.state = {} } read = async e => { const reader = new FileReader(); reader.onload = async e => { const videoUrl = e.target.result; this.play(videoUrl); }; reader.readAsDataURL(e.target.files[0]); }; play = videoUrl => { this.setState({ IsVideoUploaded: true, videoUrl }); }; render() { const { videoUrl } = this.state; return( <video id="video" autoPlay loop="true" src={videoUrl} /> ); } } 已过时,您应该使用flutter_google_places_autocomplete。选中此link以获得完整答案。