Skip to content
Snippets Groups Projects
Select Git revision
  • d90c2fa31c6fe18977dbc22c597cbb8df7e66ea3
  • master default protected
  • 82-reword-settings
  • 67-improve-app-metadata
  • 54-improve-discoveries-page
  • 7-add-lastfm-link
  • Release_0.9.1_78 protected
  • Release_0.9.0_77 protected
  • Release_0.8.4_76 protected
  • Release_0.8.3_75 protected
  • Release_0.8.2_74 protected
  • Release_0.8.1_73 protected
  • Release_0.8.0_72 protected
  • Release_0.7.0_71 protected
  • Release_0.6.0_70 protected
  • Release_0.5.0_69 protected
  • Release_0.4.2_68 protected
  • Release_0.4.1_67 protected
  • Release_0.4.0_66 protected
  • Release_0.3.1_65 protected
  • Release_0.3.0_64 protected
  • Release_0.2.2_63 protected
  • Release_0.2.1_62 protected
  • Release_0.2.0_61 protected
  • Release_0.1.2_60 protected
  • Release_0.1.1_59 protected
26 results

data_discoveries_cubit.dart

Blame
  • data_timeline_cubit.dart 1.02 KiB
    import 'package:equatable/equatable.dart';
    import 'package:flutter/material.dart';
    import 'package:hydrated_bloc/hydrated_bloc.dart';
    
    import 'package:scrobbles/models/timeline.dart';
    
    part 'data_timeline_state.dart';
    
    class DataTimelineCubit extends HydratedCubit<DataTimelineState> {
      DataTimelineCubit() : super(const DataTimelineState());
    
      void getData(DataTimelineState state) {
        emit(state);
      }
    
      TimelineData? getValue() {
        return state.timeline;
      }
    
      void update(TimelineData? timeline) {
        if (state.timeline.toString() != timeline.toString()) {
          setValue(timeline);
        }
      }
    
      void setValue(TimelineData? timeline) {
        emit(DataTimelineState(
          timeline: timeline,
        ));
      }
    
      @override
      DataTimelineState? fromJson(Map<String, dynamic> json) {
        return DataTimelineState(
          timeline: TimelineData.fromJson(json['timeline']),
        );
      }
    
      @override
      Map<String, Object?>? toJson(DataTimelineState state) {
        return <String, Object?>{
          'timeline': state.timeline?.toJson(),
        };
      }
    }