简体   繁体   English

Flutter:如何将文件引用到 main.dart?

[英]Flutter: How to reference files into main.dart?

This is a screenshot of my main.dart file: https://i.stack.imgur.com/9WGQj.png这是我的 main.dart 文件的截图: https://i.stack.imgur.com/9WGQj.png

And a screenshot of my home_page.dart file which I want to reference INTO main.dart: https://i.stack.imgur.com/U8TeS.png还有我的 home_page.dart 文件的屏幕截图,我想参考 INTO main.dart: https://i.stack.imgur.com/UTe8

How do I reference the home_page.dart file?如何引用 home_page.dart 文件?

Your class name _LoginPage has underscore in front of the name, which means it's private and can't be imported in any other file.您的 class 名称_LoginPage名称前面有下划线,这意味着它是私有的,不能在任何其他文件中导入。 To make it visible, remove underscore from the name (ie, LoginPage ).要使其可见,请从名称中删除下划线(即LoginPage )。 And you have to import main.dart inside of home_page.dart file to import MyApp class.您必须在home_page.dart文件中导入main.dart才能导入MyApp class。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM