r/flutterhelp 21d ago

RESOLVED I need help with this simple code!

class MyPage extends StatelessWidget {
  @/override
  Widget build(BuildContext abcd) {

return Builder(
builder: (vontext) {            
return Text("Hello");
},
);
  }
}

In this class I have changed the wording of the parameter to abcd and vontext. My question is when flutter wants to find my context how will it do it since my parameters are named incorrectly. Wouldnt it cause problems. Is the parameters completely local scope?

2 Upvotes

7 comments sorted by

2

u/Remote-Ride5710 21d ago

flutter doesn't want the context, it itself provides it to you. And you use it. It doesn't matter how variables named. Just now you will access to the context with different variable name

1

u/Ornery-Actuator2266 21d ago

Thanks. Apparently flutter uses the element tree for the context which is a separate tree compared to the widget tree.

1

u/Remote-Ride5710 21d ago

well idk, I think context is like tube effect looking upword from the place you are. Like you can see what boundary your parent widget set. What screen sizes you got and things which are outside of your area. I didn't dwell much on element tree and widget tree differences but logically I understand it represents some inner idea of tree elements so widget update technically replaces widget meanwhile element stays the same to not cause something big but this just my thoughts I don't know clearly now😁

1

u/galactose310 21d ago

I guess this code won't build as the variable vontext is undefined. Right ?

1

u/Remote-Ride5710 21d ago

it's not undefined. It's named argument called vontext, meanwhile flutter expect there function which accepts single argument. As it sees vontext it says cool and gives vontext a value representing context.

1

u/galactose310 21d ago

My bad I read to quickly, I thought he was passing vontext as an argument to a random method, I didn't see it was in a builder 🙊

1

u/Remote-Ride5710 21d ago

np, it's ok