Unaconfig class

This class is used to search for configuration files in a directory or directories.

The name is used to search for files with the name in the path, according to the filenamePatterns. The filenamePatterns are regular expressions that are matched against the file name. The paths are the directories to search. If paths is null, the current directory is searched.

The parsers are used to search for the configuration file contents. The parsers are tried in order, and the first one that matches is used. If parsers is null, the default parsers are used. The default parsers are:

  • If the file name matches ^pubspec\.yaml$, the file is parsed as YAML and the name is used as the key to look up the configuration.
  • If the file name matches .*\.json$, the file is parsed as JSON.
  • If the file name matches .*\.ya?ml$, the file is parsed as YAML.

Constructors

Unaconfig(String name, {List<String>? paths, List<String>? filenamePatterns, List<ConfigParser>? parsers, FileSystem fs = const LocalFileSystem()})

Properties

currentDirectory String
The default current directory.
no setter
filenamePatterns List<String>
The regular expressions to match against the file name.
final
fs → FileSystem
The file system to use to search for the configuration.
final
hashCode int
The hash code for this object.
no setterinherited
homeDirectory String
The default home directory of the current user.
no setter
name String
The name of the configuration to search for.
final
parsers List<ConfigParser>
The parsers to use to search for the configuration.
final
paths List<String>
The paths to search for the configuration.
final
projectRoot String
This searches for the project root directory, and falls back to the current directory if no project root is found.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

findConfig() Future<ConfigMatchDetails?>
Search for the configuration file, and return the path and configuration contents.
findPath() Future<String?>
Search for the configuration file, and return the path.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
Search for the configuration.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

defaultFilenamePatterns List<String>
The default search patterns.
final
defaultParsers List<ConfigParser>
The default parsers.
final

Static Methods

getCurrentDirectory(FileSystem fs) String
Get the current directory.
getHomeDirectory(FileSystem fs) String
Get the home directory. The fs is the file system to use to search for the home directory.
getProjectRoot(FileSystem fs) String
Get the project root directory. The fs is the file system to use to search for the project root.