简体   繁体   English

如何将多个 dart 文件中的字符串传递给 flutter 中的一个 dart 文件?

[英]How to pass strings from multiple dart files and get it to one dart file in flutter?

How to send the data's of different dart files to one dart file in flutter?如何将不同dart文件的数据发送到flutter中的一个dart文件中? I need to get strings from different dart files in a dart file.我需要从 dart 文件中的不同 dart 文件中获取字符串。

Suppose this is the file system of Your project.假设这是您项目的文件系统。

探险家

  • CS.dart and CU.dart are the files where Strings is defined. CS.dartCU.dart是定义字符串的文件。
  • You want to use that Strings in the CategoryScreen.dart file.您想在CategoryScreen.dart文件中使用该字符串。

Then you have to write these lines of code in your CategoryScreen.dart at the top of any other code.然后,您必须在任何其他代码顶部的CategoryScreen.dart中编写这些代码行。

import 'package:demo_app/utils/CS.dart';
import 'package:demo_app/utils/CU.dart';

...REST OF YOUR CODE HERE

暂无
暂无

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

相关问题 将快照数据从一个 dart 文件传递到 flutter 项目中的另一个文件 - Pass Snapshot Data from One dart file to another in flutter project Flutter - 如何将变量从一个飞镖类传递到另一个飞镖类 - Flutter -How to Pass variable from one dart class to another dart class 如何在 flutter dart 中将图像选择器文件从一页传递到另一页? - How to pass image picker file from one page to another in flutter dart? 如何在flutter文件中获取一个.dart文件到另一个.dart文件的变量 - How to get a variable of .dart file to another .dart file in flutter 如何使用 flutter GetX 将“selectedIndex”的值从一个 dart 文件更改为另一个 dart 文件? - How to change the value of 'selectedIndex' from one dart file to the other dart file using flutter GetX? 如何在 flutter 中从一个 dart 文件访问 static 列表到另一个文件? - How to access the static list from one dart file to another in flutter? 如何从flutter dart中firebasestorage中该文件的链接获取文件名 - How to get name of a file from the link of that file in firebasestorage in flutter dart Flutter Dart with Firestore,如何从一个集合中获取参考文档? - Flutter Dart with Firestore, How to get referenced document from one collection? Flutter:从另一个 Dart 文件获取 AlertDialog - Flutter : Get AlertDialog From Another Dart File 如何从颤动的另一个飞镖文件中获取地图长度? - How to get Map length from another dart file in flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM