After selecting image from image picker , flutter app crashes - flutter

It works good when I tab on selecting image from camera. After selecting image from camera it suddenly crashes and goes back to previous screen .. terminal is show no error .. m using try & catch method but it catch no error as well.
Future pickimage() async {
try{
await ImagePicker.pickImage(
source: ImageSource.camera,
imageQuality: 50,
).then((img) => setState(() {
immage = img;
imagefile = File(immage.path);
}));
if (imagefile != null) {
print('heloo data is saving to database');
await saveimage();
}
}catch(e){
print(e);
}
}
m using latest image_picker() version this is my pub dependences
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
carousel_slider: ^2.3.1
animated_text_kit: ^1.3.1
cloud_firestore: ^0.14.3
progress_dialog: ^1.2.4
firebase_auth: ^0.18.4+1
firebase_core: ^0.5.3
google_maps_flutter: ^1.0.6
geolocator: ^6.1.5
geoflutterfire: ^2.2.1
image_picker: ^0.6.7+22
firebase_storage: ^5.2.0
latlng: ^0.0.2
location: ^3.1.0
simple_animations: ^2.4.0
liquid_swipe: ^1.5.0
otp_text_field: ^1.0.1
charts_flutter: ^0.9.0
flutter_echarts: ^1.5.0
flutter_staggered_animations: "^0.1.2"

Have you added few lines of configuration on AndroidManifest.xml ?
You should add:
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"/>
check this url: https://pub.dev/packages/image_cropper/versions/1.3.1
and section: How to install

This is an error in the plugin. You can track the similar issues on GitHub (for example here and here) and provide your error and device hardware info for developers.

Any Feedback on this?
It seems it happening every time i call pickImage.
Future getImage() async {
final _imageFiles =
await ImagePicker().getImage(source: ImageSource.gallery);
if (_imageFiles != null) {
File _imageFile = await Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ImageCropper(file: File(_imageFiles.path))),
);
if (_imageFile != null) {
setState(() {
profilePicChange = _imageFile.path;
// Navigator.pop(context);
});
}
}

In my case apps crush with message "Lost connection to device." both on real device and on simulator.

Related

Flutter Web + Firebase: [firebase_auth/argument-error]

I have a Flutter App that I'm simply building to web. I use pretty much the whole suite of Firebase tools. What happens is that whenever I try to call the any signIn method e.g. signInAnonymously or signInWithEmailAndPassword, I get an [firebase_auth/argument-error].
Regular firebase calls, like Firestore get() or update() are working fine.
This is my pubspec.yaml:
firebase_auth:
firebase_auth_web:
firebase_core:
firebase_core_web: ^1.7.3
firebase_storage:
firebase_analytics:
firebase_dynamic_links:
firebase_messaging:
cloud_firestore:
cloud_firestore_web:
cloud_functions:
I initialize Firebase like this in main.dart
if (Constants.BUILD_FOR_WEB) {
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
),
);
} else {
await Firebase.initializeApp();
}
Note: I removed all firebase configurations from index.html because I read that it isn't needed anymore. Since firestore calls worked after removing, I figured it was true.
What I am doing is simply calling my anonymousSignUp() function:
import 'package:firebase_auth_web/firebase_auth_web.dart' as authWeb;
import 'package:firebase_auth/firebase_auth.dart' as auth;
Future<void> anonymousSignUp() async {
try {
if (Constants.BUILD_FOR_WEB) {
await _authWeb.signInAnonymously();
} else {
await _auth.signInAnonymously();
}
} catch (e) {
print(e);
}
}
I get an [firebase_auth/argument-error], nothing more.
No console output, nothing in the network tab either.
I don't know what to do. If anybody has a clue, I'm incredibly thankful for everything.

flutter two packages conflict

