urldat library

urldat is a micro library that exposes urldat and urldatFactory functions. It is a simple utility that helps you with building URLs in intuitive way while also making sure URLs have correct format.

Example:

urldat('https://example.com/', '/:section/item', parameters: {
  'section': 'users',
  's': 'hello'
  'id': 1,
});

This gives you https://example.com/users/item?s=hello&id=1.

Enums

UrldatErrorId
ID for catching type of errors programatically

Functions

urldat(String base, String pathOrTemplate, {Map<String, dynamic>? parameters, String? scheme, int? port, String? fragment}) String
Function that takes base string URL and pathOrTemplate string URL. pathOrTemplate can be either:
urldatFactory(String base) UrldatConfiguredFn
This function creates a closure around base urldat.urldat function. You pass base string URL to this factory function and closure is returned that allows you to call urldat.urldat without explicitly passing base again. All other arguments like pathOrTemplate and parameters apply. This is simply convenience function to make use of urldat more convenient.

Typedefs

UrldatConfiguredFn = String Function(String pathOrTemplate, {String? fragment, Map<String, dynamic>? parameters, int? port, String? scheme})
UrldatFn = String Function(String base, String pathOrTemplate, {String? fragment, Map<String, dynamic>? parameters, int? port, String? scheme})

Exceptions / Errors

UrldatError
Use this to detect when urldat.urldat throws due to invalid combination of inputs. If you want to detect types of error programatically, use id property which will give you UrldatErrorId identifier.