我的颤振项目无法在 ios 设备上运行。我试过下面的命令sudo gem install cocoapods
。
颤动运行:
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
To install:
sudo gem install cocoapods
pod setup
Running Xcode build...
Xcode build done. 4.3s
Failed to build iOS app
Error output from Xcode build:
?
** BUILD FAILED **
Xcode's …
Run Code Online (Sandbox Code Playgroud) 我们为什么要使用dispose()
方法?我对此有点困惑。如果我们不使用它会出现什么问题,使用它有什么好处?
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
Run Code Online (Sandbox Code Playgroud) 我有一个对话框的图像,并尝试设计与图像下方相同的图像。
我试过了,但它与图像上方不同,我只想在右上角设置十字按钮,就像图像上方一样。我使用了堆栈,并Positioned
在top:0.0
,right:0.0
。
代码:
customDialogBox(BuildContext context) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0))),
contentPadding: EdgeInsets.only(top: 10.0),
content: Stack(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 20.0,
),
Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: new Text("Sorry please try \n again tomorrow", style:TextStyle(fontSize: 30.0,color: Colors.white)),
)//
),
SizedBox(
height: 20.0,
width: 5.0,
),
Divider(
color: Colors.grey, …
Run Code Online (Sandbox Code Playgroud) 我有一个问题的图像溢出了 17 个像素。&我无法解决它?首先,我做了什么..!!!
我拿了一个Row()
小部件并用Container()
& 包裹起来,其中Row()
包含了两个Expanded()
小部件。一个用于 TextField()
,另一个用于CountryPickerDropdown()
。
我使用过country_pickers插件
代码:
new Container(
width: MediaQuery.of(context).size.width,
padding: const EdgeInsets.only(left: 10.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5.0)),
border: Border.all(color: Colors.blue)
),
child: Row(
children: <Widget>[
Expanded(
child: CountryPickerDropdown(
initialValue: 'in',
itemBuilder: _buildDropdownItem,
onValuePicked: (Country country) {
isCountryCodeSelected=true;
print("${country.name}");
print("${country.phoneCode}");
print("${country.isoCode}");
print("+${country.phoneCode}(${country.isoCode})");
setState(() {
countryCode= country.phoneCode;
});
},
),
),
Expanded(
child: TextField(
keyboardType: TextInputType.phone,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Telephone Number",
),
onChanged: (value){ …
Run Code Online (Sandbox Code Playgroud) 我的 flutter 应用程序无法在2.5.0-5.3.pre
beta 版本上运行。之后我搜索了它,然后需要升级我的 flutter sdk,因此已升级到最新的 beta 版本 2.6.0-5.2.pre
,但仍然出现错误。\nplace_picker-0.9.19-nullsafety
插件的错误。并且无法解决它。
错误日志:
\n../../../../Workspace/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/rich_suggestion.dart:35:89: Error: The getter \'body1\' isn\'t defined for the class \'TextTheme\'.\n - \'TextTheme\' is from \'package:flutter/src/material/text_theme.dart\' (\'../../../../Workspace/flutter/packages/flutter/lib/src/material/text_theme.dart\').\nTry correcting the name to the name of an existing getter, or defining a getter or field named \'body1\'.\n TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.body1!.color)),\n ^^^^^\n../../../../Workspace/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/search_input.dart:60:65: Error: The getter \'body1\' isn\'t defined for the class \'TextTheme\'.\n - \'TextTheme\' is from \'package:flutter/src/material/text_theme.dart\' (\'../../../../Workspace/flutter/packages/flutter/lib/src/material/text_theme.dart\').\nTry correcting the name to the name …
Run Code Online (Sandbox Code Playgroud) 我正在尝试检查输入的电话号码是否有效。意思是,如果我输入了世界上不存在的错误号码,那么它会向我显示内容为“请输入有效号码”的祝酒词
Expanded(
child: TextField(
keyboardType: TextInputType.phone,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Phone Number",
),
onChanged: (value){
setState(() {
phoneValue=value;
});
//String telNo = value==null?("+91" + value) :null;
print("phoneNumbe:$phoneNo");
this.phoneNo = isCountryCodeSelected ? "+" + countryCode + value : "+91" + value ;
print("phoneNo="+phoneNo);
},
),
)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在真实设备上通过 xcode 运行我的 flutter 项目。但是收到此错误 module map file '/Users/"my_flutter_project_path"/ios/Pods/Headers/Private/openssl_grpc/BoringSSL-GRPC.modulemap' not found
我浏览了这个错误并获得了this_gitHub_issue_solution并遵循了它但无法获得解决方案。
我尝试了一些代码但得到了一个例外。
我得到的例外:
java.lang.IllegalArgumentException: Invalid document reference. Document references must have an even number of segments, but Users has 1
我搜索了一下,根据这个,文档引用必须有偶数个段,如:集合 - 文档 - 集合 - 文档 - 集合 - 文档
从 Firestore 获取数据的查询:
String getIsNewUSer;
Firestore.instance.collection('Users').document(uid).get().then((DocumentSnapshot document){
print("document_build:$document");
setState(() {
getIsNewUSer=document['IsNewUser'];
print("getIsNewUSe:$getIsNewUSer");
});
});
Run Code Online (Sandbox Code Playgroud)
查询将数据更新到 Firestore:
Firestore.instance
.collection('Users')
.document(uid)
.updateData({
"IsNewUser":"1"
}).then((result){
print("new USer true");
}).catchError((onError){
print("onError");
});
Run Code Online (Sandbox Code Playgroud)
我的这些代码行超出了异常。
初始状态:
void initState() {
super.initState();
this.uid = '';
FirebaseAuth.instance.currentUser().then((val){
setState(() {
this.uid= val.uid;
print("uid_init: $uid");
});
});
} …
Run Code Online (Sandbox Code Playgroud) 我使用ShowTimePicker
class 根据我的意愿选择时间,但想在 PM 或 AM 中显示,Text
例如 9:00 AM、10:00 PM。
表示采用 12 小时格式。
代码 :
import 'package:flutter/material.dart';
class ShowTimePickerDemo extends StatefulWidget {
@override
_ShowTimePickerDemoState createState() => _ShowTimePickerDemoState();
}
class _ShowTimePickerDemoState extends State<ShowTimePickerDemo> {
TimeOfDay pickedTime = TimeOfDay.now();
Future<Null> _selectTime(BuildContext context) async {
final TimeOfDay response = await showTimePicker(
context: context,
initialTime: pickedTime,
);
if (response != null && response != pickedTime) {
setState(() {
pickedTime = response;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold( …
Run Code Online (Sandbox Code Playgroud)