repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/lib/domain/failures/failures.dart
import 'package:equatable/equatable.dart'; abstract class Failure{} class ServerFailure extends Failure with EquatableMixin { @override List<Object?> get props => []; } class GeneralFailure extends Failure with EquatableMixin{ @override List<Object?> get props => []; } class CacheFailure extends Failure with EquatableMixin{ @override List<Object?> get props => []; }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/lib/domain/entities/advice_Enitity.dart
class AdviceEntity { final String advice; final int id; AdviceEntity({required this.advice, required this.id}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/lib/domain/usecases/advicer_usecases.dart
import 'package:advicer/domain/entities/advice_enitity.dart'; import 'package:advicer/domain/failures/failures.dart'; import 'package:advicer/domain/reposetories/advicer_repository.dart'; import 'package:dartz/dartz.dart'; class AdvicerUsecases { final AdvicerRepository advicerRepository; AdvicerUsecases({required this.advicerRepository}); Future<Either<Failure, AdviceEntity>> getAdviceUsecase() async { // call function from repository to get advice return advicerRepository.getAdviceFromApi(); // Buisness logic implementieren z.b. rechnung etc } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application/advicer/advice_bloc_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/application/advicer/advice_bloc_test.dart. // Do not manually edit this file. import 'dart:async' as _i5; import 'package:advicer/domain/entities/advice_enitity.dart' as _i7; import 'package:advicer/domain/failures/failures.dart' as _i6; import 'package:advicer/domain/reposetories/advicer_repository.dart' as _i2; import 'package:advicer/domain/usecases/advicer_usecases.dart' as _i4; import 'package:dartz/dartz.dart' as _i3; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis class _FakeAdvicerRepository_0 extends _i1.Fake implements _i2.AdvicerRepository {} class _FakeEither_1<L, R> extends _i1.Fake implements _i3.Either<L, R> {} /// A class which mocks [AdvicerUsecases]. /// /// See the documentation for Mockito's code generation for more information. class MockAdvicerUsecases extends _i1.Mock implements _i4.AdvicerUsecases { MockAdvicerUsecases() { _i1.throwOnMissingStub(this); } @override _i2.AdvicerRepository get advicerRepository => (super.noSuchMethod(Invocation.getter(#advicerRepository), returnValue: _FakeAdvicerRepository_0()) as _i2.AdvicerRepository); @override _i5.Future<_i3.Either<_i6.Failure, _i7.AdviceEntity>> getAdviceUsecase() => (super.noSuchMethod(Invocation.method(#getAdviceUsecase, []), returnValue: Future<_i3.Either<_i6.Failure, _i7.AdviceEntity>>.value( _FakeEither_1<_i6.Failure, _i7.AdviceEntity>())) as _i5 .Future<_i3.Either<_i6.Failure, _i7.AdviceEntity>>); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application/advicer/advice_bloc_test.dart
import 'package:advicer/application/advicer/advicer_bloc.dart'; import 'package:advicer/domain/entities/advice_enitity.dart'; import 'package:advicer/domain/failures/failures.dart'; import 'package:advicer/domain/usecases/advicer_usecases.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'advice_bloc_test.mocks.dart'; @GenerateMocks([AdvicerUsecases]) void main() { late AdvicerBloc advicerBloc; late MockAdvicerUsecases mockAdvicerUsecases; setUp(() { mockAdvicerUsecases = MockAdvicerUsecases(); advicerBloc = AdvicerBloc(usecases: mockAdvicerUsecases); }); test(" initState should be AdvicerInitial", () { // assert expect(advicerBloc.state, equals(AdvicerInitial())); }); group("AdviceRequestedEvent", () { final t_advice = AdviceEntity(advice: "test", id: 1); const t_advice_string = "test"; test("should call usecase if event is added", () async { // arrange when(mockAdvicerUsecases.getAdviceUsecase()) .thenAnswer((_) async => Right(t_advice)); //act advicerBloc.add(AdviceRequestedEvent()); await untilCalled(mockAdvicerUsecases.getAdviceUsecase()); // assert verify(mockAdvicerUsecases.getAdviceUsecase()); verifyNoMoreInteractions(mockAdvicerUsecases); }); test("should emmit loading then the loaded state after event is added", () async { // arrange when(mockAdvicerUsecases.getAdviceUsecase()) .thenAnswer((_) async => Right(t_advice)); //assert later final expected = [ AdvicerStateLoading(), AdvicerStateLoaded(advice: t_advice_string) ]; expectLater(advicerBloc.stream, emitsInOrder(expected)); // act advicerBloc.add(AdviceRequestedEvent()); }); test( "should emmit loading then the error state after event is added -> usecase fails -> server failure", () async { // arrange when(mockAdvicerUsecases.getAdviceUsecase()) .thenAnswer((_) async => Left(ServerFailure())); //assert later final expected = [ AdvicerStateLoading(), AdvicerStateError(message: SERVER_FAILURE_MESSAGE) ]; expectLater(advicerBloc.stream, emitsInOrder(expected)); // act advicerBloc.add(AdviceRequestedEvent()); }); test( "should emmit loading then the error state after event is added -> usecase fails -> general failure", () async { // arrange when(mockAdvicerUsecases.getAdviceUsecase()) .thenAnswer((_) async => Left(GeneralFailure())); //assert later final expected = [ AdvicerStateLoading(), AdvicerStateError(message: GENERAL_FAILURE_MESSAGE) ]; expectLater(advicerBloc.stream, emitsInOrder(expected)); // act advicerBloc.add(AdviceRequestedEvent()); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application/theme/theme_service_test.dart
import 'package:advicer/application/theme/theme_service.dart'; import 'package:advicer/domain/failures/failures.dart'; import 'package:advicer/domain/reposetories/theme_repositroy.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'theme_service_test.mocks.dart'; @GenerateMocks([ThemeRepository]) void main() { late MockThemeRepository mockThemeRepository; late ThemeService themeService; late int listenerCount; setUp(() { listenerCount = 0; mockThemeRepository = MockThemeRepository(); themeService = ThemeServiceImpl(themeRepository: mockThemeRepository) ..addListener(() { listenerCount += 1; }); }); test("check if defaoult value for darkmode is true", () { // assert expect(themeService.isDarkModeOn, true); }); group("setThemeMode", () { const t_mode = false; test( "should set the theme to the parameter it gets, store theme information", () async { //arragen themeService.isDarkModeOn = true; when(mockThemeRepository.setThemeMode(mode: anyNamed("mode"))) .thenAnswer((_) async => true); // act await themeService.setTheme(mode: t_mode); //assert expect(themeService.isDarkModeOn, t_mode); verify(mockThemeRepository.setThemeMode(mode: t_mode)); expect(listenerCount, 1); }); }); group("toggleThemeMode", () { const t_mode = false; test("should toggle current theme mode, store theme information", () async { //arragen themeService.isDarkModeOn = true; when(mockThemeRepository.setThemeMode(mode: anyNamed("mode"))) .thenAnswer((_) async => true); // act await themeService.toggleTheme(); //assert expect(themeService.isDarkModeOn, t_mode); verify(mockThemeRepository.setThemeMode(mode: t_mode)); expect(listenerCount, 1); }); }); group("init", () { const t_mode = false; test( "should get a theme mode from local data source and use it and notify listeners", () async { //arrage themeService.useSystemTheme = false; when(mockThemeRepository.getUseSytemTheme()) .thenAnswer((_) async => const Right(false)); themeService.isDarkModeOn = true; when(mockThemeRepository.getThemeMode()) .thenAnswer((_) async => const Right(t_mode)); when(mockThemeRepository.setThemeMode(mode: anyNamed("mode"))) .thenAnswer((_) async => true); when(mockThemeRepository.setUseSytemTheme(useSystemTheme: false)) .thenAnswer((_) async => true); // act await themeService.init(); //assert expect(themeService.isDarkModeOn, t_mode); verify(mockThemeRepository.getThemeMode()); expect(listenerCount, 2); }); test( "should start with dark mode if no theme is returned from local source and notify listeners", () async { //arrage themeService.isDarkModeOn = true; when(mockThemeRepository.getThemeMode()) .thenAnswer((_) async => Left(CacheFailure())); themeService.useSystemTheme = false; when(mockThemeRepository.getUseSytemTheme()) .thenAnswer((_) async => const Right(false)); when(mockThemeRepository.setThemeMode(mode: anyNamed("mode"))) .thenAnswer((_) async => true); when(mockThemeRepository.setUseSytemTheme(useSystemTheme: false)) .thenAnswer((_) async => true); // act await themeService.init(); //assert expect(themeService.isDarkModeOn, true); verify(mockThemeRepository.getThemeMode()); expect(listenerCount, 2); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/application/theme/theme_service_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/application/theme/theme_service_test.dart. // Do not manually edit this file. import 'dart:async' as _i4; import 'package:advicer/domain/failures/failures.dart' as _i5; import 'package:advicer/domain/reposetories/theme_repositroy.dart' as _i3; import 'package:dartz/dartz.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis class _FakeEither_0<L, R> extends _i1.Fake implements _i2.Either<L, R> {} /// A class which mocks [ThemeRepository]. /// /// See the documentation for Mockito's code generation for more information. class MockThemeRepository extends _i1.Mock implements _i3.ThemeRepository { MockThemeRepository() { _i1.throwOnMissingStub(this); } @override _i4.Future<_i2.Either<_i5.Failure, bool>> getThemeMode() => (super.noSuchMethod(Invocation.method(#getThemeMode, []), returnValue: Future<_i2.Either<_i5.Failure, bool>>.value( _FakeEither_0<_i5.Failure, bool>())) as _i4.Future<_i2.Either<_i5.Failure, bool>>); @override _i4.Future<void> setThemeMode({bool? mode}) => (super.noSuchMethod(Invocation.method(#setThemeMode, [], {#mode: mode}), returnValue: Future<void>.value(), returnValueForMissingStub: Future<void>.value()) as _i4.Future<void>); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/fixtures/fixture_reader.dart
import 'dart:io'; String fixture(String name) => File('test/fixtures/$name').readAsStringSync();
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/models/advice_model_test.dart
import 'dart:convert'; import 'package:advicer/domain/entities/advice_enitity.dart'; import 'package:advicer/infrastructure/models/advice_model.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../fixtures/fixture_reader.dart'; void main(){ final t_AdviceModel = AdviceModel(advice: "test", id: 1); test("model should be subclass of advice-entity", (){ //assert expect(t_AdviceModel, isA<AdviceEntity>()); }); group("fromJson factory", (){ test("should return a valid model if the JSON advice is correct", (){ //arrange final Map<String,dynamic> jsonMap = json.decode(fixture("advice.json")); // act final result = AdviceModel.fromJson(jsonMap); //assert expect(result, t_AdviceModel); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/repositories/theme_repository_test.dart
import 'package:advicer/domain/failures/failures.dart'; import 'package:advicer/domain/reposetories/theme_repositroy.dart'; import 'package:advicer/infrastructure/datasources/theme_local_datasource.dart'; import 'package:advicer/infrastructure/exceptions/exceptions.dart'; import 'package:advicer/infrastructure/repositories/theme_repository_impl.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'theme_repository_test.mocks.dart'; @GenerateMocks([ThemeLocalDatasource]) void main() { late MockThemeLocalDatasource mockThemeLocalDatasource; late ThemeRepository themeRepository; setUp(() { mockThemeLocalDatasource = MockThemeLocalDatasource(); themeRepository = ThemeRespositoryImpl(themeLocalDatasource: mockThemeLocalDatasource); }); group("getThemeMode", () { const t_themeMode = true; test("should return theme mode if cached data is present", () async { // arrange when(mockThemeLocalDatasource.getCachedThemeData()) .thenAnswer((_) async => t_themeMode); // act final result = await themeRepository.getThemeMode(); // assert expect(result, const Right(t_themeMode)); verify(mockThemeLocalDatasource.getCachedThemeData()); verifyNoMoreInteractions(mockThemeLocalDatasource); }); test( "should return CacheFailure if local datasource throws a chache exeption", () async { // arrange when(mockThemeLocalDatasource.getCachedThemeData()) .thenThrow(CacheException()); // act final result = await themeRepository.getThemeMode(); // assert expect(result, Left(CacheFailure())); verify(mockThemeLocalDatasource.getCachedThemeData()); verifyNoMoreInteractions(mockThemeLocalDatasource); }); }); group("setThemeMode", () { const t_themeMode = true; test("should call function to chache theme mode in local datasource", () { //arrange when(mockThemeLocalDatasource.cacheThemeData(mode: anyNamed("mode"))) .thenAnswer((_) async => true); // act themeRepository.setThemeMode(mode: t_themeMode); // assert verify(mockThemeLocalDatasource.cacheThemeData(mode: t_themeMode)); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/repositories/advicer_repository_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/infrastructure/repositories/advicer_repository_test.dart. // Do not manually edit this file. import 'dart:async' as _i4; import 'package:advicer/domain/entities/advice_enitity.dart' as _i2; import 'package:advicer/infrastructure/datasources/advicer_remote_datasource.dart' as _i3; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis class _FakeAdviceEntity_0 extends _i1.Fake implements _i2.AdviceEntity {} /// A class which mocks [AdvicerRemoteDatasource]. /// /// See the documentation for Mockito's code generation for more information. class MockAdvicerRemoteDatasource extends _i1.Mock implements _i3.AdvicerRemoteDatasource { MockAdvicerRemoteDatasource() { _i1.throwOnMissingStub(this); } @override _i4.Future<_i2.AdviceEntity> getRandomAdviceFromApi() => (super.noSuchMethod( Invocation.method(#getRandomAdviceFromApi, []), returnValue: Future<_i2.AdviceEntity>.value(_FakeAdviceEntity_0())) as _i4.Future<_i2.AdviceEntity>); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/repositories/advicer_repository_test.dart
import 'package:advicer/domain/entities/advice_enitity.dart'; import 'package:advicer/domain/failures/failures.dart'; import 'package:advicer/domain/reposetories/advicer_repository.dart'; import 'package:advicer/infrastructure/datasources/advicer_remote_datasource.dart'; import 'package:advicer/infrastructure/exceptions/exceptions.dart'; import 'package:advicer/infrastructure/models/advice_model.dart'; import 'package:advicer/infrastructure/repositories/advicer_repository_impl.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'advicer_repository_test.mocks.dart'; @GenerateMocks([AdvicerRemoteDatasource]) void main(){ late AdvicerRepository advicerRepository; late MockAdvicerRemoteDatasource mockAdvicerRemoteDatasource; setUp((){ mockAdvicerRemoteDatasource = MockAdvicerRemoteDatasource(); advicerRepository = AdvicerRepositoryImpl(advicerRemoteDatasource: mockAdvicerRemoteDatasource); }); group("getAdviceFromAPI", (){ final t_AdviceModel = AdviceModel(advice: "test", id: 1); final AdviceEntity t_advice = t_AdviceModel; test("should return remote data if the call to remote datasource is successfull", ()async{ // arrange when(mockAdvicerRemoteDatasource.getRandomAdviceFromApi()).thenAnswer((_) async => t_AdviceModel); // act final result = await advicerRepository.getAdviceFromApi(); // assert verify(mockAdvicerRemoteDatasource.getRandomAdviceFromApi()); expect(result, Right(t_advice)); verifyNoMoreInteractions(mockAdvicerRemoteDatasource); }); test("should return server failure if datasource throws server-excepiton", ()async{ //arrange when(mockAdvicerRemoteDatasource.getRandomAdviceFromApi()).thenThrow(SeverException()); //act final result = await advicerRepository.getAdviceFromApi(); //assert verify(mockAdvicerRemoteDatasource.getRandomAdviceFromApi()); expect(result, Left(ServerFailure())); verifyNoMoreInteractions(mockAdvicerRemoteDatasource); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/repositories/theme_repository_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/infrastructure/repositories/theme_repository_test.dart. // Do not manually edit this file. import 'dart:async' as _i3; import 'package:advicer/infrastructure/datasources/theme_local_datasource.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis /// A class which mocks [ThemeLocalDatasource]. /// /// See the documentation for Mockito's code generation for more information. class MockThemeLocalDatasource extends _i1.Mock implements _i2.ThemeLocalDatasource { MockThemeLocalDatasource() { _i1.throwOnMissingStub(this); } @override _i3.Future<bool> getCachedThemeData() => (super.noSuchMethod(Invocation.method(#getCachedThemeData, []), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<void> cacheThemeData({bool? mode}) => (super.noSuchMethod(Invocation.method(#cacheThemeData, [], {#mode: mode}), returnValue: Future<void>.value(), returnValueForMissingStub: Future<void>.value()) as _i3.Future<void>); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/datsources/theme_local_datasource_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/infrastructure/datsources/theme_local_datasource_test.dart. // Do not manually edit this file. import 'dart:async' as _i3; import 'package:mockito/mockito.dart' as _i1; import 'package:shared_preferences/shared_preferences.dart' as _i2; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis /// A class which mocks [SharedPreferences]. /// /// See the documentation for Mockito's code generation for more information. class MockSharedPreferences extends _i1.Mock implements _i2.SharedPreferences { MockSharedPreferences() { _i1.throwOnMissingStub(this); } @override Set<String> getKeys() => (super.noSuchMethod(Invocation.method(#getKeys, []), returnValue: <String>{}) as Set<String>); @override Object? get(String? key) => (super.noSuchMethod(Invocation.method(#get, [key])) as Object?); @override bool? getBool(String? key) => (super.noSuchMethod(Invocation.method(#getBool, [key])) as bool?); @override int? getInt(String? key) => (super.noSuchMethod(Invocation.method(#getInt, [key])) as int?); @override double? getDouble(String? key) => (super.noSuchMethod(Invocation.method(#getDouble, [key])) as double?); @override String? getString(String? key) => (super.noSuchMethod(Invocation.method(#getString, [key])) as String?); @override bool containsKey(String? key) => (super.noSuchMethod(Invocation.method(#containsKey, [key]), returnValue: false) as bool); @override List<String>? getStringList(String? key) => (super.noSuchMethod(Invocation.method(#getStringList, [key])) as List<String>?); @override _i3.Future<bool> setBool(String? key, bool? value) => (super.noSuchMethod(Invocation.method(#setBool, [key, value]), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> setInt(String? key, int? value) => (super.noSuchMethod(Invocation.method(#setInt, [key, value]), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> setDouble(String? key, double? value) => (super.noSuchMethod(Invocation.method(#setDouble, [key, value]), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> setString(String? key, String? value) => (super.noSuchMethod(Invocation.method(#setString, [key, value]), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> setStringList(String? key, List<String>? value) => (super.noSuchMethod(Invocation.method(#setStringList, [key, value]), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> remove(String? key) => (super.noSuchMethod(Invocation.method(#remove, [key]), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> commit() => (super.noSuchMethod(Invocation.method(#commit, []), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<bool> clear() => (super.noSuchMethod(Invocation.method(#clear, []), returnValue: Future<bool>.value(false)) as _i3.Future<bool>); @override _i3.Future<void> reload() => (super.noSuchMethod(Invocation.method(#reload, []), returnValue: Future<void>.value(), returnValueForMissingStub: Future<void>.value()) as _i3.Future<void>); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/datsources/theme_local_datasource_test.dart
import 'package:advicer/infrastructure/datasources/theme_local_datasource.dart'; import 'package:advicer/infrastructure/exceptions/exceptions.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'theme_local_datasource_test.mocks.dart'; @GenerateMocks([SharedPreferences]) void main(){ late ThemeLocalDatasource themeLocalDatasource; late MockSharedPreferences mockSharedPreferences; setUp((){ mockSharedPreferences = MockSharedPreferences(); themeLocalDatasource = ThemeLocalDatasourceImpl(sharedPreferences: mockSharedPreferences); }); group("getCachedThemeData", (){ const t_themeData = true; test("should return a bool ( themeData) if there is one in sharedPreferences", ()async{ // arrange when(mockSharedPreferences.getBool(any)).thenReturn(t_themeData); //act final result = await themeLocalDatasource.getCachedThemeData(); //assert verify(mockSharedPreferences.getBool(CACHED_THEME_MODE)); expect(result, t_themeData); }); test("should return a CacheException if there is no theme data in sharedPreferences", ()async{ // arrange when(mockSharedPreferences.getBool(any)).thenReturn(null); //act final call = themeLocalDatasource.getCachedThemeData; //assert expect(()=> call(), throwsA(const TypeMatcher<CacheException>())); }); }) ; group("cacheThemeData", (){ const t_themeData = true; test("should call shared preferences to cache theme mode", ()async { when(mockSharedPreferences.setBool(any, any)).thenAnswer((_) async => true); // act await themeLocalDatasource.cacheThemeData(mode: t_themeData); //assert verify(mockSharedPreferences.setBool(CACHED_THEME_MODE, t_themeData)); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/datsources/advice_remote_datsource_test.dart
import 'package:advicer/infrastructure/datasources/advicer_remote_datasource.dart'; import 'package:advicer/infrastructure/exceptions/exceptions.dart'; import 'package:advicer/infrastructure/models/advice_model.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart' as http; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import '../../fixtures/fixture_reader.dart'; import 'advice_remote_datsource_test.mocks.dart'; @GenerateMocks([http.Client]) void main() { late AdvicerRemoteDatasource advicerRemoteDatasource; late MockClient mockClient; setUp(() { mockClient = MockClient(); advicerRemoteDatasource = AdvicerRemoteDatasourceImpl(client: mockClient); }); void setUpMockClientSuccess200() { //arrange when(mockClient.get(any, headers: anyNamed("headers"))).thenAnswer( (_) async => http.Response(fixture("advice_http_respond.json"), 200)); } void setUpMockClientFailure404() { //arrange when(mockClient.get(any, headers: anyNamed("headers"))) .thenAnswer((_) async => http.Response("something went wrong", 404)); } group("getRandomAdviceFromApi", () { final t_AdviceModel = AdviceModel(advice: "test", id: 1); test( "should perform a get request on a URL with advice being the endpoint and header appliction/json", () { //arrange setUpMockClientSuccess200(); // act advicerRemoteDatasource.getRandomAdviceFromApi(); //assert verify(mockClient.get( Uri.parse("https://api.adviceslip.com/advice"), headers: { 'Content-Type': 'application/json', }, )); }); test("should return a valid advice when the response is a succsess 200", () async { //arrange setUpMockClientSuccess200(); // act final result = await advicerRemoteDatasource.getRandomAdviceFromApi(); //assert expect(result, t_AdviceModel); }); test("should thrwo ServerException if the response code is not 200", () { //arrange setUpMockClientFailure404(); // act final call = advicerRemoteDatasource.getRandomAdviceFromApi; //assert expect(()=> call(), throwsA( const TypeMatcher<SeverException>())); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/infrastructure/datsources/advice_remote_datsource_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/infrastructure/datsources/advice_remote_datsource_test.dart. // Do not manually edit this file. import 'dart:async' as _i5; import 'dart:convert' as _i6; import 'dart:typed_data' as _i7; import 'package:http/src/base_request.dart' as _i8; import 'package:http/src/client.dart' as _i4; import 'package:http/src/response.dart' as _i2; import 'package:http/src/streamed_response.dart' as _i3; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis class _FakeResponse_0 extends _i1.Fake implements _i2.Response {} class _FakeStreamedResponse_1 extends _i1.Fake implements _i3.StreamedResponse { } /// A class which mocks [Client]. /// /// See the documentation for Mockito's code generation for more information. class MockClient extends _i1.Mock implements _i4.Client { MockClient() { _i1.throwOnMissingStub(this); } @override _i5.Future<_i2.Response> head(Uri? url, {Map<String, String>? headers}) => (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}), returnValue: Future<_i2.Response>.value(_FakeResponse_0())) as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> get(Uri? url, {Map<String, String>? headers}) => (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), returnValue: Future<_i2.Response>.value(_FakeResponse_0())) as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> post(Uri? url, {Map<String, String>? headers, Object? body, _i6.Encoding? encoding}) => (super.noSuchMethod( Invocation.method(#post, [url], {#headers: headers, #body: body, #encoding: encoding}), returnValue: Future<_i2.Response>.value(_FakeResponse_0())) as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> put(Uri? url, {Map<String, String>? headers, Object? body, _i6.Encoding? encoding}) => (super.noSuchMethod( Invocation.method(#put, [url], {#headers: headers, #body: body, #encoding: encoding}), returnValue: Future<_i2.Response>.value(_FakeResponse_0())) as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> patch(Uri? url, {Map<String, String>? headers, Object? body, _i6.Encoding? encoding}) => (super.noSuchMethod( Invocation.method(#patch, [url], {#headers: headers, #body: body, #encoding: encoding}), returnValue: Future<_i2.Response>.value(_FakeResponse_0())) as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> delete(Uri? url, {Map<String, String>? headers, Object? body, _i6.Encoding? encoding}) => (super.noSuchMethod( Invocation.method(#delete, [url], {#headers: headers, #body: body, #encoding: encoding}), returnValue: Future<_i2.Response>.value(_FakeResponse_0())) as _i5.Future<_i2.Response>); @override _i5.Future<String> read(Uri? url, {Map<String, String>? headers}) => (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}), returnValue: Future<String>.value('')) as _i5.Future<String>); @override _i5.Future<_i7.Uint8List> readBytes(Uri? url, {Map<String, String>? headers}) => (super.noSuchMethod( Invocation.method(#readBytes, [url], {#headers: headers}), returnValue: Future<_i7.Uint8List>.value(_i7.Uint8List(0))) as _i5.Future<_i7.Uint8List>); @override _i5.Future<_i3.StreamedResponse> send(_i8.BaseRequest? request) => (super.noSuchMethod(Invocation.method(#send, [request]), returnValue: Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_1())) as _i5.Future<_i3.StreamedResponse>); @override void close() => super.noSuchMethod(Invocation.method(#close, []), returnValueForMissingStub: null); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/domain/usecases/advicer_usecases_test.dart
import 'package:advicer/domain/entities/advice_enitity.dart'; import 'package:advicer/domain/failures/failures.dart'; import 'package:advicer/domain/reposetories/advicer_repository.dart'; import 'package:advicer/domain/usecases/advicer_usecases.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'advicer_usecases_test.mocks.dart'; @GenerateMocks([AdvicerRepository]) void main() { late AdvicerUsecases advicerUsecases; late MockAdvicerRepository mockAdvicerRepository; setUp(() { mockAdvicerRepository = MockAdvicerRepository(); advicerUsecases = AdvicerUsecases(advicerRepository: mockAdvicerRepository); }); group("getAdviceUsecase", () { final t_Advice = AdviceEntity(advice: "test", id: 1); test("should return the same advice as repo", () async { // arrange when(mockAdvicerRepository.getAdviceFromApi()) .thenAnswer((_) async => Right(t_Advice)); // act final result = await advicerUsecases.getAdviceUsecase(); // assert expect(result, Right(t_Advice)); verify(mockAdvicerRepository.getAdviceFromApi()); verifyNoMoreInteractions(mockAdvicerRepository); }); test("should return the same failure as repo", () async { // arrange when(mockAdvicerRepository.getAdviceFromApi()) .thenAnswer((_) async => Left(ServerFailure())); // act final result = await advicerUsecases.getAdviceUsecase(); // assert expect(result, Left(ServerFailure())); verify(mockAdvicerRepository.getAdviceFromApi()); verifyNoMoreInteractions(mockAdvicerRepository); }); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/domain/usecases/advicer_usecases_test.mocks.dart
// Mocks generated by Mockito 5.0.15 from annotations // in advicer/test/domain/usecases/advicer_usecases_test.dart. // Do not manually edit this file. import 'dart:async' as _i4; import 'package:advicer/domain/entities/advice_enitity.dart' as _i6; import 'package:advicer/domain/failures/failures.dart' as _i5; import 'package:advicer/domain/reposetories/advicer_repository.dart' as _i3; import 'package:dartz/dartz.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis class _FakeEither_0<L, R> extends _i1.Fake implements _i2.Either<L, R> {} /// A class which mocks [AdvicerRepository]. /// /// See the documentation for Mockito's code generation for more information. class MockAdvicerRepository extends _i1.Mock implements _i3.AdvicerRepository { MockAdvicerRepository() { _i1.throwOnMissingStub(this); } @override _i4.Future<_i2.Either<_i5.Failure, _i6.AdviceEntity>> getAdviceFromApi() => (super.noSuchMethod(Invocation.method(#getAdviceFromApi, []), returnValue: Future<_i2.Either<_i5.Failure, _i6.AdviceEntity>>.value( _FakeEither_0<_i5.Failure, _i6.AdviceEntity>())) as _i4 .Future<_i2.Either<_i5.Failure, _i6.AdviceEntity>>); @override String toString() => super.toString(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/advicer/test/widget_tests/widget_examples_test.dart
import 'package:advicer/widget_test_examples/simple_text.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets("check if text is correct", (WidgetTester tester) async { await tester.pumpWidget(const MyWidget(title: "title", message: "message")); final findTitle = find.text("title"); final findMessage = find.text("message"); expect(findTitle, findsOneWidget); expect(findMessage, findsOneWidget); }); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/root.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/presentation/counter_app/counter_app_page.dart'; import 'package:fluttergrundlagen/presentation/theme_animation/theme_animation_page.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets_examples_page.dart'; class RootWidget extends StatefulWidget { const RootWidget({ Key? key }) : super(key: key); @override _RootWidgetState createState() => _RootWidgetState(); } class _RootWidgetState extends State<RootWidget> { int _currentIndex = 0; @override Widget build(BuildContext context) { return Scaffold( body: IndexedStack( index: _currentIndex, children: const [ WidgetsExamplesPage(), CounterAppPage(), ThemeAnimationPage() ], ), bottomNavigationBar: BottomNavigationBar( onTap: (index){ setState(() { _currentIndex = index; }); }, currentIndex: _currentIndex, unselectedItemColor: Colors.grey, selectedItemColor: Colors.white, backgroundColor: Theme.of(context).appBarTheme.backgroundColor, items: const [ BottomNavigationBarItem(icon: Icon(Icons.star), label: "examples"), BottomNavigationBarItem(icon: Icon(Icons.add), label: "counter"), BottomNavigationBarItem(icon: Icon(Icons.color_lens), label: "theme"), ]), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/theme.dart
import 'package:flutter/material.dart'; class AppTheme { AppTheme._(); static final Color _lightPrimaryColor = Colors.blueGrey.shade50; static final Color _lightPrimaryVariantColor = Colors.blueGrey.shade800; static final Color _lightOnPrimaryColor = Colors.blueGrey.shade200; static const Color _lightTextColorPrimary = Colors.black; static const Color _appbarColorLight = Colors.blue; static final Color _darkPrimaryColor = Colors.blueGrey.shade900; static const Color _darkPrimaryVariantColor = Colors.black; static final Color _darkOnPrimaryColor = Colors.blueGrey.shade300; static const Color _darkTextColorPrimary = Colors.white; static final Color _appbarColorDark = Colors.blueGrey.shade800; static const Color _iconColor = Colors.white; static const TextStyle _lightHeadingText = TextStyle(color: _lightTextColorPrimary, fontFamily: "Rubik"); static const TextStyle _lightBodyText = TextStyle( color: _lightTextColorPrimary, fontFamily: "Rubik", fontStyle: FontStyle.italic); static const TextTheme _lightTextTheme = TextTheme( displayLarge: _lightHeadingText, bodyLarge: _lightBodyText, ); static final TextStyle _darkThemeHeadingTextStyle = _lightHeadingText.copyWith(color: _darkTextColorPrimary); static final TextStyle _darkThemeBodyeTextStyle = _lightBodyText.copyWith(color: _darkTextColorPrimary); static final TextTheme _darkTextTheme = TextTheme( displayLarge: _darkThemeHeadingTextStyle, bodyLarge: _darkThemeBodyeTextStyle, ); static final ThemeData lightTheme = ThemeData( scaffoldBackgroundColor: _lightPrimaryColor, appBarTheme: const AppBarTheme( color: _appbarColorLight, iconTheme: IconThemeData(color: _iconColor)), bottomAppBarTheme: const BottomAppBarTheme(color: _appbarColorLight), colorScheme: ColorScheme.light( primary: _lightPrimaryColor, onPrimary: _lightOnPrimaryColor, primaryContainer: _lightPrimaryVariantColor), textTheme: _lightTextTheme); static final ThemeData darkTheme = ThemeData( scaffoldBackgroundColor: _darkPrimaryColor, appBarTheme: AppBarTheme( color: _appbarColorDark, iconTheme: const IconThemeData(color: _iconColor)), bottomAppBarTheme: BottomAppBarTheme(color: _appbarColorDark), colorScheme: ColorScheme.dark( primary: _darkPrimaryColor, onPrimary: _darkOnPrimaryColor, primaryContainer: _darkPrimaryVariantColor, ), textTheme: _darkTextTheme); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/main.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/application/theme_service.dart'; import 'package:fluttergrundlagen/presentation/navigation_example_screens/screen1.dart'; import 'package:fluttergrundlagen/presentation/navigation_example_screens/screen2.dart'; import 'package:fluttergrundlagen/root.dart'; import 'package:fluttergrundlagen/theme.dart'; import 'package:provider/provider.dart'; void main() { runApp(ChangeNotifierProvider( create: (context) => ThemeService(), child: const MyApp(), )); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Consumer<ThemeService>(builder: (context, themeService, child) { return MaterialApp( theme: AppTheme.lightTheme, darkTheme: AppTheme.darkTheme, themeMode: themeService.isDarkModeOn ? ThemeMode.dark : ThemeMode.light, debugShowCheckedModeBanner: false, routes: <String, WidgetBuilder>{ "/root": (BuildContext countext) => const RootWidget(), "/screen1": (BuildContext countext) => const Screen1(), "/screen2": (BuildContext countext) => const Screen2(), }, home: const RootWidget()); }); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/application/theme_service.dart
import 'package:flutter/material.dart'; class ThemeService extends ChangeNotifier { bool isDarkModeOn = false; void toggleTheme() { isDarkModeOn = !isDarkModeOn; notifyListeners(); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation/theme_animation_page.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/application/theme_service.dart'; import 'package:fluttergrundlagen/presentation/theme_animation/widgets/moon.dart'; import 'package:fluttergrundlagen/presentation/theme_animation/widgets/star.dart'; import 'package:fluttergrundlagen/presentation/theme_animation/widgets/sun.dart'; import 'package:fluttergrundlagen/presentation/theme_animation/widgets/theme_switch.dart'; import 'package:provider/provider.dart'; class ThemeAnimationPage extends StatelessWidget { const ThemeAnimationPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final themeData = Theme.of(context); return Consumer<ThemeService>(builder: (context, themeServie, child) { return Scaffold( backgroundColor: themeData.scaffoldBackgroundColor, appBar: AppBar( centerTitle: true, backgroundColor: themeData.appBarTheme.backgroundColor, title: const Text("Theme Animation"), ), body: Center( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Material( borderRadius: BorderRadius.circular(15), elevation: 20, child: ConstrainedBox( constraints: const BoxConstraints(minWidth: double.infinity), child: Container( height: 500, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), gradient: LinearGradient( colors: themeServie.isDarkModeOn ? const [ Color(0xFF94A9FF), Color(0xFF6B66CC), Color(0xFF200F75), ] : [ const Color(0xDDFFFA66), const Color(0xDDFFA057), const Color(0xDD940B99) ], begin: Alignment.bottomCenter, end: Alignment.topCenter)), child: Stack( children: [ Positioned( top: 70, right: 50, child: AnimatedOpacity( duration: const Duration(milliseconds: 200), opacity: themeServie.isDarkModeOn ? 1 : 0, child: const Star())), Positioned( top: 150, left: 60, child: AnimatedOpacity( duration: const Duration(milliseconds: 200), opacity: themeServie.isDarkModeOn ? 1 : 0, child: const Star())), Positioned( top: 40, left: 200, child: AnimatedOpacity( duration: const Duration(milliseconds: 200), opacity: themeServie.isDarkModeOn ? 1 : 0, child: const Star())), Positioned( top: 50, left: 50, child: AnimatedOpacity( duration: const Duration(milliseconds: 200), opacity: themeServie.isDarkModeOn ? 1 : 0, child: const Star())), Positioned( top: 100, right: 200, child: AnimatedOpacity( duration: const Duration(milliseconds: 200), opacity: themeServie.isDarkModeOn ? 1 : 0, child: const Star())), // AnimatedPositioned( duration: const Duration(milliseconds: 400), top: themeServie.isDarkModeOn ? 100 : 130, right: themeServie.isDarkModeOn ? 100 : -40, child: AnimatedOpacity( duration: const Duration(milliseconds: 300), opacity: themeServie.isDarkModeOn ? 1 : 0, child: const Moon())), AnimatedPadding( duration: const Duration(milliseconds: 200), padding: EdgeInsets.only( top: themeServie.isDarkModeOn ? 110 : 50), child: const Center(child: Sun()), ), Align( alignment: Alignment.bottomCenter, child: Container( height: 225, width: double.infinity, decoration: BoxDecoration( color: themeServie.isDarkModeOn ? themeData.appBarTheme.backgroundColor : themeData.colorScheme.primary, borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(15), bottomRight: Radius.circular(15))), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( Provider.of<ThemeService>(context).isDarkModeOn ? "Zu dunkel?" : "Zu hell?", style: themeData.textTheme.displayLarge!.copyWith( fontWeight: FontWeight.w600, height: 0.9, fontSize: 21, ), textAlign: TextAlign.center, ), const SizedBox( height: 30, ), Text( Provider.of<ThemeService>(context).isDarkModeOn ? "Lass die Sonne aufgehen" : "Lass es Nacht werden", style: themeData.textTheme.bodyLarge!.copyWith( height: 0.9, fontSize: 18, ), textAlign: TextAlign.center, ), const SizedBox( height: 40, ), const ThemeSwitcher() ], ), ), ), ], ), ), ), ), ), ), ); }); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation/widgets/theme_switch.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/application/theme_service.dart'; import 'package:provider/provider.dart'; class ThemeSwitcher extends StatelessWidget { const ThemeSwitcher({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final themeProvider = Provider.of<ThemeService>(context); final themeData = Theme.of(context); final Color backgroundColor = themeData.colorScheme.primaryContainer; final Color buttonColor = themeData.colorScheme.onPrimary; final Color textColor = themeData.textTheme.displayLarge!.color!; final List<String> values = ["Light", "Dark"]; return SizedBox( width: 200, height: 30, child: Stack( children: <Widget>[ InkWell( onHover: (_) {}, onTap: () { Provider.of<ThemeService>(context, listen: false).toggleTheme(); }, child: Container( height: 30, decoration: BoxDecoration( color: backgroundColor, borderRadius: BorderRadius.circular(10), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Center( child: Text( values[0], style: TextStyle( fontFamily: "Open Sans", fontSize: 16, fontWeight: FontWeight.w600, color: textColor, ), ), ), ), Expanded( child: Center( child: Text( values[1], style: TextStyle( fontFamily: "Open Sans", fontSize: 16, fontWeight: FontWeight.w600, color: textColor, ), ), ), ), ]), ), ), InkWell( onHover: (_) {}, onTap: () { Provider.of<ThemeService>(context, listen: false).toggleTheme(); }, child: AnimatedAlign( duration: const Duration(milliseconds: 200), curve: Curves.decelerate, alignment: !themeProvider.isDarkModeOn ? Alignment.centerLeft : Alignment.centerRight, child: Container( width: 100, height: 30, decoration: ShapeDecoration( color: buttonColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), alignment: Alignment.center, child: Text( !themeProvider.isDarkModeOn ? values[0] : values[1], style: TextStyle( fontFamily: "Open Sans", fontSize: 16, fontWeight: FontWeight.w600, color: textColor, ), ), ), ), ) ], ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation/widgets/sun.dart
import 'package:flutter/material.dart'; class Sun extends StatelessWidget { const Sun({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SunShine( radius: 160, child: SunShine( radius: 120, child: SunShine( radius: 80, child: Container( height: 50, width: 50, decoration: const BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( colors: [Color(0xDDFC554F), Color(0xDDFFF79E)], begin: Alignment.bottomLeft, end: Alignment.topRight), ), ), ), ), ); } } class SunShine extends StatelessWidget { final double radius; final Widget child; const SunShine({Key? key, required this.radius, required this.child}) : super(key: key); @override Widget build(BuildContext context) { return Container( width: radius, height: radius, decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.white.withOpacity(0.1)), child: Center(child: child), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation/widgets/moon.dart
import 'package:flutter/material.dart'; class Moon extends StatelessWidget { const Moon({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( colors: [Color(0xFF8983F7), Color(0xFFA3DAFB)], begin: Alignment.bottomLeft, end: Alignment.topRight), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/theme_animation/widgets/star.dart
import 'package:flutter/material.dart'; class Star extends StatelessWidget { const Star({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( width: 2, height: 2, decoration: BoxDecoration( shape: BoxShape.circle, color: const Color(0xFFC9E9FC), boxShadow: [ BoxShadow( color: const Color(0xFFC9E9FC).withOpacity(0.5), spreadRadius: 5, blurRadius: 7, offset: const Offset(0, 0)) ], ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets_examples_page.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/application/theme_service.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/container_text_example.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/custom_button.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/media_query_example.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/page_view_example.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/profile_picture.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/rectangular_image.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/row_expanded_example.dart'; import 'package:provider/provider.dart'; class WidgetsExamplesPage extends StatelessWidget { const WidgetsExamplesPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[900], appBar: AppBar( leading: const Icon( Icons.home, size: 30, ), centerTitle: true, backgroundColor: Colors.blue, title: const Text("Widgets Examples"), ), body: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Padding( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ const ContainerTextExample(), const SizedBox( height: 10, ), const RowExpandedExample(), const SizedBox( height: 30, ), const ProfilePicture(), const SizedBox( height: 30, ), const RectImage(), const SizedBox( height: 30, ), const MediaQueryExample(), const SizedBox( height: 30, ), const PageViewExample(), const SizedBox( height: 30, ), IconButton( splashColor: Colors.blue, onPressed: () { // ignore: avoid_print print("Icon Button pressed!"); }, icon: const Icon( Icons.home, color: Colors.white, )), const SizedBox( height: 30, ), TextButton( onPressed: () { // ignore: avoid_print print("Text Button Pressed"); }, child: Container( color: Colors.grey, child: const Text( "Text Button", style: TextStyle(color: Colors.white), ))), const SizedBox( height: 30, ), CustomButton( buttonColor: Colors.blue[200]!, onPressed: () { Navigator.of(context).pushNamed("/screen2"); }, text: 'Got to Screen 2', ), const SizedBox( height: 30, ), CustomButton( buttonColor: Colors.green[200]!, onPressed: () { Navigator.of(context).pushNamed("/screen1"); }, text: 'Go to Screen 1', ), const SizedBox( width: 15, ), Switch( value: Provider.of<ThemeService>(context).isDarkModeOn, onChanged: (value) { Provider.of<ThemeService>(context, listen: false) .toggleTheme(); }) ], ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/profile_picture.dart
import 'package:flutter/material.dart'; class ProfilePicture extends StatelessWidget { const ProfilePicture({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( height: 230, width: 200, child: Stack( children: [ const SizedBox( height: 200, child: CircleAvatar( radius: 200, backgroundImage: AssetImage("assets/images/profilbild.jpeg"), ), ), Align( alignment: Alignment.bottomCenter, child: Container( alignment: Alignment.center, height: 60, width: 200, decoration: BoxDecoration( color: Colors.grey.withOpacity(0.7), borderRadius: BorderRadius.circular(10)), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: const [ Text( "Flutter Freelancer", style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white), ), Text( "Udemy Dozent", style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, color: Colors.white), ), ], ), ), ) ], ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/custom_button.dart
import 'package:flutter/material.dart'; class CustomButton extends StatelessWidget { final Function onPressed; final String text; final Color buttonColor; const CustomButton( {Key? key, required this.onPressed, required this.text, required this.buttonColor}) : super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: () => onPressed(), child: Material( elevation: 26, borderRadius: BorderRadius.circular(8), child: Container( height: 30, width: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: buttonColor), child: Center( child: Text( text, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic), ), ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/container_text_example.dart
import 'package:flutter/material.dart'; class ContainerTextExample extends StatelessWidget { const ContainerTextExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: 180, // width: 300, decoration: BoxDecoration( color: Colors.grey, border: Border.all( color: Colors.black, width: 4, ), borderRadius: BorderRadius.circular(16)), child: Center( child: Material( borderRadius: BorderRadius.circular(10), elevation: 8, child: Container( alignment: Alignment.center, //padding: EdgeInsets.only(bottom: 20), height: 100, width: 200, decoration: BoxDecoration( color: Colors.blue[200], borderRadius: BorderRadius.circular(10)), child: const Text( "Text Example", style: TextStyle( fontStyle: FontStyle.italic, fontFamily: "Rubik", fontSize: 20), ), ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/page_view_example.dart
import 'package:flutter/material.dart'; class PageViewExample extends StatelessWidget { const PageViewExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return SizedBox( height: size.height * 0.2, child: PageView( controller: PageController(viewportFraction: 0.95), children: [ Padding( padding: const EdgeInsets.only(right: 8.0), child: SinglePage( size: size, text: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor ', title: 'Title 1', ), ), SinglePage( size: size, text: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor ', title: 'Title 2', ) ], ), ); } } class SinglePage extends StatelessWidget { final Size size; final String title; final String text; const SinglePage( {Key? key, required this.size, required this.title, required this.text}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: size.height * 0.2, width: size.width * 0.85, decoration: BoxDecoration( color: Colors.grey[700], borderRadius: BorderRadius.circular(15)), child: Padding( padding: const EdgeInsets.all(30), child: Column( children: [ Text( title, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18), ), const SizedBox( height: 20, ), Text( text, style: const TextStyle(color: Colors.white, fontSize: 15), textAlign: TextAlign.center, ), ], ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/row_expanded_example.dart
import 'package:flutter/material.dart'; class RowExpandedExample extends StatelessWidget { const RowExpandedExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Row( //mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Container(color: Colors.yellow, height: 100, width: 50,), const SizedBox(width: 10,), Expanded(flex: 2, child: Container(color: Colors.green, height: 100, )), const SizedBox(width: 10,), Expanded(flex: 1, child: Container(color: Colors.red, height: 100, )), const SizedBox(width: 10,), Container(color: Colors.yellow, height: 100, width: 50,) ], ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/media_query_example.dart
import 'package:flutter/material.dart'; class MediaQueryExample extends StatelessWidget { const MediaQueryExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return Container( height: size.height * 0.1, width: size.width * 0.8, color: Colors.green, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/widgets_examples/widgets/rectangular_image.dart
import 'package:flutter/material.dart'; class RectImage extends StatelessWidget { const RectImage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( width: 200, height: 100, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Image.asset( "assets/images/profilbild.jpeg", fit: BoxFit.cover, ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/counter_app/counter_app_page.dart
import 'package:flutter/material.dart'; class CounterAppPage extends StatefulWidget { const CounterAppPage({Key? key}) : super(key: key); @override _CounterAppPageState createState() => _CounterAppPageState(); } class _CounterAppPageState extends State<CounterAppPage> { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } void _decrementCounter() { setState(() { _counter--; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Counter App"), backgroundColor: Colors.blue, centerTitle: true, ), body: Center( child: Material( elevation: 15, borderRadius: BorderRadius.circular(15), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: _counter < 20 ? Colors.grey : Colors.blue ), height: 200, width: 200, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text("Counter"), const SizedBox( height: 20, ), Text( _counter.toString(), style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ) ], ), ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ FloatingActionButton( heroTag: "btn1", onPressed: () => _decrementCounter(), backgroundColor: Colors.red, child: const Icon(Icons.remove), ), FloatingActionButton( heroTag: "btn2", onPressed: () => _incrementCounter(), backgroundColor: Colors.blue, child: const Icon(Icons.add), ), ], ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/navigation_example_screens/screen1.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/custom_button.dart'; class Screen1 extends StatelessWidget { const Screen1({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.green, title: const Text("Screen 1"), centerTitle: true), body: Center( child: CustomButton( onPressed: () { Navigator.of(context).pop(); }, text: "Navigate Back", buttonColor: Colors.green), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/flutter_grundlagen/lib/presentation/navigation_example_screens/screen2.dart
import 'package:flutter/material.dart'; import 'package:fluttergrundlagen/presentation/widgets_examples/widgets/custom_button.dart'; class Screen2 extends StatelessWidget { const Screen2({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.yellow, title: const Text("Screen 2"), centerTitle: true), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CustomButton( onPressed: () { Navigator.of(context).pop(); }, text: "Navigate Back", buttonColor: Colors.yellow), const SizedBox(height: 20,), CustomButton( onPressed: () { Navigator.of(context).pushReplacementNamed("/screen1"); }, text: "Go to Screen 1", buttonColor: Colors.yellow), ], ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/injection.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:get_it/get_it.dart'; import 'package:todo/application/auth/authbloc/auth_bloc.dart'; import 'package:todo/application/auth/singupfrom/signupform_bloc.dart'; import 'package:todo/application/todos/controller/controller_bloc.dart'; import 'package:todo/application/todos/observer/observer_bloc.dart'; import 'package:todo/application/todos/todoForm/todoform_bloc.dart'; import 'package:todo/domain/repositries/auth_repository.dart'; import 'package:todo/domain/repositries/todo_repository.dart'; import 'package:todo/infrastructure/repositories/auth_repository_impl.dart'; import 'package:todo/infrastructure/repositories/todo_repository_impl.dart'; final sl = GetIt.I; // sl == service locator Future<void> init() async { //? ################ auth ################## //! state management sl.registerFactory(() => SignupformBloc(authRepository: sl())); sl.registerFactory(() => AuthBloc(authRepository: sl())); //! repos sl.registerLazySingleton<AuthRepository>( () => AuthRepositoryImpl(firebaseAuth: sl())); //! extern final friebaseAuth = FirebaseAuth.instance; sl.registerLazySingleton(() => friebaseAuth); //? ################ todo ################## //!X state management sl.registerFactory(() => ObserverBloc(todoRepository: sl())); sl.registerFactory(() => ControllerBloc(todoRepository: sl())); sl.registerFactory(() => TodoformBloc(todoRepository: sl())); //! repos sl.registerLazySingleton<TodoRepository>(() => TodoRepositoryImpl(firestore: sl())); //! extern final firestore = FirebaseFirestore.instance; sl.registerLazySingleton(() => firestore); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/theme.dart
import 'package:flutter/material.dart'; class AppTheme { AppTheme._(); static final Color _lightPrimaryColor = Colors.blueGrey.shade50; static final Color _lightPrimaryVariantColor = Colors.blueGrey.shade800; static final Color _lightOnPrimaryColor = Colors.blueGrey.shade200; static const Color _lightTextColorPrimary = Colors.black; static const Color _appbarColorLight = Colors.blue; static final Color _darkPrimaryColor = Colors.blueGrey.shade900; static const Color _darkPrimaryVariantColor = Colors.black; static final Color _darkOnPrimaryColor = Colors.blueGrey.shade300; static const Color _darkTextColorPrimary = Colors.white; static final Color _appbarColorDark = Colors.blueGrey.shade800; static const Color _iconColor = Colors.white; static const Color _accentColorDark = Color.fromRGBO(74, 217, 217, 1); static const TextStyle _lightHeadingText = TextStyle( color: _lightTextColorPrimary, fontFamily: "Rubik", fontSize: 20, fontWeight: FontWeight.bold); static const TextStyle _lightBodyText = TextStyle( color: _lightTextColorPrimary, fontFamily: "Rubik", fontStyle: FontStyle.italic, fontWeight: FontWeight.bold, fontSize: 16); static const TextTheme _lightTextTheme = TextTheme( displayLarge: _lightHeadingText, bodyLarge: _lightBodyText, ); static final TextStyle _darkThemeHeadingTextStyle = _lightHeadingText.copyWith(color: _darkTextColorPrimary); static final TextStyle _darkThemeBodyeTextStyle = _lightBodyText.copyWith(color: _darkTextColorPrimary); static final TextTheme _darkTextTheme = TextTheme( displayLarge: _darkThemeHeadingTextStyle, bodyLarge: _darkThemeBodyeTextStyle, ); static final InputDecorationTheme _inputDecorationTheme = InputDecorationTheme( floatingLabelStyle: const TextStyle(color: Colors.white), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: const BorderSide(color: Colors.white)), border: OutlineInputBorder(borderRadius: BorderRadius.circular(8))); static final ThemeData lightTheme = ThemeData( inputDecorationTheme: _inputDecorationTheme, scaffoldBackgroundColor: _lightPrimaryColor, appBarTheme: const AppBarTheme( color: _appbarColorLight, iconTheme: IconThemeData(color: _iconColor)), bottomAppBarTheme: const BottomAppBarTheme(color: _appbarColorLight), colorScheme: ColorScheme.light( primary: _lightPrimaryColor, onPrimary: _lightOnPrimaryColor, secondary: _accentColorDark, primaryContainer: _lightPrimaryVariantColor), textTheme: _lightTextTheme); static final ThemeData darkTheme = ThemeData( inputDecorationTheme: _inputDecorationTheme, scaffoldBackgroundColor: _darkPrimaryColor, appBarTheme: AppBarTheme( color: _appbarColorDark, iconTheme: const IconThemeData(color: _iconColor)), bottomAppBarTheme: BottomAppBarTheme(color: _appbarColorDark), colorScheme: ColorScheme.dark( primary: _darkPrimaryColor, secondary: _accentColorDark, onPrimary: _darkOnPrimaryColor, primaryContainer: _darkPrimaryVariantColor, ), textTheme: _darkTextTheme); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for web - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for macos - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyAEBg9vQf2XJ4gVaP5yJvTVj2C7AQVEj_s', appId: '1:412763203883:android:6a7076ab4c607a45423d6e', messagingSenderId: '412763203883', projectId: 'flutterkurstodo', storageBucket: 'flutterkurstodo.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyC6D3hAIGuyGUoBndNdSb1wrbhDHPyajPw', appId: '1:412763203883:ios:ca211ef561e3e93b423d6e', messagingSenderId: '412763203883', projectId: 'flutterkurstodo', storageBucket: 'flutterkurstodo.appspot.com', androidClientId: '412763203883-r06on0rqepd35qks06fp451gm3mpq8oc.apps.googleusercontent.com', iosClientId: '412763203883-fvkis5ur3erfc8548e0q5rposk64f7c5.apps.googleusercontent.com', iosBundleId: 'com.example.todo', ); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/main.dart
import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/firebase_options.dart'; import 'package:todo/injection.dart' as di; import 'package:todo/presentation/routes/router.dart'; // Old: import 'package:todo/presentation/routes/router.gr.dart' as r; import 'package:todo/theme.dart'; import 'application/auth/authbloc/auth_bloc.dart'; import 'injection.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); await di.init(); runApp(MyApp()); } class MyApp extends StatelessWidget { final _appRouter = AppRouter(); // OLD : r.AppRouter(); MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider( create: (context) => sl<AuthBloc>()..add(AuthCheckRequestedEvent()), ) ], child: MaterialApp.router( routeInformationParser: _appRouter.defaultRouteParser(), routerDelegate: _appRouter.delegate(), debugShowCheckedModeBanner: false, title: 'TODO', theme: AppTheme.lightTheme, darkTheme: AppTheme.darkTheme, themeMode: ThemeMode.dark, ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth/authbloc/auth_bloc.dart
import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; import 'package:todo/domain/repositries/auth_repository.dart'; part 'auth_event.dart'; part 'auth_state.dart'; class AuthBloc extends Bloc<AuthEvent, AuthState> { final AuthRepository authRepository; AuthBloc({required this.authRepository}) : super(AuthInitial()) { on<SignOutPressedEvent>((event, emit) async { await authRepository.signOut(); emit(AuthStateUnauthenticated()); }); on<AuthCheckRequestedEvent>((event, emit) async { final userOption = authRepository.getSignedInUser(); userOption.fold(() => emit(AuthStateUnauthenticated()), (a) => emit(AuthStateAuthenticated())); }); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth/authbloc/auth_event.dart
part of 'auth_bloc.dart'; @immutable abstract class AuthEvent {} class SignOutPressedEvent extends AuthEvent {} class AuthCheckRequestedEvent extends AuthEvent {}
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth/authbloc/auth_state.dart
part of 'auth_bloc.dart'; @immutable abstract class AuthState {} class AuthInitial extends AuthState {} class AuthStateAuthenticated extends AuthState {} class AuthStateUnauthenticated extends AuthState {}
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth/singupfrom/signupform_event.dart
part of 'signupform_bloc.dart'; @immutable abstract class SignupformEvent {} class RegisterWithEmailAndPasswordPressed extends SignupformEvent { final String? email; final String? password; RegisterWithEmailAndPasswordPressed({required this.email,required this.password}); } class SignInWithEmailAndPasswordPressed extends SignupformEvent { final String? email; final String? password; SignInWithEmailAndPasswordPressed({required this.email,required this.password}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth/singupfrom/signupform_bloc.dart
import 'package:bloc/bloc.dart'; import 'package:dartz/dartz.dart'; import 'package:meta/meta.dart'; import 'package:todo/core/Failures/auth_failures.dart'; import 'package:todo/domain/repositries/auth_repository.dart'; part 'signupform_event.dart'; part 'signupform_state.dart'; class SignupformBloc extends Bloc<SignupformEvent, SignupformState> { final AuthRepository authRepository; SignupformBloc({required this.authRepository}) : super(SignupformState( isSubmitting: false, showValidationMessages: false, authFailureOrSuccessOption: none())) { on<RegisterWithEmailAndPasswordPressed>((event, emit) async { if (event.email == null || event.password == null) { emit(state.copyWith(isSubmitting: false, showValidationMessages: true)); } else { emit(state.copyWith(isSubmitting: true, showValidationMessages: false)); final failureOrSuccess = await authRepository.registerWithEmailAndPassword( email: event.email!, password: event.password!); emit(state.copyWith( isSubmitting: false, authFailureOrSuccessOption: optionOf(failureOrSuccess))); } }); on<SignInWithEmailAndPasswordPressed>((event, emit) async { if (event.email == null || event.password == null) { emit(state.copyWith(isSubmitting: false, showValidationMessages: true)); } else { emit(state.copyWith(isSubmitting: true, showValidationMessages: false)); final failureOrSuccess = await authRepository.signInWithEmailAndPassword( email: event.email!, password: event.password!); emit(state.copyWith( isSubmitting: false, authFailureOrSuccessOption: optionOf(failureOrSuccess))); } }); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/auth/singupfrom/signupform_state.dart
part of 'signupform_bloc.dart'; class SignupformState { final bool isSubmitting; final bool showValidationMessages; final Option<Either<AuthFailure, Unit>> authFailureOrSuccessOption; SignupformState( {required this.isSubmitting, required this.showValidationMessages, required this.authFailureOrSuccessOption}); SignupformState copyWith({ bool? isSubmitting, bool? showValidationMessages, Option<Either<AuthFailure, Unit>>? authFailureOrSuccessOption, }) { return SignupformState( isSubmitting: isSubmitting ?? this.isSubmitting, authFailureOrSuccessOption: authFailureOrSuccessOption ?? this.authFailureOrSuccessOption, showValidationMessages: showValidationMessages ?? this.showValidationMessages, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/todoForm/todoform_state.dart
part of 'todoform_bloc.dart'; class TodoformState { final Todo todo; final bool showErrorMessages; final bool isSaving; final bool isEditing; final Option<Either<TodoFailure, Unit>> failureOrSuccessOption; TodoformState( {required this.todo, required this.showErrorMessages, required this.isEditing, required this.isSaving, required this.failureOrSuccessOption}); factory TodoformState.initial() => TodoformState( todo: Todo.empty(), showErrorMessages: false, isEditing: false, isSaving: false, failureOrSuccessOption: none()); TodoformState copyWith({ Todo? todo, bool? showErrorMessages, bool? isSaving, bool? isEditing, Option<Either<TodoFailure, Unit>>? failureOrSuccessOption, }) { return TodoformState( todo: todo ?? this.todo, showErrorMessages: showErrorMessages ?? this.showErrorMessages, isSaving: isSaving ?? this.isSaving, isEditing: isEditing ?? this.isEditing, failureOrSuccessOption: failureOrSuccessOption ?? this.failureOrSuccessOption, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/todoForm/todoform_bloc.dart
import 'package:bloc/bloc.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/material.dart'; import 'package:todo/core/Failures/todo_failures.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/domain/entities/todo_color.dart'; import 'package:todo/domain/repositries/todo_repository.dart'; part 'todoform_event.dart'; part 'todoform_state.dart'; class TodoformBloc extends Bloc<TodoformEvent, TodoformState> { final TodoRepository todoRepository; TodoformBloc({required this.todoRepository}) : super(TodoformState.initial()) { on<InitializeTodoDetailPage>((event, emit) { if (event.todo != null) { emit(state.copyWith(todo: event.todo, isEditing: true)); } else { emit(state); } }); on<ColorChangedEvent>((event, emit) { emit(state.copyWith( todo: state.todo.copyWith(color: TodoColor(color: event.color)))); }); on<SafePressedEvent>((event, emit) async { Either<TodoFailure, Unit>? failureOrSuccess; emit(state.copyWith(isSaving: true, failureOrSuccessOption: none())); if (event.title != null && event.body != null) { final Todo editedTodo = state.todo.copyWith(title: event.title, body: event.body); if (state.isEditing) { failureOrSuccess = await todoRepository.update(editedTodo); } else { failureOrSuccess = await todoRepository.create(editedTodo); } } emit(state.copyWith( isSaving: false, showErrorMessages: true, failureOrSuccessOption: optionOf(failureOrSuccess))); }); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/todoForm/todoform_event.dart
part of 'todoform_bloc.dart'; @immutable abstract class TodoformEvent {} class InitializeTodoDetailPage extends TodoformEvent { final Todo? todo; InitializeTodoDetailPage({required this.todo}); } class ColorChangedEvent extends TodoformEvent { final Color color; ColorChangedEvent({required this.color}); } class SafePressedEvent extends TodoformEvent { final String? title; final String? body; SafePressedEvent({required this.title, required this.body}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/controller/controller_bloc.dart
import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; import 'package:todo/core/Failures/todo_failures.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/domain/repositries/todo_repository.dart'; part 'controller_event.dart'; part 'controller_state.dart'; class ControllerBloc extends Bloc<ControllerEvent, ControllerState> { final TodoRepository todoRepository; ControllerBloc({required this.todoRepository}) : super(ControllerInitial()) { on<DeleteTodoEvent>((event, emit) async { emit(ControllerInProgress()); final failureOrSuccess = await todoRepository.delete(event.todo); failureOrSuccess.fold( (failure) => emit(ControllerFailure(todoFailure: failure)), (r) => emit(ControllerSuccess())); }); on<UpdateTodoEvent>((event, emit) async { emit(ControllerInProgress()); final failureOrSuccess = await todoRepository.update(event.todo.copyWith(done: event.done)); failureOrSuccess.fold( (failure) => emit(ControllerFailure(todoFailure: failure)), (r) => emit(ControllerSuccess())); }); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/controller/controller_state.dart
part of 'controller_bloc.dart'; @immutable abstract class ControllerState {} class ControllerInitial extends ControllerState {} class ControllerInProgress extends ControllerState {} class ControllerSuccess extends ControllerState {} class ControllerFailure extends ControllerState { final TodoFailure todoFailure; ControllerFailure({required this.todoFailure}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/controller/controller_event.dart
part of 'controller_bloc.dart'; @immutable abstract class ControllerEvent {} class DeleteTodoEvent extends ControllerEvent { final Todo todo; DeleteTodoEvent({required this.todo}); } class UpdateTodoEvent extends ControllerEvent { final Todo todo; final bool done; UpdateTodoEvent({required this.todo, required this.done}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/observer/observer_bloc.dart
import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:dartz/dartz.dart'; import 'package:meta/meta.dart'; import 'package:todo/core/Failures/todo_failures.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/domain/repositries/todo_repository.dart'; part 'observer_event.dart'; part 'observer_state.dart'; class ObserverBloc extends Bloc<ObserverEvent, ObserverState> { final TodoRepository todoRepository; StreamSubscription<Either<TodoFailure, List<Todo>>>? _todoStreamSub; ObserverBloc({required this.todoRepository}) : super(ObserverInitial()) { on<ObserveAllEvent>((event, emit) async { emit(ObserverLoading()); await _todoStreamSub?.cancel(); _todoStreamSub = todoRepository.watchAll().listen((failureOrTodos) => add(TodosUpdatedEvent(failureOrTodos: failureOrTodos))); }); on<TodosUpdatedEvent>((event, emit) { event.failureOrTodos.fold( (failures) => emit(ObserverFailure(todoFailure: failures)), (todos) => emit(ObserverSuccess(todos: todos))); }); } @override Future<void> close() async { await _todoStreamSub?.cancel(); return super.close(); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/observer/observer_state.dart
part of 'observer_bloc.dart'; @immutable abstract class ObserverState {} class ObserverInitial extends ObserverState {} class ObserverLoading extends ObserverState {} class ObserverFailure extends ObserverState { final TodoFailure todoFailure; ObserverFailure({required this.todoFailure}); } class ObserverSuccess extends ObserverState { final List<Todo> todos; ObserverSuccess({required this.todos}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/application/todos/observer/observer_event.dart
part of 'observer_bloc.dart'; @immutable abstract class ObserverEvent {} class ObserveAllEvent extends ObserverEvent {} class TodosUpdatedEvent extends ObserverEvent { final Either<TodoFailure, List<Todo>> failureOrTodos; TodosUpdatedEvent({required this.failureOrTodos}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure/models/todo_model.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:todo/domain/entities/id.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/domain/entities/todo_color.dart'; class TodoModel { final String id; final String title; final String body; final bool done; final int color; final dynamic serverTimeStamp; TodoModel( {required this.id, required this.body, required this.title, required this.color, required this.done, required this.serverTimeStamp}); Map<String, dynamic> toMap() { return { 'id': id, 'title': title, 'body': body, 'done': done, 'color': color, 'serverTimeStamp': serverTimeStamp, }; } factory TodoModel.fromMap(Map<String, dynamic> map) { return TodoModel( id: "", title: map['title'] as String, body: map['body'] as String, done: map['done'] as bool, color: map['color'] as int, serverTimeStamp: map['serverTimeStamp'], ); } TodoModel copyWith({ String? id, String? title, String? body, bool? done, int? color, dynamic serverTimeStamp, }) { return TodoModel( id: id ?? this.id, title: title ?? this.title, body: body ?? this.body, done: done ?? this.done, color: color ?? this.color, serverTimeStamp: serverTimeStamp ?? this.serverTimeStamp, ); } factory TodoModel.fromFirestore( QueryDocumentSnapshot<Map<String, dynamic>> doc) { return TodoModel.fromMap(doc.data()).copyWith(id: doc.id); } Todo toDomain() { return Todo( id: UniqueID.fromUniqueString(id), title: title, body: body, done: done, color: TodoColor(color: Color(color).withOpacity(1))); } factory TodoModel.fromDomain(Todo todoItem) { return TodoModel( id: todoItem.id.value, body: todoItem.body, title: todoItem.title, color: todoItem.color.color.value, done: todoItem.done, serverTimeStamp: FieldValue.serverTimestamp()); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure/extensions/firebase_helpers.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:todo/core/errors/errors.dart'; import 'package:todo/domain/repositries/auth_repository.dart'; import 'package:todo/injection.dart'; extension FirestorExt on FirebaseFirestore { Future<DocumentReference> userDocument() async { final userOption = sl<AuthRepository>().getSignedInUser(); final user = userOption.getOrElse(() => throw NotAuthenticatedError()); return FirebaseFirestore.instance.collection("users").doc(user.id.value); } } extension DocumentReferenceExt on DocumentReference { CollectionReference<Map<String, dynamic>> get todoCollection => collection("todos"); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure/extensions/firebase_user_mapper.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:todo/domain/entities/id.dart'; import 'package:todo/domain/entities/user.dart'; extension FirebaseUserMapper on User { CustomUser toDomain() { return CustomUser(id: UniqueID.fromUniqueString(uid)); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure/repositories/todo_repository_impl.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/core/Failures/todo_failures.dart'; import 'package:dartz/dartz.dart'; import 'package:todo/domain/repositries/todo_repository.dart'; import 'package:todo/infrastructure/extensions/firebase_helpers.dart'; import 'package:todo/infrastructure/models/todo_model.dart'; class TodoRepositoryImpl implements TodoRepository { final FirebaseFirestore firestore; TodoRepositoryImpl({required this.firestore}); @override Stream<Either<TodoFailure, List<Todo>>> watchAll() async* { final userDoc = await firestore.userDocument(); // right side listen on todos yield* userDoc.todoCollection .snapshots() .map((snapshot) => right<TodoFailure, List<Todo>>(snapshot.docs .map((doc) => TodoModel.fromFirestore(doc).toDomain()) .toList())) // error handling (left side) .handleError((e) { if (e is FirebaseException) { if (e.code.contains('permission-denied') || e.code.contains("PERMISSION_DENIED")) { return left(InsufficientPermisssons()); } else { return left(UnexpectedFailure()); } } else { return left(UnexpectedFailure()); } }); } @override Future<Either<TodoFailure, Unit>> create(Todo todo) async { try { final userDoc = await firestore.userDocument(); final todoModel = TodoModel.fromDomain(todo); await userDoc.todoCollection.doc(todoModel.id).set(todoModel.toMap()); return right(unit); } on FirebaseException catch (e) { if (e.code.contains("PERMISSION_DENIED")) { return left(InsufficientPermisssons()); } else { return left(UnexpectedFailure()); } } } @override Future<Either<TodoFailure, Unit>> update(Todo todo) async { try { final userDoc = await firestore.userDocument(); final todoModel = TodoModel.fromDomain(todo); await userDoc.todoCollection.doc(todoModel.id).update(todoModel.toMap()); return right(unit); } on FirebaseException catch (e) { if (e.code.contains("PERMISSION_DENIED")) { // NOT_FOUND return left(InsufficientPermisssons()); } else { return left(UnexpectedFailure()); } } } @override Future<Either<TodoFailure, Unit>> delete(Todo todo) async { try { final userDoc = await firestore.userDocument(); final todoModel = TodoModel.fromDomain(todo); await userDoc.todoCollection.doc(todoModel.id).delete(); return right(unit); } on FirebaseException catch (e) { if (e.code.contains("PERMISSION_DENIED")) { // NOT_FOUND return left(InsufficientPermisssons()); } else { return left(UnexpectedFailure()); } } } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/infrastructure/repositories/auth_repository_impl.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:todo/core/Failures/auth_failures.dart'; import 'package:dartz/dartz.dart'; import 'package:todo/domain/entities/user.dart'; import 'package:todo/domain/repositries/auth_repository.dart'; import 'package:todo/infrastructure/extensions/firebase_user_mapper.dart'; class AuthRepositoryImpl implements AuthRepository { final FirebaseAuth firebaseAuth; AuthRepositoryImpl({required this.firebaseAuth}); @override Future<Either<AuthFailure, Unit>> registerWithEmailAndPassword( {required String email, required String password}) async { try { await firebaseAuth.createUserWithEmailAndPassword( email: email, password: password); return right(unit); } on FirebaseAuthException catch (e) { if (e.code == "email-already-in-use") { return left(EmailAlreadyInUseFailure()); } else { return left(ServerFailure()); } } } @override Future<Either<AuthFailure, Unit>> signInWithEmailAndPassword( {required String email, required String password}) async { try { await firebaseAuth.signInWithEmailAndPassword( email: email, password: password); return right(unit); } on FirebaseAuthException catch (e) { if (e.code == "wrong-password" || e.code == "user-not-found") { return left(InvalidEmailAndPasswordCombinationFailure()); } else { return left(ServerFailure()); } } } @override Future<void> signOut() => Future.wait([ firebaseAuth.signOut(), ]); @override Option<CustomUser> getSignedInUser() => optionOf(firebaseAuth.currentUser?.toDomain()); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/core
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/core/errors/errors.dart
class NotAuthenticatedError extends Error {}
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/core
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/core/Failures/todo_failures.dart
abstract class TodoFailure {} class InsufficientPermisssons extends TodoFailure {} class UnexpectedFailure extends TodoFailure {}
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/core
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/core/Failures/auth_failures.dart
abstract class AuthFailure {} class ServerFailure extends AuthFailure {} class EmailAlreadyInUseFailure extends AuthFailure {} class InvalidEmailAndPasswordCombinationFailure extends AuthFailure {}
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/routes/router.gr.dart
// GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** // AutoRouterGenerator // ************************************************************************** // ignore_for_file: type=lint // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:auto_route/auto_route.dart' as _i5; import 'package:flutter/material.dart' as _i6; import 'package:todo/domain/entities/todo.dart' as _i7; import 'package:todo/presentation/home/home_page.dart' as _i2; import 'package:todo/presentation/signup/signup_page.dart' as _i4; import 'package:todo/presentation/splash/splash_page.dart' as _i3; import 'package:todo/presentation/todo_detail/todo_detail_page.dart' as _i1; abstract class $AppRouter extends _i5.RootStackRouter { $AppRouter({super.navigatorKey}); @override final Map<String, _i5.PageFactory> pagesMap = { TodoDetailRoute.name: (routeData) { final args = routeData.argsAs<TodoDetailRouteArgs>(); return _i5.AutoRoutePage<dynamic>( routeData: routeData, child: _i1.TodoDetail( key: args.key, todo: args.todo, ), ); }, HomeRoute.name: (routeData) { return _i5.AutoRoutePage<dynamic>( routeData: routeData, child: const _i2.HomePage(), ); }, SplashRoute.name: (routeData) { return _i5.AutoRoutePage<dynamic>( routeData: routeData, child: const _i3.SplashPage(), ); }, SignUpRoute.name: (routeData) { return _i5.AutoRoutePage<dynamic>( routeData: routeData, child: const _i4.SignUpPage(), ); }, }; } /// generated route for /// [_i1.TodoDetail] class TodoDetailRoute extends _i5.PageRouteInfo<TodoDetailRouteArgs> { TodoDetailRoute({ _i6.Key? key, required _i7.Todo? todo, List<_i5.PageRouteInfo>? children, }) : super( TodoDetailRoute.name, args: TodoDetailRouteArgs( key: key, todo: todo, ), initialChildren: children, ); static const String name = 'TodoDetailRoute'; static const _i5.PageInfo<TodoDetailRouteArgs> page = _i5.PageInfo<TodoDetailRouteArgs>(name); } class TodoDetailRouteArgs { const TodoDetailRouteArgs({ this.key, required this.todo, }); final _i6.Key? key; final _i7.Todo? todo; @override String toString() { return 'TodoDetailRouteArgs{key: $key, todo: $todo}'; } } /// generated route for /// [_i2.HomePage] class HomeRoute extends _i5.PageRouteInfo<void> { const HomeRoute({List<_i5.PageRouteInfo>? children}) : super( HomeRoute.name, initialChildren: children, ); static const String name = 'HomeRoute'; static const _i5.PageInfo<void> page = _i5.PageInfo<void>(name); } /// generated route for /// [_i3.SplashPage] class SplashRoute extends _i5.PageRouteInfo<void> { const SplashRoute({List<_i5.PageRouteInfo>? children}) : super( SplashRoute.name, initialChildren: children, ); static const String name = 'SplashRoute'; static const _i5.PageInfo<void> page = _i5.PageInfo<void>(name); } /// generated route for /// [_i4.SignUpPage] class SignUpRoute extends _i5.PageRouteInfo<void> { const SignUpRoute({List<_i5.PageRouteInfo>? children}) : super( SignUpRoute.name, initialChildren: children, ); static const String name = 'SignUpRoute'; static const _i5.PageInfo<void> page = _i5.PageInfo<void>(name); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/routes/router.dart
import 'package:auto_route/auto_route.dart'; import 'package:todo/presentation/routes/router.gr.dart'; // ********************** // Old Aout route Syntax: // ********************** /*@MaterialAutoRouter( routes: <AutoRoute>[ AutoRoute(page: SplashPage, initial: true), AutoRoute(page: SignUpPage, initial: false), AutoRoute(page: HomePage , initial: false), AutoRoute(page: TodoDetail, initial: false, fullscreenDialog: true) ] ) class $AppRouter {}*/ // ********************** // New Aout route Syntax: // ********************** @AutoRouterConfig() class AppRouter extends $AppRouter { @override RouteType get defaultRouteType => const RouteType.material(); //.cupertino, .adaptive ..etc @override final List<AutoRoute> routes = [ AutoRoute(page: SplashRoute.page, path: '/'), AutoRoute(page: HomeRoute.page), AutoRoute(page: SignUpRoute.page), AutoRoute(page: TodoDetailRoute.page), ]; }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/signup/signup_page.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/auth/singupfrom/signupform_bloc.dart'; import 'package:todo/injection.dart'; import 'package:todo/presentation/signup/widgets/signup_form.dart'; @RoutePage() class SignUpPage extends StatelessWidget { const SignUpPage({ Key? key }) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: BlocProvider( create: (context) => sl<SignupformBloc>(), child: const SignUpForm()), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/signup
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/signup/widgets/signup_form.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/auth/singupfrom/signupform_bloc.dart'; import 'package:todo/core/Failures/auth_failures.dart'; import 'package:todo/presentation/routes/router.gr.dart'; import 'package:todo/presentation/core/custom_button.dart'; class SignUpForm extends StatelessWidget { const SignUpForm({Key? key}) : super(key: key); @override Widget build(BuildContext context) { late String _email; late String _password; final GlobalKey<FormState> formKey = GlobalKey<FormState>(); String? validateEmail(String? input) { const emailRegex = r"""^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+"""; if (input == null || input.isEmpty) { return "please enter email"; } else if (RegExp(emailRegex).hasMatch(input)) { _email = input; return null; } else { return "invalid email format"; } } String? validatePassword(String? input) { if (input == null || input.isEmpty) { return "please enter password"; } else if (input.length >= 6) { _password = input; return null; } else { return "short password"; } } String mapFailureMessage(AuthFailure failure) { switch (failure.runtimeType) { case ServerFailure: return "something went wrong"; case EmailAlreadyInUseFailure: return "email already in use"; case InvalidEmailAndPasswordCombinationFailure: return "invalid email and password combination"; default: return "something went wrong"; } } final themeData = Theme.of(context); return BlocConsumer<SignupformBloc, SignupformState>( listenWhen: (p,c) => p.authFailureOrSuccessOption != c.authFailureOrSuccessOption, listener: (context, state) { state.authFailureOrSuccessOption.fold( () => {}, (eitherFailureOrSuccess) => eitherFailureOrSuccess.fold((failure) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.redAccent, content: Text( mapFailureMessage(failure), style: themeData.textTheme.bodyLarge, ))); }, (_) { AutoRouter.of(context).replace(const HomeRoute()); })); }, builder: (context, state) { return Form( autovalidateMode: state.showValidationMessages ? AutovalidateMode.always : AutovalidateMode.disabled, key: formKey, child: ListView( padding: const EdgeInsets.symmetric(horizontal: 20), children: [ const SizedBox( height: 80, ), Text( "Welcome", style: themeData.textTheme.displayLarge!.copyWith( fontSize: 50, fontWeight: FontWeight.w500, letterSpacing: 4), ), const SizedBox( height: 20, ), Text( "Please register or sign in", style: themeData.textTheme.displayLarge!.copyWith( fontSize: 14, fontWeight: FontWeight.w500, letterSpacing: 4), ), const SizedBox( height: 80, ), TextFormField( cursorColor: Colors.white, decoration: const InputDecoration(labelText: "E-Mail"), validator: validateEmail, ), const SizedBox( height: 20, ), TextFormField( cursorColor: Colors.white, obscureText: true, decoration: const InputDecoration( labelText: "Password", ), validator: validatePassword, ), const SizedBox( height: 40, ), CustomButton( buttonText: "Sign in", callback: () { if (formKey.currentState!.validate()) { BlocProvider.of<SignupformBloc>(context).add( SignInWithEmailAndPasswordPressed( email: _email, password: _password)); } else { BlocProvider.of<SignupformBloc>(context).add( SignInWithEmailAndPasswordPressed( email: null, password: null)); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.redAccent, content: Text( "invalid input", style: themeData.textTheme.bodyLarge, ))); } }, ), const SizedBox( height: 20, ), CustomButton( buttonText: "Register", callback: () { if (formKey.currentState!.validate()) { BlocProvider.of<SignupformBloc>(context).add( RegisterWithEmailAndPasswordPressed( email: _email, password: _password)); } else { BlocProvider.of<SignupformBloc>(context).add( RegisterWithEmailAndPasswordPressed( email: null, password: null)); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.redAccent, content: Text( "invalid input", style: themeData.textTheme.bodyLarge, ))); } }, ), if (state.isSubmitting) ...[ const SizedBox( height: 10, ), LinearProgressIndicator( color: themeData.colorScheme.secondary, ) ] ], ), ); }, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/core/custom_button.dart
import 'package:flutter/material.dart'; class CustomButton extends StatelessWidget { final String buttonText; final Function callback; const CustomButton({Key? key, required this.buttonText, required this.callback}) : super(key: key); @override Widget build(BuildContext context) { final themeData = Theme.of(context); return InkResponse( onTap: () => callback(), child: Container( height: 40, width: double.infinity, decoration: BoxDecoration(color: themeData.colorScheme.secondary, borderRadius: BorderRadius.circular(8)), child: Center( child: Text(buttonText, style: themeData.textTheme.displayLarge!.copyWith( fontSize: 14, color: Colors.blueGrey[800], fontWeight: FontWeight.bold, letterSpacing: 4 ), ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail/todo_detail_page.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/todos/todoForm/todoform_bloc.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/injection.dart'; import 'package:todo/presentation/routes/router.gr.dart'; import 'package:todo/presentation/todo_detail/widgets/safe_progress_overlay.dart'; import 'package:todo/presentation/todo_detail/widgets/todo_form.dart'; @RoutePage(name: 'TodoDetailRoute') class TodoDetail extends StatelessWidget { final Todo? todo; const TodoDetail({Key? key, required this.todo}) : super(key: key); @override Widget build(BuildContext context) { return BlocProvider( create: (context) => sl<TodoformBloc>()..add(InitializeTodoDetailPage(todo: todo)), child: BlocConsumer<TodoformBloc, TodoformState>( listenWhen: (p, c) => p.failureOrSuccessOption != c.failureOrSuccessOption, listener: (context, state) { state.failureOrSuccessOption.fold( () {}, (eitherFailureOrSuccess) => eitherFailureOrSuccess.fold( (failure) => ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text("failure"), backgroundColor: Colors.redAccent)), (_) => Navigator.of(context).popUntil( (route) => route.settings.name == HomeRoute.name))); }, builder: (context, state) { return Scaffold( appBar: AppBar( centerTitle: true, title: Text(todo == null ? "Create Todo" : "Edit Todo"), ), body: Stack( children: [ const TodoForm(), SafeInProgressOverlay(isSaving: state.isSaving) ], ), ); }, ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail/widgets/color_field.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/todos/todoForm/todoform_bloc.dart'; import 'package:todo/domain/entities/todo_color.dart'; class ColorField extends StatelessWidget { final TodoColor color; const ColorField({Key? key, required this.color}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( height: 80, child: ListView.separated( scrollDirection: Axis.horizontal, physics: const BouncingScrollPhysics(), padding: const EdgeInsets.symmetric(horizontal: 8), itemBuilder: (context, index) { final itemColor = TodoColor.predefinedColors[index]; return InkWell( onTap: (){ BlocProvider.of<TodoformBloc>(context).add(ColorChangedEvent(color: itemColor)); }, child: Material( color: itemColor, elevation: 10, shape: CircleBorder( side: BorderSide( width: 2, color: itemColor == color.color ? Colors.white : Colors.black)), child: const SizedBox( height: 50, width: 50, ), ), ); }, separatorBuilder: (context, index) { return const SizedBox( width: 10, ); }, itemCount: TodoColor.predefinedColors.length), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail/widgets/todo_form.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/todos/todoForm/todoform_bloc.dart'; import 'package:todo/presentation/core/custom_button.dart'; import 'package:todo/presentation/todo_detail/widgets/color_field.dart'; class TodoForm extends StatelessWidget { const TodoForm({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final GlobalKey<FormState> formKey = GlobalKey<FormState>(); final textEditingControllerTitle = TextEditingController(); final textEditingControllerBody = TextEditingController(); late String body; late String title; String? validateBody(String? input) { if (input == null || input.isEmpty) { return "please enter a description"; } else if (input.length < 300) { body = input; return null; } else { return "body too long"; } } String? validateTitle(String? input) { if (input == null || input.isEmpty) { return "please enter a title"; } else if (input.length < 30) { title = input; return null; } else { return "title too long"; } } return BlocConsumer<TodoformBloc, TodoformState>( listenWhen: (p, c) => p.isEditing != c.isEditing, listener: (context, state) { textEditingControllerTitle.text = state.todo.title; textEditingControllerBody.text = state.todo.body; }, builder: (context, state) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 30), child: Form( key: formKey, autovalidateMode: state.showErrorMessages ? AutovalidateMode.always : AutovalidateMode.disabled, child: ListView( children: [ TextFormField( controller: textEditingControllerTitle, cursorColor: Colors.white, validator: validateTitle, maxLength: 100, maxLines: 2, minLines: 1, decoration: InputDecoration( labelText: "Title", counterText: "", border: OutlineInputBorder( borderRadius: BorderRadius.circular(8))), ), const SizedBox( height: 20, ), TextFormField( controller: textEditingControllerBody, cursorColor: Colors.white, validator: validateBody, maxLength: 300, maxLines: 8, minLines: 5, decoration: InputDecoration( labelText: "Body", counterText: "", border: OutlineInputBorder( borderRadius: BorderRadius.circular(8))), ), const SizedBox( height: 20, ), ColorField(color: state.todo.color), const SizedBox( height: 20, ), CustomButton( buttonText: "Safe", callback: () { if (formKey.currentState!.validate()) { BlocProvider.of<TodoformBloc>(context) .add(SafePressedEvent(body: body, title: title)); } else { BlocProvider.of<TodoformBloc>(context) .add(SafePressedEvent(body: null, title: null)); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.redAccent, content: Text( "Invalid Input", style: Theme.of(context).textTheme.bodyLarge, ))); } }) ], ), ), ); }, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/todo_detail/widgets/safe_progress_overlay.dart
import 'package:flutter/material.dart'; class SafeInProgressOverlay extends StatelessWidget { final bool isSaving; const SafeInProgressOverlay({ Key? key , required this.isSaving}) : super(key: key); @override Widget build(BuildContext context) { return IgnorePointer( ignoring: !isSaving, child: Visibility( visible: isSaving, child: Center( child: CircularProgressIndicator(color: Theme.of(context).colorScheme.secondary,), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home/home_page.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/auth/authbloc/auth_bloc.dart'; import 'package:todo/application/todos/controller/controller_bloc.dart'; import 'package:todo/application/todos/observer/observer_bloc.dart'; import 'package:todo/core/Failures/todo_failures.dart'; import 'package:todo/injection.dart'; import 'package:todo/presentation/home/widgets/home_body.dart'; import 'package:todo/presentation/routes/router.gr.dart'; @RoutePage() class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); String _mapFailureToMessage(TodoFailure todoFailure) { switch (todoFailure.runtimeType) { case InsufficientPermisssons: return "You have not the permissions to do that"; case UnexpectedFailure: return "Something went wrong"; default: return "Something went wrong"; } } @override Widget build(BuildContext context) { final observerBloc = sl<ObserverBloc>()..add(ObserveAllEvent()); return MultiBlocProvider( providers: [ BlocProvider<ObserverBloc>( create: (context) => observerBloc, ), BlocProvider<ControllerBloc>( create: (context) => sl<ControllerBloc>(), ) ], child: MultiBlocListener( listeners: [ BlocListener<AuthBloc, AuthState>(listener: (context, state) { if (state is AuthStateUnauthenticated) { AutoRouter.of(context).push(const SignUpRoute()); } }), BlocListener<ControllerBloc, ControllerState>( listener: (context, state) { if (state is ControllerFailure) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.redAccent, content: Text(_mapFailureToMessage(state.todoFailure)))); } }) ], child: Scaffold( /* appBar: AppBar( leading: IconButton( onPressed: () { BlocProvider.of<AuthBloc>(context).add(SignOutPressedEvent()); }, icon: const Icon(Icons.exit_to_app)), title: const Text("Todo"), ),*/ body: const HomeBody(), floatingActionButton: FloatingActionButton( backgroundColor: Colors.white, onPressed: () { AutoRouter.of(context).push(TodoDetailRoute(todo: null)); }, child: const Icon( Icons.add, size: 26, ), ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home/widgets/progress_bar_painter.dart
import 'package:flutter/material.dart'; class ProgressPainter extends CustomPainter { double barWidth; double barHeight; double donePercent; Color backgroundColor; Color percentageColor; ProgressPainter({required this.donePercent, required this.barHeight, required this.barWidth, required this.backgroundColor, required this.percentageColor}); getPaint(Color color) { return Paint() ..color = color ..style = PaintingStyle.fill; } @override void paint(Canvas canvas, Size size) { Paint defaultBarPaint = getPaint(backgroundColor); Paint percentageBarPaint = getPaint(percentageColor); canvas.drawRRect( RRect.fromRectAndRadius( Offset(-(barWidth / 2), -barHeight / 2) & Size(barWidth, barHeight), Radius.circular(barHeight / 2)), defaultBarPaint); canvas.drawRRect( RRect.fromRectAndRadius( Offset(-(barWidth / 2), -barHeight / 2) & Size(barWidth * donePercent, barHeight), Radius.circular(barHeight / 2)), percentageBarPaint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return true; } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home/widgets/todo_item.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/todos/controller/controller_bloc.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/presentation/routes/router.gr.dart'; class TodoItem extends StatelessWidget { final Todo todo; const TodoItem({Key? key, required this.todo}) : super(key: key); void _showDeletDialog( {required BuildContext context, required ControllerBloc bloc}) { showDialog( context: context, builder: (context) { return AlertDialog( title: const Text("Selected Todo to delete:"), content: Text( todo.title, maxLines: 3, overflow: TextOverflow.ellipsis, ), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: const Text( "CANCLE", style: TextStyle(color: Colors.white), )), TextButton( onPressed: () { bloc.add(DeleteTodoEvent(todo: todo)); Navigator.pop(context); }, child: const Text( "DELETE", style: TextStyle(color: Colors.white), )), ], ); }); } @override Widget build(BuildContext context) { final themeData = Theme.of(context); return InkResponse( onTap: () { AutoRouter.of(context).push(TodoDetailRoute(todo: todo)); }, onLongPress: () { final controllerBloc = context.read<ControllerBloc>(); _showDeletDialog(context: context, bloc: controllerBloc); }, child: Material( elevation: 16, borderRadius: BorderRadius.circular(15), color: Colors.transparent, child: Container( decoration: BoxDecoration( color: todo.color.color, borderRadius: BorderRadius.circular(15)), child: Padding( padding: const EdgeInsets.all(15), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( todo.title, maxLines: 2, overflow: TextOverflow.ellipsis, style: themeData.textTheme.displayLarge! .copyWith(fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox( height: 10, ), Text( todo.body, maxLines: 3, overflow: TextOverflow.ellipsis, style: themeData.textTheme.bodyLarge!.copyWith(fontSize: 16), ), const Spacer(), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ SizedBox( height: 25, width: 25, child: Transform.scale( scale: 1.3, child: Checkbox( shape: const CircleBorder(), activeColor: Colors.white, checkColor: themeData.scaffoldBackgroundColor, value: todo.done, onChanged: (value) { if (value != null) { BlocProvider.of<ControllerBloc>(context) .add(UpdateTodoEvent(todo: todo, done: value)); } }, ), ), ), ], ) ], ), ), ), )); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home/widgets/home_body.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/todos/observer/observer_bloc.dart'; import 'package:todo/presentation/home/widgets/flexible_space.dart'; import 'package:todo/presentation/home/widgets/progress_bar.dart'; import 'package:todo/presentation/home/widgets/todo_item.dart'; class HomeBody extends StatelessWidget { const HomeBody({Key? key}) : super(key: key); static const double _spacing = 20; @override Widget build(BuildContext context) { final themeData = Theme.of(context); return BlocBuilder<ObserverBloc, ObserverState>( builder: (context, state) { if (state is ObserverInitial) { return Container(); } else if (state is ObserverLoading) { return Center( child: CircularProgressIndicator( color: themeData.colorScheme.secondary, ), ); } else if (state is ObserverFailure) { return const Center(child: Text("Failure")); } else if (state is ObserverSuccess) { return SafeArea( child: CustomScrollView( physics: const BouncingScrollPhysics(), slivers: [ SliverAppBar( collapsedHeight: 70, expandedHeight: 280, backgroundColor: themeData.scaffoldBackgroundColor, pinned: true, flexibleSpace: const FlexibleSpace(), ), SliverPadding( padding: const EdgeInsets.only(left: _spacing, right: _spacing), sliver: SliverToBoxAdapter( child: ProgressBar(todos: state.todos), ), ), SliverPadding( padding: const EdgeInsets.all(_spacing), sliver: SliverGrid( delegate: SliverChildBuilderDelegate((context, index) { final todo = state.todos[index]; return TodoItem( todo: todo, ); }, childCount: state.todos.length), gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200, crossAxisSpacing: _spacing, childAspectRatio: 4 / 5, mainAxisSpacing: _spacing), )), ], ), ); } return Container(); }, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home/widgets/progress_bar.dart
import 'package:flutter/material.dart'; import 'package:todo/domain/entities/todo.dart'; import 'package:todo/presentation/home/widgets/progress_bar_painter.dart'; class ProgressBar extends StatelessWidget { final List<Todo> todos; const ProgressBar({Key? key, required this.todos}) : super(key: key); double _getDoneTodoPercentage({required List<Todo> todos}){ int done = 0; for(var todo in todos){ if(todo.done){ done++; } } double percent = (1/todos.length) * done; return percent; } @override Widget build(BuildContext context) { final _radius = BorderRadius.circular(10); return Material( elevation: 16, borderRadius: _radius, child: Container( height: 80, decoration: BoxDecoration( color: Theme.of(context).appBarTheme.backgroundColor, borderRadius: _radius), child: Padding( padding: const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Todos progress", style: Theme.of(context) .textTheme .displayLarge! .copyWith(fontSize: 16), ), const SizedBox(height: 10), Expanded(child: LayoutBuilder( builder: (context, constraints) { return Center( child: CustomPaint( painter: ProgressPainter( donePercent: _getDoneTodoPercentage(todos: todos), backgroundColor: Colors.grey, percentageColor: Colors.tealAccent, barHeight: 25, barWidth: constraints.maxWidth), ), ); })) ], ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/home/widgets/flexible_space.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/auth/authbloc/auth_bloc.dart'; class FlexibleSpace extends StatelessWidget { const FlexibleSpace({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return FlexibleSpaceBar( background: Padding( padding: const EdgeInsets.only(bottom: 90, top: 15), child: Image.asset("assets/todo.png"), ), titlePadding: const EdgeInsets.only(left: 20, bottom: 10), title: Row( children: [ Text( "Todo", textScaleFactor: 2, style: Theme.of(context).textTheme.displayLarge! .copyWith(fontWeight: FontWeight.bold), ), const Spacer(), IconButton( onPressed: () { BlocProvider.of<AuthBloc>(context).add(SignOutPressedEvent()); }, icon: const Icon(Icons.exit_to_app)), ], ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/presentation/splash/splash_page.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:todo/application/auth/authbloc/auth_bloc.dart'; import 'package:todo/presentation/routes/router.gr.dart'; @RoutePage() class SplashPage extends StatelessWidget { const SplashPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return BlocListener<AuthBloc, AuthState>( listener: (context, state) { if(state is AuthStateAuthenticated){ // navigate to home context.router.replace(const HomeRoute()); } else if (state is AuthStateUnauthenticated){ // navigate to signin context.router.replace(const SignUpRoute()); } }, child: Scaffold( body: Center( child: CircularProgressIndicator( color: Theme.of(context).colorScheme.secondary, ), ), ), ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain/repositries/todo_repository.dart
import 'package:dartz/dartz.dart'; import 'package:todo/core/Failures/todo_failures.dart'; import 'package:todo/domain/entities/todo.dart'; abstract class TodoRepository { Stream<Either<TodoFailure, List<Todo>>> watchAll(); Future<Either<TodoFailure, Unit>> create(Todo todo); Future<Either<TodoFailure, Unit>> update(Todo todo); Future<Either<TodoFailure, Unit>> delete(Todo todo); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain/repositries/auth_repository.dart
import 'package:dartz/dartz.dart'; import 'package:todo/core/Failures/auth_failures.dart'; import 'package:todo/domain/entities/user.dart'; abstract class AuthRepository { Future<Either<AuthFailure, Unit>> registerWithEmailAndPassword( {required String email, required String password}); Future<Either<AuthFailure, Unit>> signInWithEmailAndPassword( {required String email, required String password}); Future<void> signOut(); Option<CustomUser> getSignedInUser(); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain/entities/todo_color.dart
import 'package:flutter/material.dart'; class TodoColor { final Color color; static const List<Color> predefinedColors = [ Color(0xffD62006), Color(0xff3BC1EC), Color(0xffF5C412), Color(0xff1246F5), Color(0xff6CB705), Color(0xff9A54E6), ]; TodoColor({required this.color}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain/entities/id.dart
import 'package:uuid/uuid.dart'; class UniqueID { const UniqueID._(this.value); final String value; factory UniqueID() { return UniqueID._(const Uuid().v1()); } factory UniqueID.fromUniqueString(String uniqueID) { return UniqueID._(uniqueID); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain/entities/todo.dart
import 'package:todo/domain/entities/id.dart'; import 'package:todo/domain/entities/todo_color.dart'; class Todo { final UniqueID id; final String title; final String body; final bool done; final TodoColor color; Todo( {required this.id, required this.body, required this.title, required this.color, required this.done}); factory Todo.empty() { return Todo( id: UniqueID(), title: "", body: "", done: false, color: TodoColor(color: TodoColor.predefinedColors[5])); } Todo copyWith({ UniqueID? id, String? title, String? body, bool? done, TodoColor? color, }) { return Todo( id: id ?? this.id, title: title ?? this.title, body: body ?? this.body, done: done ?? this.done, color: color ?? this.color, ); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/todo_redesign/lib/domain/entities/user.dart
import 'package:todo/domain/entities/id.dart'; class CustomUser { final UniqueID id; CustomUser({required this.id}); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/18_vererbung_mixins.dart
void main() { Student student1 = Student(); student1.setStudienjahr = 2; int studienjahr = student1.getStudienjahr; print(studienjahr); student1.feiern(); student1.setName = "patrick"; student1.laufen(); student1.lernen(); } class Person { late String _name; late int _alter; // getter String get getName => this._name; int get getAlter => this._alter; // setter set setName(String name) { this._name = name; } set setAlter(int alter) { this._alter = alter; } // methoden void laufen() { print("person läuft!"); } } mixin Lernender { void lernen() { print("lernen!"); } } class Student extends Person with Lernender { late int _studienjahr; // getter int get getStudienjahr => this._studienjahr; // setter set setStudienjahr(int studienjahr) { this._studienjahr = studienjahr; } // methoden void feiern() { print("party!"); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/13_methoden_mit_rückgabewert.dart
void main(){ print("vor"); int ergebnis = addieren(x:10,y:11); print(ergebnis); int ergebnis2 = addieren(x:10,y: ergebnis); print(ergebnis2); print("danach"); } int addieren({required int x,required int y}){ int z = x+y; return z; }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/9_do_while.dart
void main (){ int number = 1; do{ print(number); number++; }while(number < 1); // Fußgesteuert }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/6_if_Abfragen.dart
void main (){ int alter = 16; //alter = alter + 1; print("vor dem if"); if (alter >= 18){ print("Du Darfst in den Film."); } else if (alter == 17){ print("Du Darfst gerade noch in den Film."); }else{ print("Dur darfst nicht"); } print("nach dem if"); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/7_switch_case.dart
void main (){ int alter = 16; String name = "Hans"; print("vor dem switch"); switch (name){ case "Peter": print("ich bin Peter"); break; case "Hans": print("ich bin Hans"); break; default: print("keine ahnung"); } print("nach dem switch"); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/3_datentypen.dart
void main(){ int alter = 32; //Iteger double meinDouble = 4.4; // double bool meinBool = false; // bool // ############################### String meinString = "Der Ball"; String zweitenString = " ist rot."; String verkettet = meinString + zweitenString; print(verkettet); print(meinString + zweitenString); print(meinString + " ist blau."); String multiline = ''' das ist ein string '''; print(multiline); int wert = 3; String beispiel = "Der Wert ist: $wert"; print(beispiel); // ! Statisch int alter1 = 32; //Iteger double meinDouble1 = 4.4; // double bool meinBool1 = false; // bool String meinString1 = "Der Ball"; // ! Automatisch var alter2 = 32; //Iteger var meinDouble2 = 4.4; // double var meinBool2 = false; // bool var meinString2 = "Der Ball"; dynamic variable3 ; variable3 = 3; variable3 = "string"; }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/8_schleifen_while.dart
void main (){ int number = 1; while(number < 100){ print(number); number += 2; } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/11_for_each.dart
void main (){ List<int> liste = [3,4,5,6,7,5]; List<int> liste2 = []; /* for(int i = 0; i < liste.length ; i++){ if(liste[i]==3){ liste2.add(liste[i]); } print(liste[i]); }*/ liste.forEach((element) { element++; liste2.add(element); }); print(liste); print(liste2); }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/17_konstruktor.dart
void main() { Car car1 = Car(color: "red", ps: 300); } class Car { Car({required this.color, required this.ps}); final String color; final int ps; void drive() { print("car is moving"); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/16_getter_setter.dart
void main() { Car car1 = Car(); car1.setColor = "rot"; Car car2 = Car(); car2.setColor = "blau"; String colorFromCar = car1.color; car1.sayColor(); car2.sayColor(); car1.drive(); } class Car { //! setter - kontrolliertes setzten des ertes set setColor(String color) { // platz für validierungen this._color = color; } //! getter String get color => this._color; // kurzschreibweise => /* String get clolor { platz für validierungen return this.color; }*/ //! attribute late String _color; // late -> weise später einen wert zu //! methoden void drive() { _legeGangEin(); print("car is moving"); } void _legeGangEin() { print("Gang 1"); } void sayColor() { print(this._color); } }
0
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery
mirrored_repositories/FlutterLeichtGemacht_ZeroToMasery/dart_grundlagen/5_lists_maps.dart
void main (){ List<int> liste = [1,2,3]; print(liste); print(liste[0]); print(liste.first); print(liste.length); print(liste.isEmpty); liste.add(3); print(liste); Map<String,String> map = {"key1":"value1", "key2":"value2",}; print(map.length); print(map.keys); print(map["key2"]); }
0