MainBlocEvent class abstract

A base class for all Bloc events in the application.

This abstract class serves as a foundation for creating specific event classes that can be used with Blocs. All custom event classes should extend this class.

The const constructor allows for efficient instantiation of event objects.

Usage:

class MySpecificEvent extends MainBlocEvent {
  final String someData;

  const MySpecificEvent(this.someData);
}

// Using the event
bloc.add(MySpecificEvent('Some data'));

Or for freezed:

import 'package:freezed_annotation/freezed_annotation.dart';

part 'my_event.freezed.dart';

@freezed
class MyEvent with _$MyEvent implements MainBlocEvent {
  const factory MyEvent.started() = _Started;
  const factory MyEvent.dataLoaded(String data) = _DataLoaded;
}

// Using the event
bloc.add(const MyEvent.started());
bloc.add(const MyEvent.dataLoaded('Some data'));
Implementers

Constructors

MainBlocEvent()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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