Skip to content

Instantly share code, notes, and snippets.

@VB10
Created April 5, 2020 22:04
Show Gist options
  • Save VB10/3a632779244e908529bd56f0acc71c14 to your computer and use it in GitHub Desktop.
Save VB10/3a632779244e908529bd56f0acc71c14 to your computer and use it in GitHub Desktop.
Shoppi Web - Product Update
class UpdateProductView extends StatelessWidget {
final ProductModel product;
final TextEditingController controller;
final Function(ProductModel product) onComplete;
const UpdateProductView(
{Key key,
@required this.product,
@required this.controller,
this.onComplete})
: super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(child: TextField(controller: controller)),
NumberCounterWidget(
value: product.total,
onChange: (val) {
product.total = val;
},
),
RaisedButton.icon(
onPressed: () {
product.price = double.tryParse(controller.text);
onComplete(product);
},
icon: Icon(Icons.update),
label: Text("Update"))
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment