Easy time i add this to where i think it should be the code afterwards gets greyed out.
Can someone please assist me with this placement error?
Thank you.
Easy time i add this to where i think it should be the code afterwards gets greyed out.
Can someone please assist me with this placement error?
Thank you.
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
// 1: A Scaffold provides the high-level structure for a screen.
// In this case, you’re using two properties.
return Scaffold(
// 2: AppBar gets a title property by using a Text widget that has a title passed in from
// home: MyHomePage(title: 'Recipe Calculator') in the previous step.
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
// 3: body has SafeArea, which keeps the app from getting too close
// to the operating system interfaces such as the notch or
// interactive areas like the Home Indicator at the bottom of
// some iOS screens.
body: SafeArea(
// 4: SafeArea has a child widget, Builds a list using ListView.
child: ListView.builder(
// 5: itemCount determines the number of rows the list has.
// In this case, length is the number of objects in the Recipe.samples list.
itemCount: Recipe.samples.length,
// 6: itemBuilder builds the widget tree for each row.
itemBuilder: (BuildContext context, int index) {
// 7 A Text widget displays the name of the recipe.
// TODO: Update to return Recipe card
return Text(Recipe.samples[index].label);
},
),
),
);
}
}
``` this is where i am so far...
The GestureDetector
goes inside the itemBuilder as its return value
Thank you… I managed to figure it out with much google searching, stackoverflow research etc.
I appreciate your reply
@aifx4intel
Remember that you can always use the final project as a reference when you stumble upon unclear issues.
I thought of that - yet that way will not help me learn (troubleshooting is the best way as far as i understand things)
I am also having issues after adding GestureDetector
I am using the latest Flutter version. I upgraded 3 days ago
itemBuilder: (BuildContext context, int index){
//7
// TOD: Add GestureDetector
return GestureDetector(
//8
onTap: () {
//9
Navigator.push{
context,
MaterialPageRoute(
builder: (context) {
//10
//TOD Replace return with return RecipeDetail()
return Text('Detail Page');
},
),
},
},
//11
child: buildRecipeCard(Recipe.samples[index]),
);
},
I get this error
error: Expected to find ';'. (expected_token at [recipes] lib\main.dart:77)
error: Expected to find ';'. (expected_token at [recipes] lib\main.dart:78)
error: Expected to find ';'. (expected_token at [recipes] lib\main.dart:78)
error: Expected an identifier. (missing_identifier at [recipes] lib\main.dart:78)
error: Unexpected text ','. (unexpected_token at [recipes] lib\main.dart:78)
error: Expected an identifier. (missing_identifier at [recipes] lib\main.dart:85)
error: Unexpected text ','. (unexpected_token at [recipes] lib\main.dart:85)
error: Expected to find ';'. (expected_token at [recipes] lib\main.dart:85)
error: Expected to find ';'. (expected_token at [recipes] lib\main.dart:85)
error: Expected to find ';'. (expected_token at [recipes] lib\main.dart:86)
error: Unexpected text ';'. (unexpected_token at [recipes] lib\main.dart:86)
error: Expected an identifier. (missing_identifier at [recipes] lib\main.dart:86)
info: Prefer const with constant constructors. (prefer_const_constructors at [recipes] lib\main.dart:83)
Attached is a screenshot
Thank you.
I have found the mistake I made.
I put a curly brace next Navigator.push
instead of an open bracket like this: Navigator.push(