AbiMulya

Content Sizing Cubit without state

Nov 16th, 2021 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.90 KB | None | 0 0
  1. import 'package:equatable/equatable.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:hydrated_bloc/hydrated_bloc.dart';
  4.  
  5. part 'content_sizing_cubit_state.dart';
  6.  
  7. class ContentSizingCubit extends HydratedCubit<double> {
  8.   ContentSizingCubit() : super(12.0);
  9.  
  10.   double textSize = 12.0;
  11.  
  12.   void incrementTextsize() {
  13.     debugPrint('incrementTextSize : true');
  14.     if (textSize >= 10 && textSize < 18) {
  15.       textSize++;
  16.     }
  17.     emit(textSize);
  18.   }
  19.  
  20.   void decrementTextsize() {
  21.     debugPrint('decrementTextSize : true');
  22.     if (textSize > 10 && textSize <= 18) {
  23.       textSize--;
  24.     }
  25.     emit(textSize);
  26.   }
  27.  
  28.   @override
  29.   double? fromJson(Map<String, dynamic> json) {
  30.     // TODO: implement fromJson
  31.     return textSize;
  32.   }
  33.  
  34.   @override
  35.   Map<String, dynamic>? toJson(double textSize) {
  36.     // TODO: implement toJson
  37.     return {'textSize': textSize};
  38.   }
  39. }
  40.  
Add Comment
Please, Sign In to add comment