FlutterDartProject.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2013 The Flutter Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef FLUTTER_FLUTTERDARTPROJECT_H_
  5. #define FLUTTER_FLUTTERDARTPROJECT_H_
  6. #import <Foundation/Foundation.h>
  7. #include "FlutterMacros.h"
  8. NS_ASSUME_NONNULL_BEGIN
  9. /**
  10. * A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution.
  11. */
  12. FLUTTER_EXPORT
  13. @interface FlutterDartProject : NSObject
  14. /**
  15. * Initializes a Flutter Dart project from a bundle.
  16. */
  17. - (instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle NS_DESIGNATED_INITIALIZER;
  18. /**
  19. * Unavailable - use `init` instead.
  20. */
  21. - (instancetype)initFromDefaultSourceForConfiguration FLUTTER_UNAVAILABLE("Use -init instead.");
  22. /**
  23. * Returns the file name for the given asset. If the bundle with the identifier
  24. * "io.flutter.flutter.app" exists, it will try use that bundle; otherwise, it
  25. * will use the main bundle. To specify a different bundle, use
  26. * `-lookupKeyForAsset:asset:fromBundle`.
  27. *
  28. * @param asset The name of the asset. The name can be hierarchical.
  29. * @return the file name to be used for lookup in the main bundle.
  30. */
  31. + (NSString*)lookupKeyForAsset:(NSString*)asset;
  32. /**
  33. * Returns the file name for the given asset.
  34. * The returned file name can be used to access the asset in the supplied bundle.
  35. *
  36. * @param asset The name of the asset. The name can be hierarchical.
  37. * @param bundle The `NSBundle` to use for looking up the asset.
  38. * @return the file name to be used for lookup in the main bundle.
  39. */
  40. + (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle;
  41. /**
  42. * Returns the file name for the given asset which originates from the specified package.
  43. * The returned file name can be used to access the asset in the application's main bundle.
  44. *
  45. * @param asset The name of the asset. The name can be hierarchical.
  46. * @param package The name of the package from which the asset originates.
  47. * @return the file name to be used for lookup in the main bundle.
  48. */
  49. + (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
  50. /**
  51. * Returns the file name for the given asset which originates from the specified package.
  52. * The returned file name can be used to access the asset in the specified bundle.
  53. *
  54. * @param asset The name of the asset. The name can be hierarchical.
  55. * @param package The name of the package from which the asset originates.
  56. * @param bundle The bundle to use when doing the lookup.
  57. * @return the file name to be used for lookup in the main bundle.
  58. */
  59. + (NSString*)lookupKeyForAsset:(NSString*)asset
  60. fromPackage:(NSString*)package
  61. fromBundle:(nullable NSBundle*)bundle;
  62. /**
  63. * Returns the default identifier for the bundle where we expect to find the Flutter Dart
  64. * application.
  65. */
  66. + (NSString*)defaultBundleIdentifier;
  67. @end
  68. NS_ASSUME_NONNULL_END
  69. #endif // FLUTTER_FLUTTERDARTPROJECT_H_