//这是我的main.dart代码
signIn() {
FirebaseAuth.instance
.signInWithPhoneNumber(verificationId: verificationId, smsCode: smsCode)
.then((user) {
Navigator.of(context).pushReplacementNamed('/homepage');
}).catchError((e) {
print(e);
});
}
Run Code Online (Sandbox Code Playgroud)
//这是我的pubspec.yaml代码
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
firebase_auth:
Run Code Online (Sandbox Code Playgroud)
//这是我的logcat
Error: The method 'signInWithPhoneNumber' isn't defined for the class 'FirebaseAuth'.
Try correcting the name to the name of an existing method, or defining a method named 'signInWithPhoneNumber'.
Run Code Online (Sandbox Code Playgroud)
我正在我的 flutter 应用程序中实现电话号码登录。我安装了所有依赖项,并在我的项目中粘贴了 google_services.json 文件。
File profileImg;
Widget profilePic() {
return Stack(
children: <Widget>[
new Image.file(profileImg),
Positioned(
left: 50.0,
right: 50.0,
bottom: 40.0,
height: 64.0,
child: RaisedGradientButton(
onPressed: () async {
File image= await ImagePicker.pickImage(source:ImageSource.gallery);
image=profileImg;
print(image.path);
},
child: new Text(
"Upload",
style: TextStyle(fontSize: 20.0, color: Colors.white),
),
gradient: LinearGradient(
colors: <Color>[
const Color(0xFF000000),
const Color(0xFF000000),
const Color(0xFF40079B)
],
),
), // child widget
),
]);
}
Run Code Online (Sandbox Code Playgroud)
我已经创建了一张图片,在图片的底部,我有一个按钮可以从图库中选择图片。在从图库中选择图片之前,我想在从图库中选择图片后为图片设置背景颜色,我想设置所选图片图像视图中的图像
new TextFormField(
decoration: new InputDecoration(hintText: 'DOB'),
maxLength: 10,
validator: validateDob,
onSaved: (String val) {
strDob = val;
},
),
Future _selectDate() async {
DateTime picked = await showDatePicker(
context: context,
initialDate: new DateTime.now(),
firstDate: new DateTime(2016),
lastDate: new DateTime(2019)
);
if(picked != null) setState(() => _value = picked.toString());
}
Run Code Online (Sandbox Code Playgroud)
当我单击要显示日期选择器的字段时,我创建了一个textFormField,然后在选择要在textFormField中设置所选日期的日期后,必须从选择器中选择一个日期。
child: RaisedButton(
color: const Color(0xFF5867DD),
onPressed: (){
updateProfilePic();
},
Widget updateProfilePic(){
return SimpleDialog(
title: const Text('Select any option'),
children: <Widget>[
SimpleDialogOption(
onPressed: () { profileImg = ImagePicker.pickImage(source: ImageSource.gallery)
.whenComplete(() {
setState(() {});
}); },
child: const Text('open gallery'),
),
SimpleDialogOption(
onPressed: () { profileImg = ImagePicker.pickImage(source: ImageSource.camera)
.whenComplete(() {
setState(() {});
}); },
child: const Text('open camera'),
),
],
);
}
Run Code Online (Sandbox Code Playgroud)
我试图在按下按钮时实现对话框。我想从画廊和相机中选择图像,以便我创建一个对话框来选择上传图片的任何选项。问题是当我单击按钮时对话框不可见。
我正在图像上创建按钮,我想要图像底部中心的按钮
Widget buildBody() {
return Stack(
children: <Widget> [
Image(
image: new AssetImage('assets/homebg.png'),
),
Center(
child: RaisedButton(
onPressed: () => launch("tel://21213123123"),
child: new Text("Call me")
)
),
]
);
}
Run Code Online (Sandbox Code Playgroud)
我希望按钮的输出应该在图像的底部
// 这是我的 main.dart 文件
class UserRegistrationPage extends StatefulWidget {
@override
UserRegistrationPageState createState() => UserRegistrationPageState();
}
class UserRegistrationPageState extends State<UserRegistrationPage>{
@override
Widget build(BuildContext context) {
return MaterialApp(
home: new Scaffold(
body: new SingleChildScrollView(
child: new Container(
child: new Form(
child: formUi(),
),
),
),
),
);
}
Widget formUi(){
return new Column(
children: <Widget>[
new Image(
image: new AssetImage("assets/bgtopbar.png"),
fit: BoxFit.cover,
),
new TextFormField(
// margin: new EdgeInsets.all(15.0),
decoration: new InputDecoration(hintText: 'Mobile Number'),
keyboardType: TextInputType.phone,
maxLength: 10,
),
new TextFormField(
decoration: …Run Code Online (Sandbox Code Playgroud) Widget build(BuildContext context) {
return MaterialApp(
home: new Scaffold(
body: new Container(
child: Padding(
padding: EdgeInsets.fromLTRB(10.0,10.0, 10.0,10.0),
child: Column(
children: <Widget>[
timeslotsGrid()
],),),)));}
Widget timeslotsGrid(){
return Container(
child: GridView.count(
primary: false,
padding: const EdgeInsets.all(0.0),
crossAxisSpacing: 10.0,
crossAxisCount: 2,
children: <Widget>[
const Text('He\'d have you all unravel at the'),
const Text('Heed not the rabble'),
const Text('Sound of screams but the'),
const Text('Who scream'),
],) ),}
Run Code Online (Sandbox Code Playgroud)
我正在flutter中实现gridview。我尝试使用上面的代码,但问题是网格根本不可见并且页面是空白的
Widget servicesListview() {
return Container(
decoration: new BoxDecoration(color: const Color(0xFFEAEAEA)),
child: Column(
children: <Widget>[
ListView.builder(
scrollDirection: Axis.vertical,
itemCount: menServicesList.length,
itemBuilder: (BuildContext context, int index) {
Text(menServicesList[index].name);
}),
],
));
}
Run Code Online (Sandbox Code Playgroud)
每当我调用此方法列表不可见时,我都会在我的颤振项目中实现列表视图。页面变为空白,帮我解决这个问题
@override
void initState() {
super.initState();
_loadData();
}
void _loadData() async {
await StorageUtil.getInstance();
String cookie = StorageUtil.getString('sess');
String page = currentPage.toString();
if (cookie != null) {
ApiService.getEstimateList(cookie, page, myAllestimate, search)
.then((value) {
if (value.data != null) {
if (count < _totalRecords) {
setState(() {
invoicelist.addAll(value.data);
print(value.data);
_totalRecords = value.recordsTotal;
});
print(
'List size is $count and TotalRecord - ${value.recordsTotal} , TotalFiltered - ${value.recordsFiltered}');
}
}
});
}
}
Future<bool> _loadMoreData() async {
print('_loadMoreData()');
await Future.delayed(Duration(seconds: 0, milliseconds: 1000));
currentPage += …Run Code Online (Sandbox Code Playgroud) 我正在创建一个水平可滚动的卡片视图。在cardview中,我想设置图像和textview。cardview中的数据将从列表中获取。现在如何在cardview中设置列表数据
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: new Scaffold(
body: new SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
buildBody(),
productsCard()
],
),
),
)
);
}
Widget buildBody() {
return Stack(
// alignment: Alignment.bottomCenter,
children: <Widget> [
new Image(
image: new AssetImage('assets/homebg.png'),
),
Positioned(
left: 50.0,
right: 50.0,
bottom: 40.0,
height: 64.0,// adjust this if you want some padding
child: RaisedGradientButton(
onPressed: () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => StylistPage()));
},
child: new Text("BOOK AN APPOINTMENT", …Run Code Online (Sandbox Code Playgroud)