class-AddToLogFormState extends State<AddToLogForm> {
int get numberofServings => int.parse(_servingsTextController,text) ;
int get totalCalories => widget.veggie.caloriesPerServing * numberofServings;
int get totalvitaminA => widget.veggie.vitaminAPercentage * numberofServings;
int get totalvitaminC => widget.veggie.vitaminCPercentage * numberofServings;
@override
Widget build(BuildContext context) {
final textTheme = AdaptiveTextTheme.of(context);
return Stack(
children: ‹Widget>[
ListView(
padding: MediaQuery.of(context).padding +
EdgeInsets. fromLTRB (24, 16, 24, 16 + _summaryHeight),
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FlatCard(
child: ZoomClipAssetimage(
height: 112,
width: 112,
Zoom: 2.4,
imageAsset: widget.veggie.imageAssetPath,
), // SizedBox
),// FlatCard
SizedBox(width: 12),
Expanded(
child; Column(
crossAxisAlignment; CrossAxisAlignment.start,
children: [],
Text(
widget.veggie.name,
style: textTheme.tileTitle,
),
SizedBox(height: 2),
Text(
widget.veggie.categoryName,
style: textTheme.label,
),// Text
].
),// Column
),// Expanded
},
). // Row
SizedBox(height: 8),
Line(),
CupertinoSegmentedControl(
children: {
0: Text('Breakfast'),
1: Text ('Lunch'),
2: Text ('Dinner'),
},
groupValue: _mealType,
onValueChanged: (type) => setState(() => _mealType = type),
), // CupertinoSegmentedControl
].
),// ListView
],// widget>[]
);// Stack
}
}
SizedBox (height: 32),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <widget>[
SizedBox(
width: 100,
child: CupertinoTextField(
controller: _servingsTextController,
focusNode: _servingsfocusNode,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 1,
onChanged: (number) {
if (number,isNotEmpty) {
setStatel_servingsFocusNode.unfocus):
]
},
style: TextStyle(
fontSize:34,
fontweight: Fontweight.bold,
),
),
),
SizedBox (width: 24),
Column (
crossAxisAlignment: CrossAxisAlignment.start.
children:
Text (
'Servings of',
style: textTheme, label,
).
SizedBox(height: 4),
Text(
widget, veggie, servingsize,
style: textTheme.body,
),
},
),
},
),
SizedBox (height: 8),
Row(
children: (
Padding(
padding: EdgeInsets.all(12),
child: Text('1', style: textTheme.bodySmall),
), // Padding Padding(
Expanded(
child; CupertinosSlider(
value: nuberOfServings.toDouble(),
min: 1,
max: 10,
divisions: 9,
onChanged: (value) {
setState(() => _servingsTextController.text =
value.floor().toString());
},
),
),
Padding(
padding: EdgeInsets.all(12),
child: Text('10', style: textheme. bodysmall),
), // Padding
],
),// Row
SizedBox(height: 8),
line(),
QuoteText(text: widget.vegggie.shortDescription),
},
),
},
);
}
}
Positioned(
bottom: MediaQuery.of(context).padding.bottom,
left: 0,
right: 0,
child: BlurredBackground(
intensity: 12,
color: Color(OxAAF2F2F2),
child: Padding(
padding: EdgeInsets.all (16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Summary(
calorise: totalCalories,
vitaminA: totalVitaminA,
vitaminC: totalVitaminc,
],
Container(
margin: EdgeInsets.only(top: 8)
alignment: Alignment.center,
child: CupertinoButton(
child: Text ('Add to Log'),
onPressed: () {
widget.onEntryCreated(LogEntry(
veggield: widget.veggie.id,
servings: numberofServings.floor(),
timestamp: DateTime.now(),
mealType: MealType.values[_mealType],
)): // LogEntry
},
), //CupertinoButton
)// Container
},
),
),
),
),
],
);
class BlurredBackground extends Statelesswidget {
const Blurredeackground( sthis.color, this.intensity = 25, this.child});
final Color color;
final double intensity:
final Widget child;
@override
Widget build(BuildContext context) {
return ClipRect(
filter: ImageFilter.blur(sigmaX: intensity, sigmaY: intensity),
child: DecoratedBox(
decoration: BoxDecoration(
color: color,
),
child: child,
),
),
);
}
}