I'm trying to use date_picker_timeline saying :
pubspec.YAML
dependencies:
bottom_navy_bar: ^6.0.0
cloud_firestore: ^3.1.18
cupertino_icons: ^1.0.2
dash: ^1.0.3
drop_down_list: ^0.0.2
firebase_auth: ^3.3.20
firebase_core: ^1.18.0
flutter:
sdk: flutter
flutter_secure_storage: ^5.0.2
flutter_signin_button: ^2.0.0
google_fonts: ^3.0.1
google_sign_in: ^5.4.0
line_icons: ^2.0.1
provider: ^6.0.3
snippet_coder_utils: ^1.0.8
date_picker_timeline:
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/date_picker_timeline-1.2.3/lib/date_picker_widget.dart:104:8: Error: Can't declare a member that conflicts with an inherited one.
void initState() {
^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/date_picker_timeline-1.2.3/lib/date_picker_widget.dart:128:20: Error: The method 'call' isn't defined for the class 'void'.
Try correcting the name to the name of an existing method, or defining a method named 'call'.
super.initState();
my datepiker method
DatePicker datePickerMethod() {
return DatePicker(
DateTime.now(),
controller: dp,
initialSelectedDate: DateTime.now(),
selectionColor: Colors.blueAccent,
selectedTextColor: Colors.white,
);
}
already tried to flutter clear alson to delet puspec.lock not working

The method 'openAudioSession' isn't defined for the type 'FlutterSoundRecorder'

I am writing a flutter app for recording voice using flutter_sound package
environment:
sdk: ">=2.15.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_sound: ^9.1.2
permission_handler: ^8.3.0
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart';
Future init() async {
_audioRecorder = FlutterSoundRecorder();
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted){
throw RecordingPermissionException('Microphone permission denied.');
}
await _audioRecorder!.openAudioSession();
_isRecorderInitiated = true;
}
I am getting this error
The method 'openAudioSession' isn't defined for the type 'FlutterSoundRecorder'.
Can anybody help me in finding out what's wrong with the code?
It seems to have been removed in version 9, but the documentation has not been updated. You can use openRecorder() instead or switch to an older version of the library.

Stripe cannot make make payment error in webview

