Issue
I created some dart files from AdobeXD (applebutton.dart, background.dart, googlebutton.dart). However, I don't know how to call these files from the main.dart file.
I can copy and paste part of these AbodeXD generated files into the main.dart file, but I believe there must be a way to call these files without making main.dart bigger.
Inside class MyApp> Widget> body> children, I pasted the Container from background.dart, but I want to call the Widget instead of copying it.
(I am new in flutter so thanks for your answer).
Solution
These all pages have main function. It's not understandable for Dart. Dart files search main function to start, this is why you must use just one main function into your main.dart file.
To use your other screens in the main.dart file, use import keyword on the top of your main.dart files and write the page's path.
The screens must extends with StatelessWidget or StatefulWidget. You're not compile your entire application when you want to show another page, so you dont need to use main() function in each page.
Answered By - notdeveloper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.