What is difference between path and absolute.path

What is difference between path and absolute.path?
Can you open it with an example where we need to use absolute path?
can we do the same thing with just path without using absolute path?

Upvotes: 0

Views: 785

Answers (1)

Luis Utrera
Luis Utrera

Reputation: 1067

The absolute path is the path to a file from the main directory. For example: the absolute path towards a file of my current project is import 'package:projectname/shared/presentation/widgets/image_asset_widget.dart';

this file is in the folders lib>shared>presentation>widgets But, if I need to reference the very same file from lib>shared>presentation path, I just need to call ./image_asset_widget.dart since it's in the same directory as my current file.

Long story short: absolute path is the same from wherever you call it, as it starts at the root directory (in this case, lib); while the relative path is changes depending on the location of the file that's referencing it. It's the way that the current file needs to get through to reach the referenced file.

A little bit more of info here

Upvotes: 2

Related Questions