I'm using stripe payment gateway in my app everything works fine when i enter card details after that it redirect to the OTP page after enter otp and submit it throws this error
This problem occurs only in live mode, in test mode debit card won't ask for OTP
I/flutter ( 5342): errprint : PlatformException(failed, failed, null, null)
payment-service.dart
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:stripe_payment/stripe_payment.dart';
class StripeTransactionResponse {
String message;
bool success;
StripeTransactionResponse({this.message, this.success});
}
class StripeService {
static String apiBase = 'https://api.stripe.com/v1';
static String paymentApiUrl = '${StripeService.apiBase}/payment_intents';
static String secret = 'xxxMy_secretxxx';
static Map<String, String> headers = {
'Authorization': 'Bearer ${StripeService.secret}',
'Content-Type': 'application/x-www-form-urlencoded'
};
static init() {
StripePayment.setOptions(StripeOptions(
publishableKey: "xxxMy_keyxxx",
androidPayMode: 'production'));
}
static Future<StripeTransactionResponse> payViaExistingCard(
{String amount, String currency, CreditCard card}) async {
try {
var paymentMethod = await StripePayment.createPaymentMethod(
PaymentMethodRequest(card: card));
var paymentIntent =
await StripeService.createPaymentIntent(amount, currency);
print("payment intent ${paymentIntent}");
var response = await StripePayment.confirmPaymentIntent(PaymentIntent(
clientSecret: paymentIntent['client_secret'],
paymentMethodId: paymentMethod.id));
print("Payment confirm ${response.status}");
if (response.status == 'succeeded') {
return new StripeTransactionResponse(
message: 'Transaction successful', success: true);
} else {
return new StripeTransactionResponse(
message: 'Transaction failed', success: false);
}
} on PlatformException catch (err) {
print("errprint : $err");
return StripeService.getPlatformExceptionErrorResult(err);
} catch (err) {
print("errprint$err");
return new StripeTransactionResponse(
message: 'Transaction failed: ${err.toString()}', success: false);
}
}
static Future<Map<String, dynamic>> createPaymentIntent(
String amount, String currency) async {
try {
Map<String, dynamic> body = {
'amount': amount,
'currency': currency,
'payment_method_types[]': 'card',
'description': 'Software development services',
'shipping[name]': 'Jenny Rosen',
'shipping[address][line1]': '510 Townsend St',
'shipping[address][postal_code]': '98140',
'shipping[address][city]': 'San Francisco',
'shipping[address][state]': 'TN',
'shipping[address][country]': 'IN',
};
var response = await http.post(StripeService.paymentApiUrl,
body: body, headers: StripeService.headers);
print("check post res${jsonDecode(response.body)}");
return jsonDecode(response.body);
} catch (err) {
print('err charging user: ${err.toString()}');
}
return null;
}
}
This is my pubspec.yaml
name: message
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
intro_slider: ^2.3.2
firebase_auth: ^0.18.0+1
cloud_firestore: ^0.14.0+2
fluttertoast: ^7.0.2
image_picker: ^0.6.0+9
shared_preferences: ^0.5.3+1
firebase_storage: ^4.0.0
#flutter_html: ^1.0.2
firebase_core: ^0.5.0
giffy_dialog:
cached_network_image: ^2.2.0+1
modal_progress_hud: ^0.1.3
intl: ^0.16.1
flutter_clipboard_manager:
sentry: ^2.2.0
timeago: ^2.0.27
qr_flutter:
graphql:
image_cropper: ^1.0.2
contacts_service: ^0.4.6
permission_handler: ^5.0.1+1
share: ^0.6.1
fleva_icons: ^1.0.0
google_fonts : ^0.2.0
flutter_staggered_grid_view: ^0.3.0
flutter_icons: ^1.0.0+1
flutter_cache_store:
web3dart: ^1.2.3
bitcoins: ^1.0.3
#bitcoinFlutter
bitcoin_flutter: ^2.0.1
carousel_slider: ^1.3.1
transparent_image: ^1.0.0
smooth_star_rating: ^1.0.3
dots_indicator: ^1.1.0
bip32: ^1.0.5
bip39: ^1.0.3
tuple:
hex: ^0.1.2
scoped_model: ^1.0.1
equatable:
crypto: ^2.1.5
encrypt: ^4.0.2
localstorage:
path_provider:
photo_view: ^0.4.0
mime: ^0.9.6+2
ntp: ^1.0.3
decimal:
virtual_keyboard:
local_auth:
url_launcher: ^5.7.2
launch_review: ^2.0.0
flutter_secure_storage: ^3.3.4
giphy_client: ^0.2.0
flutter_barcode_scanner:
firebase_messaging: ^5.0.2
font_awesome_flutter:
#otpinput field
pin_code_fields: ^5.0.1
#otpanimation lib
flare_flutter: ^2.0.6
flutter_slidable: ^0.5.7
file_picker: ^2.0.6
ethereum_address:
flutter_downloader:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
#upi payment gateway
upi_india: ^2.1.2
cool_alert: ^1.0.1
#webview for paymentgateway
#webview_flutter: ^1.0.0
#paypal payment gateway
http_auth: ^0.3.0
#Razorpay payment gateway
#razorpay_flutter: ^1.2.2
#stripe payment gateway
stripe_payment: ^1.0.8
#stripeUI
flutter_credit_card: ^0.1.3
progress_dialog: ^1.2.2
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/img_not_available.jpeg
- assets/flags/
- assets/emoji/
- assets/images/
- assets/bg1.jpg
- assets/giphy.png
- assets/anime/otp.flr
- assets/splash.png
- assets/splashc.jpg
- assets/json/FacebookPost.json
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
Assuming that "OTP" is a "one time password" as part of a 3D Secure flow, then you can trigger this in test mode by using the SCA regulatory test cards such as the 3155 or 3184 card.
It's not clear where your error is coming from, but if you can share more detail with reproduction in test mode then someone may be able to offer more suggestions.

MissingPluginException(No implementation found for method init on channel plugins.flutter.io/google_sign_in) FLUTTER

I have run flutter doctor and it is reporting no error. The google authentication works fine in IOS but not for android. People tend to say an update does the job but it has not worked for me.It crashes on: _currentUser = await _googleSignIn.signIn();
try {
_currentUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await _currentUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
final authResult = await _auth.signInWithCredential(credential);
final user = await _auth.currentUser();
}catch(ex){}
The pubspec file is as follows:
name: app
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to
pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
modal_progress_hud: ^0.1.3
http: ^0.12.2
shared_preferences: ^0.5.8
firebase_core: ^0.4.5
firebase_auth: ^0.16.1
cloud_firestore: ^0.13.7
flutter_facebook_login: ^3.0.0
flutter_facebook_auth: ^0.2.3
google_sign_in: ^4.5.1
flutter_signin_button: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/images/
fonts:
- family: Questrial
fonts:
- asset: assets/fonts/Questrial-Regular.ttf
weight: 900
This was solved in one of two ways, I moved from master to stable branch and also completed the Facebook authentication. For whatever reason there is some dependency if you use the SignInButtons package so both needed to be implemented.