master #81
12
melos.yaml
12
melos.yaml
@ -24,13 +24,17 @@ scripts:
|
|||||||
melos exec -c 1 -- flutter analyze --fatal-infos
|
melos exec -c 1 -- flutter analyze --fatal-infos
|
||||||
description: Run `flutter analyze` for all packages.
|
description: Run `flutter analyze` for all packages.
|
||||||
|
|
||||||
|
fix:
|
||||||
|
run: melos exec dart fix . --apply
|
||||||
|
description: Run `dart fix` for all packages.
|
||||||
|
|
||||||
format:
|
format:
|
||||||
run: melos exec flutter format . --fix
|
run: melos exec dart format .
|
||||||
description: Run `flutter format` for all packages.
|
description: Run `dart format` for all packages.
|
||||||
|
|
||||||
format-check:
|
format-check:
|
||||||
run: melos exec flutter format . --set-exit-if-changed
|
run: melos exec dart fix . --set-exit-if-changed
|
||||||
description: Run `flutter format` checks for all packages.
|
description: Run `dart fix` checks for all packages.
|
||||||
|
|
||||||
clean:deep:
|
clean:deep:
|
||||||
run: git clean -x -d -f -q
|
run: git clean -x -d -f -q
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import 'package:architecture_example/data/models/photo_model.dart';
|
import 'package:architecture_example/data/models/photo_model.dart';
|
||||||
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
@ -24,7 +24,6 @@ import 'package:wyatt_architecture/wyatt_architecture.dart';
|
|||||||
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||||
|
|
||||||
class PhotoRepositoryImpl extends PhotoRepository {
|
class PhotoRepositoryImpl extends PhotoRepository {
|
||||||
|
|
||||||
PhotoRepositoryImpl(
|
PhotoRepositoryImpl(
|
||||||
this._photoRemoteDataSource,
|
this._photoRemoteDataSource,
|
||||||
this._albumRemoteDataSource,
|
this._albumRemoteDataSource,
|
||||||
|
@ -21,7 +21,6 @@ import 'package:architecture_example/domain/repositories/photo_repository.dart';
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class AddPhotoToFavorites extends AsyncUseCase<Photo, List<Photo>> {
|
class AddPhotoToFavorites extends AsyncUseCase<Photo, List<Photo>> {
|
||||||
|
|
||||||
AddPhotoToFavorites(this._photoRepository);
|
AddPhotoToFavorites(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import 'package:architecture_example/domain/repositories/photo_repository.dart';
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class CheckIfPhotoIsInFavorites extends AsyncUseCase<int, bool> {
|
class CheckIfPhotoIsInFavorites extends AsyncUseCase<int, bool> {
|
||||||
|
|
||||||
CheckIfPhotoIsInFavorites(this._photoRepository);
|
CheckIfPhotoIsInFavorites(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import 'package:architecture_example/domain/repositories/photo_repository.dart';
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class DisplayFavorites extends AsyncUseCase<NoParam, List<Photo>> {
|
class DisplayFavorites extends AsyncUseCase<NoParam, List<Photo>> {
|
||||||
|
|
||||||
DisplayFavorites(this._photoRepository);
|
DisplayFavorites(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import 'package:architecture_example/domain/repositories/photo_repository.dart';
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class DisplayPhoto extends AsyncUseCase<int, Photo> {
|
class DisplayPhoto extends AsyncUseCase<int, Photo> {
|
||||||
|
|
||||||
DisplayPhoto(this._photoRepository);
|
DisplayPhoto(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import 'package:architecture_example/domain/usecases/photos/params/query_paramet
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class OpenAlbum extends AsyncUseCase<QueryParameters, List<Photo>> {
|
class OpenAlbum extends AsyncUseCase<QueryParameters, List<Photo>> {
|
||||||
|
|
||||||
OpenAlbum(this._photoRepository);
|
OpenAlbum(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class QueryParameters {
|
class QueryParameters {
|
||||||
|
|
||||||
QueryParameters(this.start, this.limit, {this.albumId = -1});
|
QueryParameters(this.start, this.limit, {this.albumId = -1});
|
||||||
final int albumId;
|
final int albumId;
|
||||||
final int? start;
|
final int? start;
|
||||||
|
@ -21,7 +21,6 @@ import 'package:architecture_example/domain/repositories/photo_repository.dart';
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class RemovePhotoFromFavorites extends AsyncUseCase<int, List<Photo>> {
|
class RemovePhotoFromFavorites extends AsyncUseCase<int, List<Photo>> {
|
||||||
|
|
||||||
RemovePhotoFromFavorites(this._photoRepository);
|
RemovePhotoFromFavorites(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import 'package:architecture_example/domain/usecases/photos/params/query_paramet
|
|||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
|
|
||||||
class RetrieveAllAlbums extends AsyncUseCase<QueryParameters, List<Album>> {
|
class RetrieveAllAlbums extends AsyncUseCase<QueryParameters, List<Album>> {
|
||||||
|
|
||||||
RetrieveAllAlbums(this._photoRepository);
|
RetrieveAllAlbums(this._photoRepository);
|
||||||
final PhotoRepository _photoRepository;
|
final PhotoRepository _photoRepository;
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ EventTransformer<E> throttleDroppable<E>(Duration duration) =>
|
|||||||
(events, mapper) => droppable<E>().call(events.throttle(duration), mapper);
|
(events, mapper) => droppable<E>().call(events.throttle(duration), mapper);
|
||||||
|
|
||||||
class AlbumBloc extends Bloc<AlbumEvent, AlbumState> {
|
class AlbumBloc extends Bloc<AlbumEvent, AlbumState> {
|
||||||
|
|
||||||
AlbumBloc(this._retrieveAllAlbums) : super(const AlbumState()) {
|
AlbumBloc(this._retrieveAllAlbums) : super(const AlbumState()) {
|
||||||
on<AlbumFetched>(
|
on<AlbumFetched>(
|
||||||
_onAlbumFetched,
|
_onAlbumFetched,
|
||||||
|
@ -22,8 +22,11 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class AlbumsList extends StatefulWidget {
|
class AlbumsList extends StatefulWidget {
|
||||||
const AlbumsList(
|
const AlbumsList({
|
||||||
{required this.albums, required this.hasReachedMax, super.key,});
|
required this.albums,
|
||||||
|
required this.hasReachedMax,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final List<Album> albums;
|
final List<Album> albums;
|
||||||
final bool hasReachedMax;
|
final bool hasReachedMax;
|
||||||
|
@ -26,7 +26,6 @@ abstract class PhotoDetailsState extends Equatable {
|
|||||||
class PhotoDetailsInitial extends PhotoDetailsState {}
|
class PhotoDetailsInitial extends PhotoDetailsState {}
|
||||||
|
|
||||||
class PhotoDetailsSuccess extends PhotoDetailsState {
|
class PhotoDetailsSuccess extends PhotoDetailsState {
|
||||||
|
|
||||||
const PhotoDetailsSuccess(this.photo, {required this.isFavorite});
|
const PhotoDetailsSuccess(this.photo, {required this.isFavorite});
|
||||||
final Photo photo;
|
final Photo photo;
|
||||||
final bool isFavorite;
|
final bool isFavorite;
|
||||||
@ -36,7 +35,6 @@ class PhotoDetailsSuccess extends PhotoDetailsState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PhotoDetailsFailure extends PhotoDetailsState {
|
class PhotoDetailsFailure extends PhotoDetailsState {
|
||||||
|
|
||||||
const PhotoDetailsFailure(this.error);
|
const PhotoDetailsFailure(this.error);
|
||||||
final String error;
|
final String error;
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
part 'favorite_checker_state.dart';
|
part 'favorite_checker_state.dart';
|
||||||
|
|
||||||
class FavoriteCheckerCubit extends Cubit<FavoriteCheckerState> {
|
class FavoriteCheckerCubit extends Cubit<FavoriteCheckerState> {
|
||||||
|
|
||||||
FavoriteCheckerCubit(this._checkIfPhotoIsInFavorites)
|
FavoriteCheckerCubit(this._checkIfPhotoIsInFavorites)
|
||||||
: super(FavoriteCheckerInitial());
|
: super(FavoriteCheckerInitial());
|
||||||
final CheckIfPhotoIsInFavorites _checkIfPhotoIsInFavorites;
|
final CheckIfPhotoIsInFavorites _checkIfPhotoIsInFavorites;
|
||||||
|
@ -10,7 +10,6 @@ abstract class FavoriteCheckerState extends Equatable {
|
|||||||
class FavoriteCheckerInitial extends FavoriteCheckerState {}
|
class FavoriteCheckerInitial extends FavoriteCheckerState {}
|
||||||
|
|
||||||
class FavoriteCheckerSuccess extends FavoriteCheckerState {
|
class FavoriteCheckerSuccess extends FavoriteCheckerState {
|
||||||
|
|
||||||
const FavoriteCheckerSuccess(this.photoId, {required this.isFavorite});
|
const FavoriteCheckerSuccess(this.photoId, {required this.isFavorite});
|
||||||
final int photoId;
|
final int photoId;
|
||||||
final bool isFavorite;
|
final bool isFavorite;
|
||||||
@ -20,7 +19,6 @@ class FavoriteCheckerSuccess extends FavoriteCheckerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FavoriteCheckerFailure extends FavoriteCheckerState {
|
class FavoriteCheckerFailure extends FavoriteCheckerState {
|
||||||
|
|
||||||
const FavoriteCheckerFailure(this.error);
|
const FavoriteCheckerFailure(this.error);
|
||||||
final String error;
|
final String error;
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ EventTransformer<E> throttleDroppable<E>(Duration duration) =>
|
|||||||
(events, mapper) => droppable<E>().call(events.throttle(duration), mapper);
|
(events, mapper) => droppable<E>().call(events.throttle(duration), mapper);
|
||||||
|
|
||||||
class PhotoBloc extends Bloc<PhotoEvent, PhotoState> {
|
class PhotoBloc extends Bloc<PhotoEvent, PhotoState> {
|
||||||
|
|
||||||
PhotoBloc(this._openAlbum) : super(const PhotoState()) {
|
PhotoBloc(this._openAlbum) : super(const PhotoState()) {
|
||||||
on<PhotoFetched>(
|
on<PhotoFetched>(
|
||||||
_onPhotoFetched,
|
_onPhotoFetched,
|
||||||
|
@ -24,7 +24,6 @@ abstract class PhotoEvent extends Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PhotoFetched extends PhotoEvent {
|
class PhotoFetched extends PhotoEvent {
|
||||||
|
|
||||||
const PhotoFetched(this.albumId);
|
const PhotoFetched(this.albumId);
|
||||||
final int albumId;
|
final int albumId;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,10 @@ class PhotosGridThumbnail
|
|||||||
),
|
),
|
||||||
if (state is FavoriteCheckerSuccess && state.isFavorite) ...[
|
if (state is FavoriteCheckerSuccess && state.isFavorite) ...[
|
||||||
const Positioned(
|
const Positioned(
|
||||||
bottom: 10, right: 10, child: Icon(Icons.favorite),)
|
bottom: 10,
|
||||||
|
right: 10,
|
||||||
|
child: Icon(Icons.favorite),
|
||||||
|
)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||||
|
|
||||||
abstract class AppException implements Exception {
|
abstract class AppException implements Exception {
|
||||||
|
|
||||||
AppException([this.message]);
|
AppException([this.message]);
|
||||||
final String? message;
|
final String? message;
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
|||||||
class MockAuthenticationRepository extends Mock
|
class MockAuthenticationRepository extends Mock
|
||||||
implements AuthenticationRepository<int> {}
|
implements AuthenticationRepository<int> {}
|
||||||
|
|
||||||
class MockAuthenticationCubit extends Mock implements AuthenticationCubit<int> {
|
class MockAuthenticationCubit extends Mock
|
||||||
}
|
implements AuthenticationCubit<int> {}
|
||||||
|
|
||||||
class MockAccount extends Mock implements Account {}
|
class MockAccount extends Mock implements Account {}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
|||||||
class MockAuthenticationRepository extends Mock
|
class MockAuthenticationRepository extends Mock
|
||||||
implements AuthenticationRepository<int> {}
|
implements AuthenticationRepository<int> {}
|
||||||
|
|
||||||
class MockAuthenticationCubit extends Mock implements AuthenticationCubit<int> {
|
class MockAuthenticationCubit extends Mock
|
||||||
}
|
implements AuthenticationCubit<int> {}
|
||||||
|
|
||||||
class MockAccount extends Mock implements Account {}
|
class MockAccount extends Mock implements Account {}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
|||||||
class MockAuthenticationRepository extends Mock
|
class MockAuthenticationRepository extends Mock
|
||||||
implements AuthenticationRepository<int> {}
|
implements AuthenticationRepository<int> {}
|
||||||
|
|
||||||
class MockAuthenticationCubit extends Mock implements AuthenticationCubit<int> {
|
class MockAuthenticationCubit extends Mock
|
||||||
}
|
implements AuthenticationCubit<int> {}
|
||||||
|
|
||||||
class MockAccount extends Mock implements Account {}
|
class MockAccount extends Mock implements Account {}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
|||||||
class MockAuthenticationRepository extends Mock
|
class MockAuthenticationRepository extends Mock
|
||||||
implements AuthenticationRepository<int> {}
|
implements AuthenticationRepository<int> {}
|
||||||
|
|
||||||
class MockAuthenticationCubit extends Mock implements AuthenticationCubit<int> {
|
class MockAuthenticationCubit extends Mock
|
||||||
}
|
implements AuthenticationCubit<int> {}
|
||||||
|
|
||||||
class MockAccount extends Mock implements Account {}
|
class MockAccount extends Mock implements Account {}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ class CounterBloc extends Bloc<CounterEvent, CounterState> {
|
|||||||
final CounterRepository counterRepository;
|
final CounterRepository counterRepository;
|
||||||
|
|
||||||
CounterBloc(this.counterRepository) : super(const CounterInitial()) {
|
CounterBloc(this.counterRepository) : super(const CounterInitial()) {
|
||||||
|
|
||||||
on<CounterIncrement>((event, emit) {
|
on<CounterIncrement>((event, emit) {
|
||||||
emit(CounterModified(counterRepository.increment(state.count)));
|
emit(CounterModified(counterRepository.increment(state.count)));
|
||||||
});
|
});
|
||||||
|
@ -32,4 +32,3 @@ class CounterInitial extends CounterState {
|
|||||||
class CounterModified extends CounterState {
|
class CounterModified extends CounterState {
|
||||||
const CounterModified(super.count);
|
const CounterModified(super.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,14 +24,16 @@ class CounterBlocPage
|
|||||||
const CounterBlocPage({super.key});
|
const CounterBlocPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CounterBloc create(BuildContext context) => CounterBloc(repo<CounterRepository>(context));
|
CounterBloc create(BuildContext context) =>
|
||||||
|
CounterBloc(repo<CounterRepository>(context));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget onBuild(BuildContext context, CounterState state) {
|
Widget onBuild(BuildContext context, CounterState state) {
|
||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Counter with Bloc')),
|
appBar: AppBar(title: const Text('Counter with Bloc')),
|
||||||
body: Center(child: Text('${state.count}', style: textTheme.headline2)),
|
body:
|
||||||
|
Center(child: Text('${state.count}', style: textTheme.displayMedium)),
|
||||||
floatingActionButton: Column(
|
floatingActionButton: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
@ -28,7 +28,8 @@ class CounterConsumerPage
|
|||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Counter with Consumer')),
|
appBar: AppBar(title: const Text('Counter with Consumer')),
|
||||||
body: Center(child: Text('${state.count}', style: textTheme.headline2)),
|
body:
|
||||||
|
Center(child: Text('${state.count}', style: textTheme.displayMedium)),
|
||||||
floatingActionButton: Column(
|
floatingActionButton: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
@ -19,19 +19,20 @@ import 'package:bloc_helper_example/counter/repository/counter_repository.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
||||||
|
|
||||||
class CounterCubitPage
|
class CounterCubitPage extends CubitScreen<CounterCubit, CounterState> {
|
||||||
extends CubitScreen<CounterCubit, CounterState> {
|
|
||||||
const CounterCubitPage({super.key});
|
const CounterCubitPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CounterCubit create(BuildContext context) => CounterCubit(repo<CounterRepository>(context));
|
CounterCubit create(BuildContext context) =>
|
||||||
|
CounterCubit(repo<CounterRepository>(context));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget onBuild(BuildContext context, CounterState state) {
|
Widget onBuild(BuildContext context, CounterState state) {
|
||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Counter with Cubit')),
|
appBar: AppBar(title: const Text('Counter with Cubit')),
|
||||||
body: Center(child: Text('${state.count}', style: textTheme.headline2)),
|
body:
|
||||||
|
Center(child: Text('${state.count}', style: textTheme.displayMedium)),
|
||||||
floatingActionButton: Column(
|
floatingActionButton: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
@ -35,7 +35,7 @@ class CounterProviderPage
|
|||||||
appBar: AppBar(title: const Text('Counter with Provider')),
|
appBar: AppBar(title: const Text('Counter with Provider')),
|
||||||
body: Center(child: BlocBuilder<CounterBloc, CounterState>(
|
body: Center(child: BlocBuilder<CounterBloc, CounterState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Text('${state.count}', style: textTheme.headline2);
|
return Text('${state.count}', style: textTheme.displayMedium);
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
floatingActionButton: Column(
|
floatingActionButton: Column(
|
||||||
|
@ -32,4 +32,3 @@ class CounterInitial extends CounterState {
|
|||||||
class CounterModified extends CounterState {
|
class CounterModified extends CounterState {
|
||||||
const CounterModified(super.count);
|
const CounterModified(super.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ class MainPage extends StatelessWidget {
|
|||||||
onPressed: () => Navigator.of(context)
|
onPressed: () => Navigator.of(context)
|
||||||
.push(MaterialPageRoute(builder: (context) {
|
.push(MaterialPageRoute(builder: (context) {
|
||||||
return BlocProvider<CounterCubit>(
|
return BlocProvider<CounterCubit>(
|
||||||
create: (context) => CounterCubit(context.read<CounterRepository>()),
|
create: (context) =>
|
||||||
|
CounterCubit(context.read<CounterRepository>()),
|
||||||
child: const CounterConsumerPage(),
|
child: const CounterConsumerPage(),
|
||||||
);
|
);
|
||||||
})),
|
})),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2022 WYATT GROUP
|
# Copyright (C) 2023 WYATT GROUP
|
||||||
# Please see the AUTHORS file for details.
|
# Please see the AUTHORS file for details.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@ -14,6 +14,4 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
include: package:wyatt_analysis/analysis_options.flutter.yaml
|
||||||
include: package:wyatt_analysis/analysis_options.flutter.experimental.yaml
|
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ class ExampleCubit extends Cubit<CrudState> {
|
|||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudLoading());
|
emit(CrudLoading());
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudError('Cubit Error'));
|
emit(const CrudError('Cubit Error'));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudLoaded<String>('DATA LOADED'));
|
emit(const CrudLoaded<String>('DATA LOADED'));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudInitial());
|
emit(CrudInitial());
|
||||||
}
|
}
|
||||||
@ -23,14 +23,16 @@ class ExampleCubit extends Cubit<CrudState> {
|
|||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudLoading());
|
emit(CrudLoading());
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudError('Cubit Error'));
|
emit(const CrudError('Cubit Error'));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudListLoaded<String>([
|
emit(
|
||||||
|
const CrudListLoaded<String>([
|
||||||
'DATA LOADED 1',
|
'DATA LOADED 1',
|
||||||
'DATA LOADED 2',
|
'DATA LOADED 2',
|
||||||
'DATA LOADED 3',
|
'DATA LOADED 3',
|
||||||
'DATA LOADED 4'
|
'DATA LOADED 4'
|
||||||
]));
|
]),
|
||||||
|
);
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(CrudInitial());
|
emit(CrudInitial());
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ part 'custom_app_bar.g.dart';
|
|||||||
|
|
||||||
@ComponentCopyWithExtension()
|
@ComponentCopyWithExtension()
|
||||||
class CustomAppBar extends TopAppBarComponent with $CustomAppBarCWMixin {
|
class CustomAppBar extends TopAppBarComponent with $CustomAppBarCWMixin {
|
||||||
const CustomAppBar({super.title});
|
const CustomAppBar({super.key, super.title});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => AppBar(
|
Widget build(BuildContext context) => AppBar(
|
||||||
title: Text(title?.data ?? 'Title'),
|
title: Text(title?.data ?? 'Title'),
|
||||||
|
@ -7,19 +7,23 @@ part 'custom_bottom_bar.g.dart';
|
|||||||
@ComponentCopyWithExtension()
|
@ComponentCopyWithExtension()
|
||||||
class CustomBottomBar extends BottomNavigationBarComponent
|
class CustomBottomBar extends BottomNavigationBarComponent
|
||||||
with $CustomBottomBarCWMixin {
|
with $CustomBottomBarCWMixin {
|
||||||
|
const CustomBottomBar({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => BottomNavigationBar(
|
Widget build(BuildContext context) => BottomNavigationBar(
|
||||||
items: [
|
items: const [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.e_mobiledata,
|
Icons.e_mobiledata,
|
||||||
),
|
),
|
||||||
label: 'Icon 1'),
|
label: 'Icon 1',
|
||||||
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.do_not_disturb_off,
|
Icons.do_not_disturb_off,
|
||||||
),
|
),
|
||||||
label: 'Icon 2'),
|
label: 'Icon 2',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
);
|
);
|
||||||
|
@ -7,7 +7,7 @@ part 'custom_error_widget.g.dart';
|
|||||||
@ComponentCopyWithExtension()
|
@ComponentCopyWithExtension()
|
||||||
class CustomErrorWidget extends ErrorWidgetComponent
|
class CustomErrorWidget extends ErrorWidgetComponent
|
||||||
with $CustomErrorWidgetCWMixin {
|
with $CustomErrorWidgetCWMixin {
|
||||||
CustomErrorWidget({super.error});
|
CustomErrorWidget({super.key, super.error});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => ColoredBox(
|
Widget build(BuildContext context) => ColoredBox(
|
||||||
|
@ -7,7 +7,7 @@ part 'custom_loading_widget.g.dart';
|
|||||||
@ComponentCopyWithExtension()
|
@ComponentCopyWithExtension()
|
||||||
class CustomLoadingWidget extends LoadingWidgetComponent
|
class CustomLoadingWidget extends LoadingWidgetComponent
|
||||||
with $CustomLoadingWidgetCWMixin {
|
with $CustomLoadingWidgetCWMixin {
|
||||||
CustomLoadingWidget({super.color});
|
CustomLoadingWidget({super.key, super.color});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) =>
|
Widget build(BuildContext context) =>
|
||||||
|
@ -6,8 +6,8 @@ import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
|||||||
|
|
||||||
class AppThemeComponent {
|
class AppThemeComponent {
|
||||||
static ComponentThemeData get components => ComponentThemeData.raw(
|
static ComponentThemeData get components => ComponentThemeData.raw(
|
||||||
appBar: CustomAppBar(),
|
appBar: const CustomAppBar(),
|
||||||
bottomNavigationBar: CustomBottomBar(),
|
bottomNavigationBar: const CustomBottomBar(),
|
||||||
loadingWidget: CustomLoadingWidget(),
|
loadingWidget: CustomLoadingWidget(),
|
||||||
errorWidget: CustomErrorWidget(),
|
errorWidget: CustomErrorWidget(),
|
||||||
);
|
);
|
||||||
|
@ -28,8 +28,7 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
// This widget is the root of your application.
|
// This widget is the root of your application.
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => ComponentTheme(
|
||||||
return ComponentTheme(
|
|
||||||
componentThemeWidget: AppThemeComponent.components,
|
componentThemeWidget: AppThemeComponent.components,
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
title: 'Bloc Layout Example',
|
title: 'Bloc Layout Example',
|
||||||
@ -45,13 +44,13 @@ class MyApp extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (_) => ExampleCubit()..run(),
|
create: (_) => ExampleCubit()..run(),
|
||||||
child: ExampleCrudStateManagement(),
|
child: const ExampleCrudStateManagement(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (_) => ExampleCubit()..runList(),
|
create: (_) => ExampleCubit()..runList(),
|
||||||
child: ExampleListCrudStateManagement(),
|
child: const ExampleListCrudStateManagement(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -63,12 +62,14 @@ class MyApp extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (_) => ExampleCubit()..run(),
|
create: (_) => ExampleCubit()..run(),
|
||||||
child: ExampleFrameLayoutCrudConsumer()),
|
child: const ExampleFrameLayoutCrudConsumer(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (_) => ExampleCubit()..runList(),
|
create: (_) => ExampleCubit()..runList(),
|
||||||
child: ExampleFrameLayoutCrudListConsumer()),
|
child: const ExampleFrameLayoutCrudListConsumer(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -78,11 +79,12 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExampleCrudStateManagement
|
class ExampleCrudStateManagement
|
||||||
extends CrudCubitConsumerScreen<ExampleCubit, String> {
|
extends CrudCubitConsumerScreen<ExampleCubit, String> {
|
||||||
|
const ExampleCrudStateManagement({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget initialBuilder(BuildContext context, CrudInitial state) =>
|
Widget initialBuilder(BuildContext context, CrudInitial state) =>
|
||||||
Container(color: Colors.yellow);
|
Container(color: Colors.yellow);
|
||||||
@ -93,6 +95,8 @@ class ExampleCrudStateManagement
|
|||||||
|
|
||||||
class ExampleListCrudStateManagement
|
class ExampleListCrudStateManagement
|
||||||
extends CrudListCubitConsumerScreen<ExampleCubit, String> {
|
extends CrudListCubitConsumerScreen<ExampleCubit, String> {
|
||||||
|
const ExampleListCrudStateManagement({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget initialBuilder(BuildContext context, CrudInitial state) =>
|
Widget initialBuilder(BuildContext context, CrudInitial state) =>
|
||||||
Container(color: Colors.green);
|
Container(color: Colors.green);
|
||||||
@ -106,7 +110,7 @@ class ExampleListCrudStateManagement
|
|||||||
|
|
||||||
class ExampleFrameLayoutCrudConsumer
|
class ExampleFrameLayoutCrudConsumer
|
||||||
extends FrameLayoutCrudCubitConsumerScreen<ExampleCubit, String> {
|
extends FrameLayoutCrudCubitConsumerScreen<ExampleCubit, String> {
|
||||||
const ExampleFrameLayoutCrudConsumer()
|
const ExampleFrameLayoutCrudConsumer({super.key})
|
||||||
: super(
|
: super(
|
||||||
title: 'Example Title',
|
title: 'Example Title',
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
@ -119,7 +123,7 @@ class ExampleFrameLayoutCrudConsumer
|
|||||||
|
|
||||||
class ExampleFrameLayoutCrudListConsumer
|
class ExampleFrameLayoutCrudListConsumer
|
||||||
extends FrameLayoutCrudListCubitConsumerScreen<ExampleCubit, String> {
|
extends FrameLayoutCrudListCubitConsumerScreen<ExampleCubit, String> {
|
||||||
const ExampleFrameLayoutCrudListConsumer()
|
const ExampleFrameLayoutCrudListConsumer({super.key})
|
||||||
: super(
|
: super(
|
||||||
title: 'Example Title',
|
title: 'Example Title',
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
|
@ -20,7 +20,7 @@ import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
|||||||
import 'package:wyatt_crud_bloc/wyatt_crud_bloc.dart';
|
import 'package:wyatt_crud_bloc/wyatt_crud_bloc.dart';
|
||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||||
|
|
||||||
mixin CrudMixin<Cubit extends bloc_base.Cubit,
|
mixin CrudMixin<Cubit extends bloc_base.Cubit<dynamic>,
|
||||||
SuccessState extends CrudSuccess> {
|
SuccessState extends CrudSuccess> {
|
||||||
Widget errorBuilder(BuildContext context, CrudError state) =>
|
Widget errorBuilder(BuildContext context, CrudError state) =>
|
||||||
context.components.errorWidget?.copyWith(error: state.message.wrap()) ??
|
context.components.errorWidget?.copyWith(error: state.message.wrap()) ??
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import 'package:flutter/src/widgets/framework.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
||||||
import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
||||||
|
|
||||||
|
@ -16,5 +16,5 @@
|
|||||||
|
|
||||||
export './app_bar_layout_crud_cubit_consumer_screen.dart';
|
export './app_bar_layout_crud_cubit_consumer_screen.dart';
|
||||||
export './bottom_bar_layout_crud_cubit_consumer_screen.dart';
|
export './bottom_bar_layout_crud_cubit_consumer_screen.dart';
|
||||||
export './frame_layout_crud_cubit_consumer_screen.dart';
|
|
||||||
export './crud_cubit_consumer_screen.dart';
|
export './crud_cubit_consumer_screen.dart';
|
||||||
|
export './frame_layout_crud_cubit_consumer_screen.dart';
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
||||||
|
import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
||||||
|
|
||||||
abstract class CrudCubitConsumerScreen<Cubit extends bloc_base.Cubit<CrudState>,
|
abstract class CrudCubitConsumerScreen<Cubit extends bloc_base.Cubit<CrudState>,
|
||||||
T extends Object?> extends CubitConsumerScreen<Cubit, CrudState>
|
T extends Object?> extends CubitConsumerScreen<Cubit, CrudState>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
export './crud_cubit_screen.dart';
|
||||||
export 'app_bar_layout_crud_cubit_screen.dart';
|
export 'app_bar_layout_crud_cubit_screen.dart';
|
||||||
export 'bottom_bar_layout_crud_cubit_screen.dart';
|
export 'bottom_bar_layout_crud_cubit_screen.dart';
|
||||||
export 'frame_layout_crud_cubit_screen.dart';
|
export 'frame_layout_crud_cubit_screen.dart';
|
||||||
export './crud_cubit_screen.dart';
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base;
|
||||||
|
import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
|
||||||
|
|
||||||
abstract class CrudCubitScreen<Cubit extends bloc_base.Cubit<CrudState>,
|
abstract class CrudCubitScreen<Cubit extends bloc_base.Cubit<CrudState>,
|
||||||
T extends Object?> extends CubitScreen<Cubit, CrudState>
|
T extends Object?> extends CubitScreen<Cubit, CrudState>
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export 'presentation/presentation.dart';
|
|
||||||
export 'core/core.dart';
|
|
||||||
|
|
||||||
export 'package:flutter_bloc/flutter_bloc.dart';
|
export 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
export 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
|
||||||
export 'package:wyatt_crud_bloc/wyatt_crud_bloc.dart';
|
|
||||||
export 'package:wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
|
||||||
export 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
export 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
||||||
|
export 'package:wyatt_crud_bloc/wyatt_crud_bloc.dart';
|
||||||
|
export 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||||
|
export 'package:wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||||
|
|
||||||
|
export 'core/core.dart';
|
||||||
|
export 'presentation/presentation.dart';
|
||||||
|
@ -3,14 +3,17 @@ description: Layouts based on bloc helper library
|
|||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_layout
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_layout
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
|
publish_to: "none"
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.0 <3.0.0'
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
flutter_bloc: ^8.1.2
|
||||||
|
|
||||||
wyatt_bloc_helper:
|
wyatt_bloc_helper:
|
||||||
git:
|
git:
|
||||||
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
|
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
|
||||||
@ -32,11 +35,9 @@ dependencies:
|
|||||||
path: packages/wyatt_ui_components
|
path: packages/wyatt_ui_components
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
|
||||||
wyatt_analysis:
|
wyatt_analysis:
|
||||||
git:
|
git:
|
||||||
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
|
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
|
||||||
|
@ -1,7 +1 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
include: package:wyatt_analysis/analysis_options.yaml
|
include: package:wyatt_analysis/analysis_options.yaml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ description: Generator for copywith method for components.
|
|||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/component_copy_with_gen
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/component_copy_with_gen
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
|
publish_to: "none"
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.19.0 <3.0.0"
|
sdk: ">=2.19.0 <3.0.0"
|
||||||
|
|
||||||
|
@ -92,7 +92,6 @@ class MyHomePage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -121,9 +120,7 @@ class MyHomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<UserCubit>().query([LimitQuery(2)]);
|
||||||
.read<UserCubit>()
|
|
||||||
.query([LimitQuery(2)]);
|
|
||||||
},
|
},
|
||||||
child: const Text("Query"),
|
child: const Text("Query"),
|
||||||
),
|
),
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -24,7 +24,6 @@ import 'package:wyatt_crud_bloc/src/domain/entities/query.dart';
|
|||||||
|
|
||||||
class CrudInMemoryDataSourceImpl<Model extends ObjectModel>
|
class CrudInMemoryDataSourceImpl<Model extends ObjectModel>
|
||||||
extends CrudDataSource<Model> {
|
extends CrudDataSource<Model> {
|
||||||
|
|
||||||
CrudInMemoryDataSourceImpl({required this.toMap, Map<String, Model>? data})
|
CrudInMemoryDataSourceImpl({required this.toMap, Map<String, Model>? data})
|
||||||
: _data = data ?? {};
|
: _data = data ?? {};
|
||||||
final Map<String, Model> _data;
|
final Map<String, Model> _data;
|
||||||
|
@ -22,7 +22,6 @@ import 'package:wyatt_crud_bloc/src/domain/entities/query.dart';
|
|||||||
|
|
||||||
class CrudFirestoreDataSourceImpl<Model extends ObjectModel, Entity>
|
class CrudFirestoreDataSourceImpl<Model extends ObjectModel, Entity>
|
||||||
extends CrudDataSource<Model> {
|
extends CrudDataSource<Model> {
|
||||||
|
|
||||||
CrudFirestoreDataSourceImpl(
|
CrudFirestoreDataSourceImpl(
|
||||||
String collection, {
|
String collection, {
|
||||||
required Model Function(
|
required Model Function(
|
||||||
|
@ -23,7 +23,6 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
|||||||
|
|
||||||
class CrudRepositoryImpl<Model extends ObjectModel>
|
class CrudRepositoryImpl<Model extends ObjectModel>
|
||||||
extends CrudRepository<Model> {
|
extends CrudRepository<Model> {
|
||||||
|
|
||||||
CrudRepositoryImpl({
|
CrudRepositoryImpl({
|
||||||
required CrudDataSource<Model> crudDataSource,
|
required CrudDataSource<Model> crudDataSource,
|
||||||
}) : _crudDataSource = crudDataSource;
|
}) : _crudDataSource = crudDataSource;
|
||||||
|
@ -25,7 +25,6 @@ abstract class QueryParser<Q> {
|
|||||||
abstract class QueryInterface extends Entity {}
|
abstract class QueryInterface extends Entity {}
|
||||||
|
|
||||||
class WhereQuery<Value> extends QueryInterface {
|
class WhereQuery<Value> extends QueryInterface {
|
||||||
|
|
||||||
WhereQuery(this.type, this.field, this.value);
|
WhereQuery(this.type, this.field, this.value);
|
||||||
final WhereQueryType type;
|
final WhereQueryType type;
|
||||||
final String field;
|
final String field;
|
||||||
@ -33,13 +32,11 @@ class WhereQuery<Value> extends QueryInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LimitQuery extends QueryInterface {
|
class LimitQuery extends QueryInterface {
|
||||||
|
|
||||||
LimitQuery(this.limit);
|
LimitQuery(this.limit);
|
||||||
final int limit;
|
final int limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OrderByQuery extends QueryInterface {
|
class OrderByQuery extends QueryInterface {
|
||||||
|
|
||||||
OrderByQuery(this.field, {this.ascending = true});
|
OrderByQuery(this.field, {this.ascending = true});
|
||||||
final String field;
|
final String field;
|
||||||
final bool ascending;
|
final bool ascending;
|
||||||
|
@ -21,7 +21,6 @@ import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
|
|||||||
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
||||||
|
|
||||||
class Delete<Model extends ObjectModel> extends AsyncUseCase<String, void> {
|
class Delete<Model extends ObjectModel> extends AsyncUseCase<String, void> {
|
||||||
|
|
||||||
Delete(this._crudRepository);
|
Delete(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
|
|||||||
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
||||||
|
|
||||||
class DeleteAll<Model extends ObjectModel> extends AsyncUseCase<void, void> {
|
class DeleteAll<Model extends ObjectModel> extends AsyncUseCase<void, void> {
|
||||||
|
|
||||||
DeleteAll(this._crudRepository);
|
DeleteAll(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
|
|||||||
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
||||||
|
|
||||||
class Get<Model extends ObjectModel> extends AsyncUseCase<String, Model?> {
|
class Get<Model extends ObjectModel> extends AsyncUseCase<String, Model?> {
|
||||||
|
|
||||||
Get(this._crudRepository);
|
Get(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
|||||||
|
|
||||||
class GetAll<Model extends ObjectModel>
|
class GetAll<Model extends ObjectModel>
|
||||||
extends AsyncUseCase<void, List<Model?>> {
|
extends AsyncUseCase<void, List<Model?>> {
|
||||||
|
|
||||||
GetAll(this._crudRepository);
|
GetAll(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
|||||||
|
|
||||||
class Query<Model extends ObjectModel>
|
class Query<Model extends ObjectModel>
|
||||||
extends AsyncUseCase<List<QueryInterface>, List<Model?>> {
|
extends AsyncUseCase<List<QueryInterface>, List<Model?>> {
|
||||||
|
|
||||||
Query(this._crudRepository);
|
Query(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -14,9 +14,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// class Stream<Model extends ObjectModel> extends UseCase<StreamParameters,
|
||||||
|
//List<Model?>> {
|
||||||
// class Stream<Model extends ObjectModel> extends UseCase<StreamParameters, List<Model?>> {
|
|
||||||
// final CrudRepository<Model> _crudRepository;
|
// final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
// Stream(this._crudRepository);
|
// Stream(this._crudRepository);
|
||||||
@ -40,5 +39,6 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// @override
|
// @override
|
||||||
// FutureOrResult<Stream<List<Model?>>> call(StreamParameters? params) => _crudRepository.stream();
|
// FutureOrResult<Stream<List<Model?>>> call(StreamParameters? params) =>
|
||||||
|
// _crudRepository.stream();
|
||||||
// }
|
// }
|
||||||
|
@ -23,7 +23,6 @@ import 'package:wyatt_crud_bloc/src/domain/usecases/params/update_parameters.dar
|
|||||||
|
|
||||||
class Update<Model extends ObjectModel>
|
class Update<Model extends ObjectModel>
|
||||||
extends AsyncUseCase<UpdateParameters<Model>, void> {
|
extends AsyncUseCase<UpdateParameters<Model>, void> {
|
||||||
|
|
||||||
Update(this._crudRepository);
|
Update(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
|
|||||||
|
|
||||||
class UpdateAll<Model extends ObjectModel>
|
class UpdateAll<Model extends ObjectModel>
|
||||||
extends AsyncUseCase<Map<String, Object?>, void> {
|
extends AsyncUseCase<Map<String, Object?>, void> {
|
||||||
|
|
||||||
UpdateAll(this._crudRepository);
|
UpdateAll(this._crudRepository);
|
||||||
final CrudRepository<Model> _crudRepository;
|
final CrudRepository<Model> _crudRepository;
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import 'package:wyatt_crud_bloc/src/domain/usecases/update_all.dart';
|
|||||||
part 'crud_state.dart';
|
part 'crud_state.dart';
|
||||||
|
|
||||||
abstract class CrudCubit<Model extends ObjectModel> extends Cubit<CrudState> {
|
abstract class CrudCubit<Model extends ObjectModel> extends Cubit<CrudState> {
|
||||||
|
|
||||||
CrudCubit() : super(CrudInitial());
|
CrudCubit() : super(CrudInitial());
|
||||||
Create<Model>? get crudCreate;
|
Create<Model>? get crudCreate;
|
||||||
DeleteAll<Model>? get crudDeleteAll;
|
DeleteAll<Model>? get crudDeleteAll;
|
||||||
|
@ -36,7 +36,6 @@ class CrudOkReturn extends CrudState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CrudError extends CrudState {
|
class CrudError extends CrudState {
|
||||||
|
|
||||||
const CrudError(this.message);
|
const CrudError(this.message);
|
||||||
final String? message;
|
final String? message;
|
||||||
|
|
||||||
@ -45,7 +44,6 @@ class CrudError extends CrudState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CrudLoaded<T> extends CrudSuccess {
|
class CrudLoaded<T> extends CrudSuccess {
|
||||||
|
|
||||||
const CrudLoaded(this.data);
|
const CrudLoaded(this.data);
|
||||||
final T? data;
|
final T? data;
|
||||||
|
|
||||||
@ -54,7 +52,6 @@ class CrudLoaded<T> extends CrudSuccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CrudListLoaded<T> extends CrudSuccess {
|
class CrudListLoaded<T> extends CrudSuccess {
|
||||||
|
|
||||||
const CrudListLoaded(this.data);
|
const CrudListLoaded(this.data);
|
||||||
final List<T?> data;
|
final List<T?> data;
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@ class App extends StatelessWidget {
|
|||||||
FormInput(formFieldEmail, const Email.pure(),
|
FormInput(formFieldEmail, const Email.pure(),
|
||||||
metadata: const FormInputMetadata<Metadata>(extra: blue)),
|
metadata: const FormInputMetadata<Metadata>(extra: blue)),
|
||||||
FormInput(
|
FormInput(
|
||||||
formFieldList, const ListOption<String>.pure(choices: ['c1', 'c2', 'c3'],defaultValue: 'c3')),
|
formFieldList,
|
||||||
|
const ListOption<String>.pure(
|
||||||
|
choices: ['c1', 'c2', 'c3'], defaultValue: 'c3')),
|
||||||
FormInput(formFieldRadio, const TextString.pure()),
|
FormInput(formFieldRadio, const TextString.pure()),
|
||||||
FormInput(formFieldPro, const Boolean.pure(),
|
FormInput(formFieldPro, const Boolean.pure(),
|
||||||
metadata: const FormInputMetadata<Metadata>(name: 'business')),
|
metadata: const FormInputMetadata<Metadata>(name: 'business')),
|
||||||
|
@ -15,10 +15,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
enum Category {
|
enum Category { perso, business }
|
||||||
perso,
|
|
||||||
business
|
|
||||||
}
|
|
||||||
|
|
||||||
class Metadata {
|
class Metadata {
|
||||||
final Category category;
|
final Category category;
|
||||||
|
@ -38,8 +38,7 @@ class _NameInput extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InputBuilderTextController<SimpleCustomFormCubit, String?, Metadata>(
|
return InputBuilderTextController<SimpleCustomFormCubit, String?, Metadata>(
|
||||||
field: formFieldName,
|
field: formFieldName,
|
||||||
builder:
|
builder: (context, cubit, state, field, input, controller, metadata) {
|
||||||
(context, cubit, state, field, input, controller, metadata) {
|
|
||||||
final meta = state.form.metadataOf<Metadata>(field).extra;
|
final meta = state.form.metadataOf<Metadata>(field).extra;
|
||||||
final color = computeColor(meta);
|
final color = computeColor(meta);
|
||||||
return Row(
|
return Row(
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -33,7 +33,7 @@ enum SetOperation {
|
|||||||
/// Add new elements to set.
|
/// Add new elements to set.
|
||||||
union(FormUnion());
|
union(FormUnion());
|
||||||
|
|
||||||
final FormOperation operation;
|
|
||||||
|
|
||||||
const SetOperation(this.operation);
|
const SetOperation(this.operation);
|
||||||
|
|
||||||
|
final FormOperation operation;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import 'package:wyatt_form_bloc/src/domain/input_validators/form_input_validator
|
|||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class WyattFormImpl extends WyattForm {
|
class WyattFormImpl extends WyattForm {
|
||||||
|
|
||||||
WyattFormImpl(
|
WyattFormImpl(
|
||||||
this._inputs, {
|
this._inputs, {
|
||||||
required String name,
|
required String name,
|
||||||
|
@ -22,8 +22,7 @@ import 'package:wyatt_form_bloc/src/domain/input_validators/form_input_validator
|
|||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
class Boolean extends NullableValidator<bool, ValidationStandardError> {
|
class Boolean extends NullableValidator<bool, ValidationStandardError> {
|
||||||
/// {@macro boolean}
|
/// {@macro boolean}
|
||||||
const Boolean.pure({bool defaultValue = false})
|
const Boolean.pure({bool defaultValue = false}) : super.pure(defaultValue);
|
||||||
: super.pure(defaultValue);
|
|
||||||
|
|
||||||
/// {@macro boolean}
|
/// {@macro boolean}
|
||||||
const Boolean.dirty({bool? value}) : super.dirty(value);
|
const Boolean.dirty({bool? value}) : super.dirty(value);
|
||||||
@ -34,5 +33,4 @@ class Boolean extends NullableValidator<bool, ValidationStandardError> {
|
|||||||
@override
|
@override
|
||||||
ValidationStandardError? validator(bool? value) =>
|
ValidationStandardError? validator(bool? value) =>
|
||||||
value != null ? null : onNull;
|
value != null ? null : onNull;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ class EnumOption<T> extends AnyValidator<T, List<T>, ValidationError> {
|
|||||||
const EnumOption.pure({this.enums = const [], T? defaultValue})
|
const EnumOption.pure({this.enums = const [], T? defaultValue})
|
||||||
: super.pure(defaultValue);
|
: super.pure(defaultValue);
|
||||||
|
|
||||||
const EnumOption.dirty({required this.enums, T? value})
|
const EnumOption.dirty({required this.enums, T? value}) : super.dirty(value);
|
||||||
: super.dirty(value);
|
|
||||||
|
|
||||||
final List<T> enums;
|
final List<T> enums;
|
||||||
|
|
||||||
|
@ -61,6 +61,5 @@ class FormInput<
|
|||||||
List<Object?> get props => [key, validator, metadata];
|
List<Object?> get props => [key, validator, metadata];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() =>
|
String toString() => 'FormInput(name: $name, $validator)';
|
||||||
'FormInput(name: $name, $validator)';
|
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
part of 'form_data_cubit.dart';
|
part of 'form_data_cubit.dart';
|
||||||
|
|
||||||
abstract class FormDataState extends Equatable {
|
abstract class FormDataState extends Equatable {
|
||||||
|
|
||||||
const FormDataState({
|
const FormDataState({
|
||||||
required this.form,
|
required this.form,
|
||||||
this.status = FormStatus.pure,
|
this.status = FormStatus.pure,
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Global status of a form.
|
/// Global status of a form.
|
||||||
final FormStatus status;
|
final FormStatus status;
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import 'package:wyatt_form_bloc/src/presentation/features/form_data/form_data_cu
|
|||||||
part 'form_data_state_impl.dart';
|
part 'form_data_state_impl.dart';
|
||||||
|
|
||||||
abstract class FormDataCubitImpl extends FormDataCubit<FormDataStateImpl> {
|
abstract class FormDataCubitImpl extends FormDataCubit<FormDataStateImpl> {
|
||||||
|
|
||||||
FormDataCubitImpl(this._formRepository, this._formName)
|
FormDataCubitImpl(this._formRepository, this._formName)
|
||||||
: super(FormDataStateImpl(form: _formRepository.accessForm(_formName)));
|
: super(FormDataStateImpl(form: _formRepository.accessForm(_formName)));
|
||||||
final FormRepository _formRepository;
|
final FormRepository _formRepository;
|
||||||
|
@ -37,7 +37,8 @@ enum EmailVerificationAction {
|
|||||||
onNonMatch: (n) => n,
|
onNonMatch: (n) => n,
|
||||||
);
|
);
|
||||||
|
|
||||||
factory EmailVerificationAction.fromString(String str) => EmailVerificationAction.values.firstWhere(
|
factory EmailVerificationAction.fromString(String str) =>
|
||||||
|
EmailVerificationAction.values.firstWhere(
|
||||||
(element) => element.toSnakeCase() == str,
|
(element) => element.toSnakeCase() == str,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -56,7 +57,8 @@ class VerifyCode {
|
|||||||
String? email,
|
String? email,
|
||||||
String? verificationCode,
|
String? verificationCode,
|
||||||
EmailVerificationAction? action,
|
EmailVerificationAction? action,
|
||||||
}) => VerifyCode(
|
}) =>
|
||||||
|
VerifyCode(
|
||||||
email: email ?? this.email,
|
email: email ?? this.email,
|
||||||
verificationCode: verificationCode ?? this.verificationCode,
|
verificationCode: verificationCode ?? this.verificationCode,
|
||||||
action: action ?? this.action,
|
action: action ?? this.action,
|
||||||
@ -95,7 +97,8 @@ class Account {
|
|||||||
Account copyWith({
|
Account copyWith({
|
||||||
String? email,
|
String? email,
|
||||||
String? sessionId,
|
String? sessionId,
|
||||||
}) => Account(
|
}) =>
|
||||||
|
Account(
|
||||||
email: email ?? this.email,
|
email: email ?? this.email,
|
||||||
sessionId: sessionId ?? this.sessionId,
|
sessionId: sessionId ?? this.sessionId,
|
||||||
);
|
);
|
||||||
@ -107,7 +110,8 @@ class Account {
|
|||||||
|
|
||||||
factory Account.fromMap(Map<String, dynamic> map) => Account(
|
factory Account.fromMap(Map<String, dynamic> map) => Account(
|
||||||
email: map['email'] as String,
|
email: map['email'] as String,
|
||||||
sessionId: map['session_id'] != null ? map['session_id'] as String : null,
|
sessionId:
|
||||||
|
map['session_id'] != null ? map['session_id'] as String : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
String toJson() => json.encode(toMap());
|
String toJson() => json.encode(toMap());
|
||||||
@ -130,7 +134,8 @@ class SignUp {
|
|||||||
SignUp copyWith({
|
SignUp copyWith({
|
||||||
String? sessionId,
|
String? sessionId,
|
||||||
String? password,
|
String? password,
|
||||||
}) => SignUp(
|
}) =>
|
||||||
|
SignUp(
|
||||||
sessionId: sessionId ?? this.sessionId,
|
sessionId: sessionId ?? this.sessionId,
|
||||||
password: password ?? this.password,
|
password: password ?? this.password,
|
||||||
);
|
);
|
||||||
@ -168,7 +173,8 @@ class TokenSuccess {
|
|||||||
String? accessToken,
|
String? accessToken,
|
||||||
String? refreshToken,
|
String? refreshToken,
|
||||||
Account? account,
|
Account? account,
|
||||||
}) => TokenSuccess(
|
}) =>
|
||||||
|
TokenSuccess(
|
||||||
accessToken: accessToken ?? this.accessToken,
|
accessToken: accessToken ?? this.accessToken,
|
||||||
refreshToken: refreshToken ?? this.refreshToken,
|
refreshToken: refreshToken ?? this.refreshToken,
|
||||||
account: account ?? this.account,
|
account: account ?? this.account,
|
||||||
@ -207,7 +213,8 @@ class Login {
|
|||||||
Login copyWith({
|
Login copyWith({
|
||||||
String? email,
|
String? email,
|
||||||
String? password,
|
String? password,
|
||||||
}) => Login(
|
}) =>
|
||||||
|
Login(
|
||||||
email: email ?? this.email,
|
email: email ?? this.email,
|
||||||
password: password ?? this.password,
|
password: password ?? this.password,
|
||||||
);
|
);
|
||||||
|
@ -25,7 +25,6 @@ import 'package:wyatt_http_client/src/pipeline.dart';
|
|||||||
import 'package:wyatt_http_client/src/utils/http_methods.dart';
|
import 'package:wyatt_http_client/src/utils/http_methods.dart';
|
||||||
|
|
||||||
class MiddlewareClient extends BaseClient {
|
class MiddlewareClient extends BaseClient {
|
||||||
|
|
||||||
MiddlewareClient({
|
MiddlewareClient({
|
||||||
Pipeline? pipeline,
|
Pipeline? pipeline,
|
||||||
Client? inner,
|
Client? inner,
|
||||||
|
@ -13,4 +13,3 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import 'package:wyatt_http_client/src/utils/authentication_methods.dart';
|
|||||||
import 'package:wyatt_http_client/src/utils/header_keys.dart';
|
import 'package:wyatt_http_client/src/utils/header_keys.dart';
|
||||||
|
|
||||||
class BasicAuthMiddleware with OnRequestMiddleware implements Middleware {
|
class BasicAuthMiddleware with OnRequestMiddleware implements Middleware {
|
||||||
|
|
||||||
BasicAuthMiddleware({
|
BasicAuthMiddleware({
|
||||||
this.username,
|
this.username,
|
||||||
this.password,
|
this.password,
|
||||||
|
@ -25,7 +25,6 @@ import 'package:wyatt_http_client/src/utils/http_status.dart';
|
|||||||
class DigestAuthMiddleware
|
class DigestAuthMiddleware
|
||||||
with OnRequestMiddleware, OnResponseMiddleware
|
with OnRequestMiddleware, OnResponseMiddleware
|
||||||
implements Middleware {
|
implements Middleware {
|
||||||
|
|
||||||
DigestAuthMiddleware({
|
DigestAuthMiddleware({
|
||||||
required this.username,
|
required this.username,
|
||||||
required this.password,
|
required this.password,
|
||||||
|
@ -31,7 +31,6 @@ typedef TokenParser = String Function(Map<String, dynamic>);
|
|||||||
class RefreshTokenAuthMiddleware
|
class RefreshTokenAuthMiddleware
|
||||||
with OnRequestMiddleware, OnResponseMiddleware
|
with OnRequestMiddleware, OnResponseMiddleware
|
||||||
implements Middleware {
|
implements Middleware {
|
||||||
|
|
||||||
RefreshTokenAuthMiddleware({
|
RefreshTokenAuthMiddleware({
|
||||||
required this.authorizationEndpoint,
|
required this.authorizationEndpoint,
|
||||||
required this.tokenEndpoint,
|
required this.tokenEndpoint,
|
||||||
|
@ -20,7 +20,6 @@ import 'package:wyatt_http_client/src/models/middleware_request.dart';
|
|||||||
import 'package:wyatt_http_client/src/utils/convert.dart';
|
import 'package:wyatt_http_client/src/utils/convert.dart';
|
||||||
|
|
||||||
class UnsafeAuthMiddleware with OnRequestMiddleware implements Middleware {
|
class UnsafeAuthMiddleware with OnRequestMiddleware implements Middleware {
|
||||||
|
|
||||||
UnsafeAuthMiddleware({
|
UnsafeAuthMiddleware({
|
||||||
this.username,
|
this.username,
|
||||||
this.password,
|
this.password,
|
||||||
|
@ -20,7 +20,6 @@ import 'package:wyatt_http_client/src/models/middleware_request.dart';
|
|||||||
import 'package:wyatt_http_client/src/utils/protocols.dart';
|
import 'package:wyatt_http_client/src/utils/protocols.dart';
|
||||||
|
|
||||||
class UriPrefixMiddleware with OnRequestMiddleware implements Middleware {
|
class UriPrefixMiddleware with OnRequestMiddleware implements Middleware {
|
||||||
|
|
||||||
UriPrefixMiddleware({
|
UriPrefixMiddleware({
|
||||||
required this.protocol,
|
required this.protocol,
|
||||||
required this.authority,
|
required this.authority,
|
||||||
|
@ -44,7 +44,8 @@ class MiddlewareContext {
|
|||||||
MiddlewareRequest? lastRequest,
|
MiddlewareRequest? lastRequest,
|
||||||
MiddlewareResponse? originalResponse,
|
MiddlewareResponse? originalResponse,
|
||||||
MiddlewareResponse? lastResponse,
|
MiddlewareResponse? lastResponse,
|
||||||
}) => MiddlewareContext(
|
}) =>
|
||||||
|
MiddlewareContext(
|
||||||
pipeline: pipeline ?? this.pipeline,
|
pipeline: pipeline ?? this.pipeline,
|
||||||
client: client ?? this.client,
|
client: client ?? this.client,
|
||||||
originalRequest: originalRequest ?? this.originalRequest,
|
originalRequest: originalRequest ?? this.originalRequest,
|
||||||
@ -54,5 +55,8 @@ class MiddlewareContext {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'MiddlewareContext(pipeline: $pipeline, client: $client, originalRequest: $originalRequest, lastRequest: $lastRequest, originalResponse: $originalResponse, lastResponse: $lastResponse)';
|
String toString() =>
|
||||||
|
'MiddlewareContext(pipeline: $pipeline, client: $client, '
|
||||||
|
'originalRequest: $originalRequest, lastRequest: $lastRequest, '
|
||||||
|
'originalResponse: $originalResponse, lastResponse: $lastResponse)';
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ class MiddlewareResponse {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int? get contentLength => httpResponse.contentLength;
|
int? get contentLength => httpResponse.contentLength;
|
||||||
Map<String, String> get headers => httpResponse.headers;
|
Map<String, String> get headers => httpResponse.headers;
|
||||||
|
|
||||||
@ -40,11 +41,11 @@ class MiddlewareResponse {
|
|||||||
|
|
||||||
MiddlewareResponse copyWith({
|
MiddlewareResponse copyWith({
|
||||||
BaseResponse? httpResponse,
|
BaseResponse? httpResponse,
|
||||||
}) => MiddlewareResponse(
|
}) =>
|
||||||
|
MiddlewareResponse(
|
||||||
httpResponse: httpResponse ?? this.httpResponse,
|
httpResponse: httpResponse ?? this.httpResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() =>
|
String toString() => 'MiddlewareResponse(httpResponse: $httpResponse)';
|
||||||
'MiddlewareResponse(httpResponse: $httpResponse)';
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class UnfreezedRequest {
|
class UnfreezedRequest {
|
||||||
|
|
||||||
UnfreezedRequest({
|
UnfreezedRequest({
|
||||||
required this.method,
|
required this.method,
|
||||||
required this.url,
|
required this.url,
|
||||||
@ -37,7 +36,8 @@ class UnfreezedRequest {
|
|||||||
Map<String, String>? headers,
|
Map<String, String>? headers,
|
||||||
Object? body,
|
Object? body,
|
||||||
Encoding? encoding,
|
Encoding? encoding,
|
||||||
}) => UnfreezedRequest(
|
}) =>
|
||||||
|
UnfreezedRequest(
|
||||||
method: method ?? this.method,
|
method: method ?? this.method,
|
||||||
url: url ?? this.url,
|
url: url ?? this.url,
|
||||||
headers: headers ?? this.headers,
|
headers: headers ?? this.headers,
|
||||||
|
@ -20,7 +20,6 @@ import 'package:wyatt_http_client/src/models/middleware_request.dart';
|
|||||||
import 'package:wyatt_http_client/src/models/middleware_response.dart';
|
import 'package:wyatt_http_client/src/models/middleware_response.dart';
|
||||||
|
|
||||||
class Pipeline {
|
class Pipeline {
|
||||||
|
|
||||||
Pipeline() : _middlewares = <Middleware>[];
|
Pipeline() : _middlewares = <Middleware>[];
|
||||||
Pipeline.fromIterable(Iterable<Middleware> middlewares)
|
Pipeline.fromIterable(Iterable<Middleware> middlewares)
|
||||||
: _middlewares = middlewares.toList();
|
: _middlewares = middlewares.toList();
|
||||||
@ -65,8 +64,7 @@ class Pipeline {
|
|||||||
MiddlewareContext ctx = context.copyWith(lastRequest: req);
|
MiddlewareContext ctx = context.copyWith(lastRequest: req);
|
||||||
for (final middleware in _middlewares) {
|
for (final middleware in _middlewares) {
|
||||||
if (middleware is OnRequestMiddleware) {
|
if (middleware is OnRequestMiddleware) {
|
||||||
req = await (middleware as OnRequestMiddleware)
|
req = await (middleware as OnRequestMiddleware).onRequest(ctx, request);
|
||||||
.onRequest(ctx, request);
|
|
||||||
ctx = context.copyWith(lastRequest: req);
|
ctx = context.copyWith(lastRequest: req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,12 @@ class Convert {
|
|||||||
|
|
||||||
static String mapToQuery(Map<String, String> map, {Encoding? encoding}) {
|
static String mapToQuery(Map<String, String> map, {Encoding? encoding}) {
|
||||||
final pairs = <List<String>>[];
|
final pairs = <List<String>>[];
|
||||||
map.forEach((key, value) => pairs.add([
|
map.forEach(
|
||||||
|
(key, value) => pairs.add([
|
||||||
Uri.encodeQueryComponent(key, encoding: encoding ?? utf8),
|
Uri.encodeQueryComponent(key, encoding: encoding ?? utf8),
|
||||||
Uri.encodeQueryComponent(value, encoding: encoding ?? utf8)
|
Uri.encodeQueryComponent(value, encoding: encoding ?? utf8)
|
||||||
]),);
|
]),
|
||||||
|
);
|
||||||
return pairs.map((pair) => '${pair[0]}=${pair[1]}').join('&');
|
return pairs.map((pair) => '${pair[0]}=${pair[1]}').join('&');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ import 'dart:math';
|
|||||||
import 'package:wyatt_http_client/src/utils/convert.dart';
|
import 'package:wyatt_http_client/src/utils/convert.dart';
|
||||||
import 'package:wyatt_http_client/src/utils/crypto.dart';
|
import 'package:wyatt_http_client/src/utils/crypto.dart';
|
||||||
|
|
||||||
class DigestAuth { // request counter
|
class DigestAuth {
|
||||||
|
// request counter
|
||||||
|
|
||||||
DigestAuth(this.username, this.password);
|
DigestAuth(this.username, this.password);
|
||||||
String username;
|
String username;
|
||||||
|
@ -22,7 +22,7 @@ enum HttpMethods {
|
|||||||
patch('PATCH'),
|
patch('PATCH'),
|
||||||
delete('DELETE');
|
delete('DELETE');
|
||||||
|
|
||||||
final String method;
|
|
||||||
|
|
||||||
const HttpMethods(this.method);
|
const HttpMethods(this.method);
|
||||||
|
|
||||||
|
final String method;
|
||||||
}
|
}
|
||||||
|
@ -81,10 +81,13 @@ enum HttpStatus {
|
|||||||
// Client generated status code.
|
// Client generated status code.
|
||||||
networkConnectTimeoutError(599);
|
networkConnectTimeoutError(599);
|
||||||
|
|
||||||
final int statusCode;
|
|
||||||
|
|
||||||
const HttpStatus(this.statusCode);
|
const HttpStatus(this.statusCode);
|
||||||
|
|
||||||
|
factory HttpStatus.from(int status) =>
|
||||||
|
HttpStatus.values.firstWhere((element) => element.statusCode == status);
|
||||||
|
|
||||||
|
final int statusCode;
|
||||||
|
|
||||||
bool equals(Object other) {
|
bool equals(Object other) {
|
||||||
if (other is HttpStatus) {
|
if (other is HttpStatus) {
|
||||||
return statusCode == other.statusCode;
|
return statusCode == other.statusCode;
|
||||||
@ -104,8 +107,4 @@ enum HttpStatus {
|
|||||||
bool isClientError() => statusCode >= 400 && statusCode < 500;
|
bool isClientError() => statusCode >= 400 && statusCode < 500;
|
||||||
|
|
||||||
bool isServerError() => statusCode >= 500 && statusCode < 600;
|
bool isServerError() => statusCode >= 500 && statusCode < 600;
|
||||||
|
|
||||||
factory HttpStatus.from(int status) => HttpStatus.values
|
|
||||||
.firstWhere((element) => element.statusCode == status);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'$_counter',
|
'$_counter',
|
||||||
style: Theme.of(context).textTheme.headline4,
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// TODO: Put public facing types in this file.
|
|
||||||
|
|
||||||
/// Checks if you are awesome. Spoiler: you are.
|
/// Checks if you are awesome. Spoiler: you are.
|
||||||
class Awesome {
|
class Awesome {
|
||||||
bool get isAwesome => true;
|
bool get isAwesome => true;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class AppError {
|
class AppError {
|
||||||
|
|
||||||
const AppError(this.message);
|
const AppError(this.message);
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
|
@ -172,7 +172,6 @@ abstract class Option<T> extends _EitherBase<T, void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Value<T> extends Option<T> with _Left<T, void> {
|
class Value<T> extends Option<T> with _Left<T, void> {
|
||||||
|
|
||||||
/// {@macro ok}
|
/// {@macro ok}
|
||||||
const Value(this.value) : super._();
|
const Value(this.value) : super._();
|
||||||
final T value;
|
final T value;
|
||||||
|
@ -203,7 +203,6 @@ abstract class Result<T, E> extends _EitherBase<T, E> {
|
|||||||
/// {@macro result}
|
/// {@macro result}
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
class Ok<T, E> extends Result<T, E> with _Left<T, E> {
|
class Ok<T, E> extends Result<T, E> with _Left<T, E> {
|
||||||
|
|
||||||
/// {@macro ok}
|
/// {@macro ok}
|
||||||
const Ok(this.value) : super._();
|
const Ok(this.value) : super._();
|
||||||
final T value;
|
final T value;
|
||||||
@ -268,7 +267,6 @@ class Ok<T, E> extends Result<T, E> with _Left<T, E> {
|
|||||||
/// {@macro result}
|
/// {@macro result}
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
class Err<T, E> extends Result<T, E> with _Right<T, E> {
|
class Err<T, E> extends Result<T, E> with _Right<T, E> {
|
||||||
|
|
||||||
/// {@macro err}
|
/// {@macro err}
|
||||||
const Err(this.error) : super._();
|
const Err(this.error) : super._();
|
||||||
final E error;
|
final E error;
|
||||||
|
@ -32,7 +32,7 @@ extension IterableIntExtension on Iterable<int>? {
|
|||||||
Uint8List toTypedList() => Uint8List.fromList(this?.toList() ?? []);
|
Uint8List toTypedList() => Uint8List.fromList(this?.toList() ?? []);
|
||||||
|
|
||||||
/// Converts a [Uint8List] to a [String] using the specified [Encoding].
|
/// Converts a [Uint8List] to a [String] using the specified [Encoding].
|
||||||
String toStr({final Encoding to = Encoding.utf16}) {
|
String toStr({Encoding to = Encoding.utf16}) {
|
||||||
String str;
|
String str;
|
||||||
switch (to) {
|
switch (to) {
|
||||||
case Encoding.utf8:
|
case Encoding.utf8:
|
||||||
|
@ -28,7 +28,7 @@ extension StringExtension on String? {
|
|||||||
bool get isNotNullOrEmpty => this != null && this!.isNotEmpty;
|
bool get isNotNullOrEmpty => this != null && this!.isNotEmpty;
|
||||||
|
|
||||||
/// Converts a [String] to a [Uint8List] using the specified [Encoding].
|
/// Converts a [String] to a [Uint8List] using the specified [Encoding].
|
||||||
Uint8List toBytes({final Encoding from = Encoding.utf16}) {
|
Uint8List toBytes({Encoding from = Encoding.utf16}) {
|
||||||
Uint8List bytes;
|
Uint8List bytes;
|
||||||
switch (from) {
|
switch (from) {
|
||||||
case Encoding.utf8:
|
case Encoding.utf8:
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user