added method that shortens the description of the recipe for display in the recipe widget
This commit is contained in:
parent
696b987957
commit
e950bfb743
2 changed files with 13 additions and 2 deletions
|
@ -26,6 +26,17 @@ class PizzaRecipe extends HiveObject {
|
|||
|
||||
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
||||
|
||||
String getShortDescriptionString(){
|
||||
if (this.description.length < 150) { // TODO 150?
|
||||
return this.description;
|
||||
}
|
||||
var endOfLineIndex = this.description.indexOf(RegExp("[.]|\$")) + 1;
|
||||
if (endOfLineIndex >= 150){
|
||||
var first150 = this.description.substring(0, 150);
|
||||
return "$first150...";
|
||||
}
|
||||
return this.description.substring(0, endOfLineIndex);
|
||||
}
|
||||
Table getIngredientsTable(int pizzaCount, int doughBallSize) {
|
||||
return Table(
|
||||
border: TableBorder.all(),
|
||||
|
|
|
@ -23,7 +23,7 @@ class PizzaRecipeWidget extends StatelessWidget {
|
|||
Text(pizzaRecipe.name),
|
||||
]
|
||||
),
|
||||
Text(pizzaRecipe.description),
|
||||
Text(pizzaRecipe.getShortDescriptionString()),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
|
|
Loading…
Add table
Reference in a new issue