In between commit with numberpickers for number of pizzas and doughball size

This commit is contained in:
broodjeaap89 2021-07-03 15:50:29 +02:00
parent 259a4d5ddf
commit c43a4b7264
2 changed files with 40 additions and 4 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:numberpicker/numberpicker.dart';
class AddPlannedPizzaPage extends StatefulWidget { class AddPlannedPizzaPage extends StatefulWidget {
@override @override
@ -9,6 +10,8 @@ class AddPlannedPizzaPage extends StatefulWidget {
class AddPlannedPizzaPageState extends State<AddPlannedPizzaPage> { class AddPlannedPizzaPageState extends State<AddPlannedPizzaPage> {
String name = ""; String name = "";
String pizzaType = "Neapolitan"; String pizzaType = "Neapolitan";
int pizzaCount = 1;
int doughballSize = 200;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -34,9 +37,7 @@ class AddPlannedPizzaPageState extends State<AddPlannedPizzaPage> {
value: pizzaType, value: pizzaType,
isExpanded: true, isExpanded: true,
onChanged: (String? newType) { onChanged: (String? newType) {
setState(() { setState(() => pizzaType = newType!);
pizzaType = newType!;
});
}, },
items: <String>["Neapolitan", "New York", "Chicago"] items: <String>["Neapolitan", "New York", "Chicago"]
.map<DropdownMenuItem<String>>((String v) { .map<DropdownMenuItem<String>>((String v) {
@ -46,7 +47,41 @@ class AddPlannedPizzaPageState extends State<AddPlannedPizzaPage> {
); );
}).toList() }).toList()
), ),
Column(
children: <Widget>[
Text("# Of Pizzas: "),
NumberPicker(
value: pizzaCount,
minValue: 1,
maxValue: 1000,
itemHeight: 30,
axis: Axis.horizontal,
onChanged: (newPizzaCount) => setState(() => this.pizzaCount = newPizzaCount),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.black26),
),
)
]
),
Column(
children: <Widget>[
Text("Doughball Size: "),
NumberPicker(
value: doughballSize,
minValue: 100,
maxValue: 10000,
step: 10,
itemHeight: 30,
axis: Axis.horizontal,
onChanged: (newDoughballSize) => setState(() => this.doughballSize = newDoughballSize),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.black26),
),
)
]
),
] ]
) )
) )

View file

@ -25,6 +25,7 @@ dependencies:
sdk: flutter sdk: flutter
intl: ^0.17.0 intl: ^0.17.0
numberpicker: ^2.1.1
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2