我试图通过路线从一个屏幕导航到另一个屏幕.当我点击页面按钮移动到提供的路线时,我收到错误
I/flutter ( 8790): Another exception was thrown: There are multiple heroes that share the same tag within a subtree.
Run Code Online (Sandbox Code Playgroud)
这是代码:
路线:
<String, WidgetBuilder>{
'/first':(BuildContext context) =>NavigatorOne() ,
'/second':(BuildContext context) =>NavigatorTwo(),
'/third':(BuildContext context) =>NavigatorThree(),
},
Navigator.of(context).pushNamed('/first');
Navigator.of(context).pushNamed('/second');
Navigator.of(context).pushNamed('/third');
class NavigatorOne extends StatefulWidget {
@override
_NavigatorOneState createState() => _NavigatorOneState();
}
class _NavigatorOneState extends State<NavigatorOne> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(
color: Colors.green,
child: RaisedButton(child: Text(' one 1'),onPressed: (){
Navigator.of(context).pushNamed('/second');
},),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
而错误: …
我已经能够从我的计算机中选择一个文件并显示在我的 flutter web 应用程序中。我有一个函数(类型File
),它接收一个文件并将其上传到服务器。像这样functionName(File imageToSend)
。
但是当我尝试将此图像发送到服务器端时,它给了我一个错误。正在使用以下代码进行上传:
Uint8List uploadedImage;
File theChosenImg;
FileReader reader = FileReader();
FileReader reader2 = FileReader();
filePicker() async {
InputElement uploadInput = FileUploadInputElement();
uploadInput.click();
uploadInput.onChange.listen((e) {
// read file content as dataURL
final files = uploadInput.files;
if (files.length == 1) {
final file = files[0];
reader.onLoadEnd.listen((e) {
setState(() {
uploadedImage = reader.result;
theChosenImg = files[0];
});
});
reader.readAsArrayBuffer(file);
reader2.readAsDataUrl(file);
}
});
}
Run Code Online (Sandbox Code Playgroud)
当我使用变量时uploadedImage
,错误是Expected a value of type 'File', but got one …
我正在尝试使用颤振网络。我尝试使用 http 包将我创建的一个简单的 Flutter Web 应用程序连接到 mysql 数据库和 localhost。但是我没有从请求方法返回任何数据。当我试图打印出snaphot.error
我得到这个:XMLHttpRequest error
。我有这个方法FutureBuilder()
getMethod()async{
String theUrl = 'https://localhost/fetchData.php';
var res = await http.get(Uri.encodeFull(theUrl),headers: {"Accept":"application/json"});
var responsBody = json.decode(res.body);
print(responsBody);
return responsBody;
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个flutter web
使用网络图像和资产图像的项目,在我的电脑上调试时一切正常,但是当我将其部署到 Web 服务器时,网络图像工作正常,但资产图像根本不显示。当我在 Web 浏览器控制台中检查页面时,出现以下错误:
$1 @ window.dart:120
/assets/slack.png:1 Failed to load resource: the server responded with a status of 503 ()
window.dart:120 Error while trying to load an asset: Failed to load asset at "assets/slack.png" (503)
$1 @ window.dart:120
/assets/flutterLogo.png:1 Failed to load resource: the server responded with a status of 503 ()
window.dart:120 Error while trying to load an asset: Failed to load asset at "assets/flutterLogo.png" (503)
$1 @ window.dart:120
/assets/kross.jpg:1 Failed to load resource: …
Run Code Online (Sandbox Code Playgroud) 我想知道如何导航到 Flutter Web 应用程序中的 URL。
目前正在使用Navigator.of(context).push(MaterialPageRoute(...));
,我只能进入localhost:5354/#/
地址栏。
另外,我想知道如何通过将 URL 粘贴到浏览器的地址栏中直接导航到特定的 URL。
我正在使用 flutter_markdown 包向我的应用程序添加 markdown 支持。有一个语法荧光笔选项。我找到了一个语法突出显示库,如何使用它来帮助编写我的 SyntaxHighlighter 类
我正在尝试将文档添加到我的云 Firestore 数据库中。以这种方式。
Future<String> currentlyIn()async{
FirebaseAuth auth = FirebaseAuth.instance;
String fuser = await auth.currentUser();
});
return fuser.uid;
}
Map<String, dynamic> votedown() {
Map<String, dynamic> comdata = <String, dynamic>{
'user_Id':currentlyIn(),
'actual_vote':0,
'voteUp': false,
};
return comdata;
}
DocumentReference storeReference =Firestore.instance.collection('htOne').document('docq');
await storeReference.setData(votedown());
Run Code Online (Sandbox Code Playgroud)
但是,我每次运行代码时都会收到此错误。我需要有关如何成功解决此问题的帮助
E/flutter ( 6263): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 6263): Invalid argument: Instance of 'Future<String>'
E/flutter ( 6263): #0 StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:353:7)
E/flutter ( 6263): #1 FirestoreMessageCodec.writeValue (file:///C:/NoFlutterPerms/Git/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.7.4/lib/src/firestore_message_codec.dart:38:13)
Run Code Online (Sandbox Code Playgroud) dart firebase firebase-authentication flutter google-cloud-firestore
我想知道如何将用户计算机中的图像选入我的Flutter Web应用程序中进行上传
我能够构建我的应用程序的发布版本并上传到 Play 商店,现在我想更新它,我需要更改versionCode
. 但是,当我查看我<android/app/build.gradle>
的部分时,它说应该是整数的版本现在有点像flutterVersionCode.toInteger()
并且versionName
flutterVersionName
对我来说有点混乱,我不知道从哪里更改它。
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
}
def flutterVersionName = …
Run Code Online (Sandbox Code Playgroud) 我使用下面的代码创建了一个带有标记和折线的 Google 地图小部件。
一切工作正常,除了当我在两个坐标之间绘制多段线并稍后尝试删除它时,多段线不会被删除(至少不会永久删除)。当我使用下面的方法尝试删除旧的折线并添加新的折线时,我得到两条折线:
_polyLine.clear()
_polyLine.remove("id")
polylines.removeWhere((m) => m.polylineId.value == 'polyId$_randPolyId')
Run Code Online (Sandbox Code Playgroud)
它被删除,然后除了新的之外又被添加。结果如下图所示:
void showPinsOnMap() {
// _polylines.removeWhere(
// (m) => m.polylineId.value == 'polyId$_randPolyId');
// _polylines.clear()
_polylines = {};
print("\n\n\nPolyLines Lenght: ${_polylines.length}\n\n\n");
var pinPosition = LatLng(_currentLocation.latitude,_currentLocation.longitude);
var destPosition = LatLng(_destinationLocation.latitude,
_destinationLocation.longitude);
_markers.add(Marker(
markerId: MarkerId('sourcePin'),
position: pinPosition,
icon: _sourceIcon
));
_markers.add(Marker(
markerId: MarkerId('destPin'),
position: destPosition,
icon: _destinationIcon,
));
setPolylines();
notifyListeners();
}
Run Code Online (Sandbox Code Playgroud)
...
...
void setPolylines() async {
List<PointLatLng> result = await _polylinePoints.getRouteBetweenCoordinates(
_googleAPIKey,
_currentLocation.latitude,
_currentLocation.longitude,
_destinationLocation.latitude,
_destinationLocation.longitude).catchError((onError){
print("\n\n\n An Error Occured …
Run Code Online (Sandbox Code Playgroud)