Home > Blockchain >  AsyncLoading VS AsyncValue.loading
AsyncLoading VS AsyncValue.loading

Time:01-11

I am trying to create Auth and Todo app. The problem is that I don't know which is the correct usage and don't know the difference between the two.

I want to use it before adding an item to the Todo List.

Is there a clear distinction between them, or do they have the same meaning?

I saw common.dart file but it written like this.

 /// Creates an [AsyncValue] in loading state.
  ///
  /// Prefer always using this constructor with the `const` keyword.
  // coverage:ignore-start
 const factory AsyncValue.loading() = AsyncLoading<T>;```

CodePudding user response:

They are the same. AsyncData, AsyncError and AsyncLoading are just syntax sugar for different states of AsyncValue

here is the implementation from the library, it is indeed the same.

  const factory AsyncValue.data(T value) = AsyncData<T>;

  const factory AsyncValue.loading() = AsyncLoading<T>;
  • Related