Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update form_bloc_listener.dart #340

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions form_bloc_web/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions form_bloc_web/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions form_bloc_web/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
1 change: 1 addition & 0 deletions form_bloc_web/macos/Flutter/Flutter-Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
1 change: 1 addition & 0 deletions form_bloc_web/macos/Flutter/Flutter-Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
43 changes: 43 additions & 0 deletions form_bloc_web/macos/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
platform :osx, '10.14'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_macos_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
4 changes: 2 additions & 2 deletions form_bloc_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ dependencies:
auto_size_text: ^3.0.0-nullsafety.0
liquid_progress_indicator_v2: ^0.5.0
rxdart: ^0.27.7
google_fonts: ^5.1.0
google_fonts: ^6.1.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter_lints: ^3.0.1

flutter:
uses-material-design: true
Expand Down
3 changes: 2 additions & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: form_bloc_melos

packages:
- form_bloc_web
- packages/**
- packages/flutter_form_bloc
- packages/form_bloc

scripts:
analyze:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions packages/flutter_form_bloc/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
30 changes: 12 additions & 18 deletions packages/flutter_form_bloc/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ class AllFieldsForm extends StatelessWidget {
onSuccess: (context, state) {
LoadingDialog.hide(context);

Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const SuccessScreen()));
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (_) => const SuccessScreen()));
},
onFailure: (context, state) {
LoadingDialog.hide(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.failureResponse!)));
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(state.failureResponse!)));
},
child: ScrollableFormBlocManager(
formBloc: formBloc,
Expand Down Expand Up @@ -251,13 +251,11 @@ class AllFieldsForm extends StatelessWidget {
Row(
children: [
IconButton(
onPressed: () => formBloc.addFieldBloc(
fieldBloc: formBloc.select1),
onPressed: () => formBloc.addFieldBloc(fieldBloc: formBloc.select1),
icon: const Icon(Icons.add),
),
IconButton(
onPressed: () => formBloc.removeFieldBloc(
fieldBloc: formBloc.select1),
onPressed: () => formBloc.removeFieldBloc(fieldBloc: formBloc.select1),
icon: const Icon(Icons.delete),
),
],
Expand All @@ -269,28 +267,24 @@ class AllFieldsForm extends StatelessWidget {
CheckboxFieldBlocBuilder(
booleanFieldBloc: formBloc.boolean1,
body: const Text('CheckboxFieldBlocBuilder trailing'),
controlAffinity:
FieldBlocBuilderControlAffinity.trailing,
controlAffinity: FieldBlocBuilderControlAffinity.trailing,
),
SliderFieldBlocBuilder(
inputFieldBloc: formBloc.double1,
divisions: 10,
labelBuilder: (context, value) =>
value.toStringAsFixed(2),
labelBuilder: (context, value) => value.toStringAsFixed(2),
),
SliderFieldBlocBuilder(
inputFieldBloc: formBloc.double1,
divisions: 10,
labelBuilder: (context, value) =>
value.toStringAsFixed(2),
labelBuilder: (context, value) => value.toStringAsFixed(2),
activeColor: Colors.red,
inactiveColor: Colors.green,
),
SliderFieldBlocBuilder(
inputFieldBloc: formBloc.double1,
divisions: 10,
labelBuilder: (context, value) =>
value.toStringAsFixed(2),
labelBuilder: (context, value) => value.toStringAsFixed(2),
),
ChoiceChipFieldBlocBuilder<String>(
selectFieldBloc: formBloc.select2,
Expand Down Expand Up @@ -371,8 +365,8 @@ class SuccessScreen extends StatelessWidget {
),
const SizedBox(height: 10),
ElevatedButton.icon(
onPressed: () => Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const AllFieldsForm())),
onPressed: () => Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (_) => const AllFieldsForm())),
icon: const Icon(Icons.replay),
label: const Text('AGAIN'),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
43 changes: 43 additions & 0 deletions packages/flutter_form_bloc/example/macos/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
platform :osx, '10.14'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_macos_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
16 changes: 8 additions & 8 deletions packages/flutter_form_bloc/lib/src/form_bloc_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:form_bloc/form_bloc.dart' as form_bloc;

typedef FormBlocListenerCallback<
FormBlocState extends form_bloc
.FormBlocState<SuccessResponse, ErrorResponse>,
FormBlocState2 extends form_bloc
.FormBlocState<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>
= void Function(BuildContext context, FormBlocState state);
= void Function(BuildContext context, FormBlocState2 state);

/// [BlocListener] that reacts to the state changes of the FormBloc.
class FormBlocListener<
FormBloc extends form_bloc.FormBloc<SuccessResponse, ErrorResponse>,
FormBloc2 extends form_bloc.FormBloc<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>
extends BlocListener<FormBloc,
extends BlocListener<FormBloc2,
form_bloc.FormBlocState<SuccessResponse, ErrorResponse>> {
/// [BlocListener] that reacts to the state changes of the FormBloc.
/// {@macro bloclistener}
Expand Down Expand Up @@ -73,8 +73,8 @@ class FormBlocListener<
.FormBlocDeleteFailed<SuccessResponse, ErrorResponse> &&
onDeleteFailed != null) {
onDeleteFailed(context, state);
} else if (state
is form_bloc.FormBlocDeleteSuccessful<SuccessResponse, ErrorResponse> &&
} else if (state is form_bloc
.FormBlocDeleteSuccessful<SuccessResponse, ErrorResponse> &&
onDeleteSuccessful != null) {
onDeleteSuccessful(context, state);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class FormBlocListener<
/// If the [formBloc] parameter is omitted, [FormBlocListener]
/// will automatically perform a lookup using
/// [BlocProvider].of<[FormBloc]> and the current [BuildContext].
final FormBloc? formBloc;
final FormBloc2? formBloc;

/// The [Widget] which will be rendered as a descendant of the [BlocListener].
@override
Expand Down
12 changes: 9 additions & 3 deletions packages/flutter_form_bloc/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ version: 0.31.0
homepage: https://github.com/GiancarloCode/form_bloc/tree/master/packages/flutter_form_bloc
repository: https://github.com/GiancarloCode/form_bloc/tree/master/packages/flutter_form_bloc
issue_tracker: https://github.com/GiancarloCode/form_bloc/issues
publish_to: none

environment:
sdk: '>=2.12.0 <4.0.0'
sdk: ">=2.12.0 <4.0.0"

dependencies:
flutter:
sdk: flutter

flutter_bloc: ^8.0.1
form_bloc: ^0.31.0
# form_bloc: ^0.31.0
form_bloc:
git:
url: https://github.com/Cavin6080/form_bloc.git
path: packages/form_bloc

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a PR should not change this to point to another repository. This should keep pointing to the same repo. Use paths if needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do this because if we want to use flutter_form_bloc directly from GIT then we can't use it if we mention paths in pubspec.yaml. I've made the changes now for this and pushed this.

equatable: ^2.0.3
rxdart: ^0.27.3
flutter_keyboard_visibility: ^5.4.1
Expand All @@ -24,4 +30,4 @@ dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^2.0.0
flutter_lints: ^3.0.1
1 change: 1 addition & 0 deletions packages/form_bloc/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ analyzer:
avoid_print: warning
annotate_overrides: warning
always_use_package_imports: warning
strict_raw_type: ignore
language:
strict-casts: true
strict-raw-types: true
Expand Down
2 changes: 1 addition & 1 deletion packages/form_bloc/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dependencies:
form_bloc: ^0.30.0

dev_dependencies:
lints: ^1.0.1
lints: ^3.0.0
Loading