phongyewtong
phongyewtong

Reputation: 5319

In flutter and dart is param without type is slower?

Which is faster? with or without the types.

Design 1

home: Builder(
  builder: (BuildContext context) {
    return Home();
  }
)

Design 2

home: Builder(
  builder: (context) {
    return Home();
  }
)

Upvotes: 0

Views: 54

Answers (1)

It's exactly the same at run time.

Dart uses type inference for method arguments. So even if you don't specify it in your "Design 2", the compiler knows that the context argument is of type BuildContext, based one the declaration of the Builder constructor.

Upvotes: 2

Related Questions