Skip to content

Commit

Permalink
chore: Adding app cubit to manage isWeb platform bool. #275
Browse files Browse the repository at this point in the history
  • Loading branch information
LuchoTurtle committed Sep 27, 2023
1 parent 43f87b3 commit 0638788
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
4 changes: 3 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ android {
applicationId "com.dwyl.app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion

// Changed because of `gallery_saver` of `flutter_quill`. Though, it will be switched with `gal` in a different PR. Change this back once that occurs
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
8 changes: 8 additions & 0 deletions lib/blocs/cubit/app_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';

part 'app_state.dart';

class AppCubit extends Cubit<AppState> {
AppCubit({required bool isWeb}) : super(AppInitial(isWeb: isWeb));
}
14 changes: 14 additions & 0 deletions lib/blocs/cubit/app_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
part of 'app_cubit.dart';

sealed class AppState extends Equatable {
final bool isWeb;

const AppState({required this.isWeb});

@override
List<Object> get props => [];
}

final class AppInitial extends AppState {
const AppInitial({required super.isWeb});
}
9 changes: 7 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:dwyl_app/blocs/cubit/app_cubit.dart';
import 'package:dwyl_app/logging/logging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';

Expand All @@ -25,8 +27,11 @@ class MainApp extends StatelessWidget {
Bloc.observer = GlobalLogBlocObserver();
putLumberdashToWork(withClients: [ColorizeLumberdash()]);

return BlocProvider(
create: (context) => TodoBloc()..add(TodoListStarted()),
return MultiBlocProvider(
providers: [
BlocProvider<TodoBloc>(create: (context) => TodoBloc()..add(TodoListStarted())),
BlocProvider<AppCubit>(create: (context) => AppCubit(isWeb: kIsWeb)),
],
child: MaterialApp(
home: const HomePage(),
builder: (context, child) => ResponsiveBreakpoints.builder(
Expand Down

0 comments on commit 0638788

Please sign in to comment.