Skip to content

Instantly share code, notes, and snippets.

@anmolseth06
Created April 5, 2020 14:14
Show Gist options
  • Select an option

  • Save anmolseth06/a601b9246e4474ec1b92bfa0b26e8176 to your computer and use it in GitHub Desktop.

Select an option

Save anmolseth06/a601b9246e4474ec1b92bfa0b26e8176 to your computer and use it in GitHub Desktop.
import 'package:firestoredatabase/operations.dart';
import 'package:flutter/material.dart';
class AddUser extends StatefulWidget {
static const routeName = 'adduser';
@override
_AddUserState createState() => _AddUserState();
}
class _AddUserState extends State<AddUser> {
String id;
TextEditingController productNameController = TextEditingController();
TextEditingController productPriceController = TextEditingController();
TextEditingController imageUrlController = TextEditingController();
String productName;
String productPrice;
String imageUrl;
bool isFavourite = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("ADD GADGETS"),
backgroundColor: Colors.black,
),
body: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
focusedBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.green,
width: 2,
style: BorderStyle.solid)),
labelText: "Product Name",
icon: Icon(
Icons.assignment,
color: Colors.orangeAccent,
),
fillColor: Colors.white,
labelStyle: TextStyle(
color: Colors.green,
)),
onChanged: (value) {
productName = value;
},
controller: productNameController,
),
TextField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
focusedBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.green,
width: 2,
style: BorderStyle.solid)),
labelText: "Product Price",
icon: Icon(
Icons.assignment,
color: Colors.orangeAccent,
),
fillColor: Colors.white,
labelStyle: TextStyle(
color: Colors.green,
)),
onChanged: (value) {
productPrice = value;
},
controller: productPriceController,
),
TextField(
keyboardType: TextInputType.url,
decoration: InputDecoration(
focusedBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.green,
width: 2,
style: BorderStyle.solid)),
labelText: "Image URL",
icon: Icon(
Icons.assignment,
color: Colors.orangeAccent,
),
fillColor: Colors.white,
labelStyle: TextStyle(
color: Colors.green,
)),
onChanged: (value) {
imageUrl = value;
},
controller: imageUrlController,
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0, left: 40),
child: FlatButton(
color: Colors.black,
child: Text(
"Add",
style: TextStyle(color: Colors.white),
),
onPressed: () {
uploadingData(
productName, productPrice, imageUrl, isFavourite);
Navigator.of(context).pop();
},
),
)
],
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment