Is runApp() method necessary to create a flutter app?

272

Yes, it's necessary. In dart only execute code inside the main method. Not like JavaScript or Python. It's like java/c. The only execution is the main method.

Share:
272
Ganesh
Author by

Ganesh

Updated on December 26, 2022

Comments

  • Ganesh
    Ganesh over 1 year

    dart code

    I expected this code to paint a black colored rectangle to screen but it didn't .I'm using flutter framework and I want to know that don't flutter support making apps like these or any mistake in my code. I just wanted to make run flutter code without built-in flutter framework library

    }

    • Shubham Narkhede
      Shubham Narkhede over 3 years
      yes is necessary runApp() method to create app
    • dm_tr
      dm_tr over 3 years
      Your main() method must contain runApp(MyApp()). MyApp must be a Stateful or Stateless widget which must return a MaterialApp Widget
    • pskink
      pskink over 3 years
      no, runApp is not necessary, check github.com/flutter/flutter/tree/…, it shows 4 different layers, try 2 first: raw and rendering
    • Ganesh
      Ganesh over 3 years
      Thanks the link cleared my doubt
    • pskink
      pskink over 3 years
      sure, your welcome