I have a dialog as below :
showDialog(
context: context,
barrierDismissible : true,
useRootNavigator: true,
builder: (BuildContext context) {
return new AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5.0))),
title: new Flex(
direction: Axis.horizontal,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: EdgeInsets.only(left: 20.0),
child: new Text("Loading...", style: new TextStyle(
fontSize: 14.0,
color: Colors.black54,
fontFamily: "GoogleSans",
fontWeight: FontWeight.w400
), textAlign: TextAlign.left),
)
],
),
);
},
);
and try to dismiss it with function :
Navigator.of(context, rootNavigator: true).pop();
when in the process of developing, the navigator function it runs well and closes the dialog as expected. but when I upload the application in the google play store, and run the application through the google play store, the navigator function actually closes the application instead of closing the dialog. Why did it happen? is there something wrong with my code ?
and this my flutter doctor -v
Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale en-ID)
• Flutter version 1.12.13+hotfix.7 at /Users/macpro/Documents/Development/flutter
• Framework revision 9f5ff2306b (2 weeks ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/macpro/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 43.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.42.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.0
[✓] Connected device (1 available)
• SM J330G • 4200db84cc425415 • android-arm • Android 9 (API 28)
Instead of using Navigator.of(context, rootNavigator: true).pop(); use Navigator.of(context).pop();
This should solve the issue. Using Navigator.of(context, rootNavigator: true).pop(); is only necessary if you have multiple Navigator objects in your application.
Otherwise, rootNavigator: True need not be declared.
Try changing useRootNavigator: false, and dismiss your dialog by calling Navigator.of(context).pop()
Related
I'm new to Flutter and would love some help with an error.
While using the image_picker package, I noticed that I'm getting a value of null returned when I try to select an image from ios photo gallery.
(Specifically, [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_storage/object-not-found] No object exists at the desired reference.)
I read the package documentation where it says this is a known issue and to try it on a real device. I tried it on my real device an only got the desired result once. Can someone please shed some light on this? Below, I have provided the necessary code and a look and my flutter doctor. Thanks in advance!
P.S. To be clear, I am trying to test this on my physical ios device(iPhone 14 Pro Max), as I am aware of the issue with the ios Simulator and the image_picker package.
Please let me know if I need to provide more information to resolve this issue!
String? photoUrl = " ";
File? image;
Future pickImage() async {
try {
final image = await ImagePicker()
.pickImage(source: ImageSource.gallery, requestFullMetadata: false);
if (image == null) return;
Reference ref = FirebaseStorage.instance.ref().child("profilepic.jpg");
await ref.putFile(File(image.path));
await ref.getDownloadURL().then((value) {print(value); setState(() {
photoUrl = value;
});});
} on PlatformException catch (e) {
debugPrint('Failed to pick image: $e');
}
}
profilePic() {
final Size size = MediaQuery.of(context).size;
return SizedBox(
height: size.height * 0.185,
width: double.infinity,
child: Column(children: [
const Spacer(),
photoUrl != null
?
GestureDetector(
onTap: () {
pickImage();
},
child: Container(
height: 120,
width: 160,
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: const Icon(
Icons.person,
size: 50,
color: Colors.white,
),
),
):Image.network(photoUrl!),
],
),
);
}
[✓] Flutter (Channel stable, 3.7.0, on macOS 12.6.1 21G217 darwin-arm64, locale en-US)
• Flutter version 3.7.0 on channel stable at /Users/myronsp/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b06b8b2710 (9 days ago), 2023-01-23 16:55:55 -0800
• Engine revision b24591ed32
• Dart version 2.19.0
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/myronsp/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/myronsp/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[✓] Connected device (5 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator)
• Myron’s iPhone (mobile) • 00008120-00016D500A80C01E • ios • iOS 16.0.2 20A380
• iPhone 14 Pro Max (mobile) • B8ACBFEA-35E5-4D2C-810C-46100D17EE63 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.6.1 21G217 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
hope you are included all the required steps for accessing gallery in android and iOS as mentioned here.
other chances are out dated packages in the flutter project.
please check the following link to rectify that link
If i am understanding correctly, below your spacer widget in your column children the condition should be photoUrl == null instead of photoUrl != null.
It would be good if you can share some findings.
In scrollable widget, when google map come to screen edges, its camera position slightly shifting. And it produces lagging
Is there an any way to prevent this behavior. Its like google_map trying to reposition its camera. I think this is like an undesired outcome. How could I keep stable the map while it is at screen edges
Sample code and flutter doctor outputs are below the example gif.
Code sample
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class DenemePage extends StatelessWidget {
const DenemePage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 200, bottom: 1500),
child: Container(
width: MediaQuery.of(context).size.width,
height: 400,
child: Stack(
alignment: Alignment.center,
children: [
GoogleMap(
initialCameraPosition:
const CameraPosition(target: LatLng(40, 29), zoom: 10),
),
Icon(Icons.radar_outlined)
],
),
),
),
);
}
}
Flutter Doctor
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.4 21F79 darwin-x64, locale tr-TR)
• Flutter version 2.10.3 at /Volumes/HARDDISK/SDKs/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (5 months ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Volumes/HARDDISK/SDKs/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.69.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.44.0
[✓] Connected device (2 available)
• iPhone 13 Pro (mobile) • BE0A3070-5A72-46F4-A649-6C7F17B9A731 • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I have created a solution.
Download the google_maps_flutter
Edit the code in google_maps_flutter-2.1.8/iOS/Classes/GoogleMapController.m from
_mapView.delegate = weakSelf;
_registrar = registrar;
to
_mapView.delegate = weakSelf;
_mapView.paddingAdjustmentBehavior = kGMSMapViewPaddingAdjustmentBehaviorNever;
_registrar = registrar;
Put this modified google_maps_flutter-2.1.8 folder into somewhere. Let say parentFolder/google_maps_flutter-2.1.8.
In pubspec.yaml file which flutter project you want to use this modified package.
google_maps_flutter:
path: parentFolder/google_maps_flutter-2.1.8
Also I have opened a issue about that on GitHub. More detailed info is at there.
When the user increases the Display Font Size of mobile phone Android/iOS the application UI is completed broken.
Requirement: I need to fix the size of all the TextFields though the user increases the display font size. (Give no support for Accessibility)
Note: I have already given "fontSize" to my textfields, though it enlarges when font size is increase.
Steps to reproduce it:
iOS Mobile: Settings -> Accessibilities -> Display and Text Size -> Large Text -> On -> Maximum
Android Mobile: Settings -> Display -> Font Size -> Huge
Please let me know if any solution prevails.
Help will be appreciated.
Here is my flutter doctor -v
Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-arm, locale en-IN)
• Flutter version 1.22.6 at /Users/sunflower/Documents/flutter
• Framework revision 9b2d32b (3 months ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/sunflower/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Users/sunflower/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin installed
• Dart plugin version 201.9317
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
Please find the attached files to get the highlight of the issue.
When Font Size is increased Application UI
Everything is overflowed
this might help, font size change prohibited,
MaterialApp(
builder: (BuildContext context, Widget child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor),
child: child,
);
},
title: 'Home Page',
);
Lock the textScaleFactor to 1.0 in your 'MaterialApp`:
MaterialApp(
title: 'My App',
builder: (BuildContext context, Widget _) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), // like this
child: Home(), // Your widgets go here
);
},
);
To have an animation while changing screens I am using the page_transition: ^1.1.5
Here is an example:
Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: HandymanDocumentsOverview(), duration: Duration(milliseconds: 150)));
Yesterday I installed firebase_core: ^0.5.0 and updated all other Firebase dependencies. And somehow it just feels like the animation speed for Navigator.pop(context); is way slower than before and doesn't even match the first animations speed.
Does anyone know how to fix that?
Edit here is my flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.4 19E287, locale de-DE)
• Flutter version 1.22.0 at /Users/bastianmeyer/flutter
• Framework revision d408d302e2 (3 days ago), 2020-09-29 11:49:17 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/bastianmeyer/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
• CocoaPods version 1.9.1
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.0.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.49.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.15.0
[✓] Connected device (1 available)
• iPhone SE (2nd generation) (mobile) • FC1FC561-C5E6-4E13-AEE5-B5D9308C29B5 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
The package you are using is not yet updated to set the reverseTransitionDuration which was added to flutter recently.
You can upvote this issue to bring attention to it.
UPDATE: Should be no longer an issue with version 1.1.7+3.
Here's one way of specifying the forward and reverse durations:
Navigator.of(context).push(
PageRouteBuilder(
transitionDuration: Duration(milliseconds: 800), // Forward Duration
reverseTransitionDuration: Duration(milliseconds: 800), // Reverse Duration
pageBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation) {
return NewScreen();
},
transitionsBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
),
);
I have a different behaviour when I run my app on Chrome then when I run it on iOS. It happens when I get to this screen:
import 'dart:io';
import 'package:fixit_shop_flutter/fixit_shop_app/authentication_bloc/user_repository.dart';
import 'package:fixit_shop_flutter/fixit_shop_app/register/bloc/register_bloc.dart';
import 'package:fixit_shop_flutter/fixit_shop_app/register/register_form.dart';
import 'package:fixit_shop_flutter/localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class RegisterScreen extends StatelessWidget {
final UserRepository _userRepository;
RegisterScreen({Key key, #required UserRepository userRepository})
: assert(userRepository != null),
_userRepository = userRepository,
super(key: key);
#override
Widget build(BuildContext context) {
dynamic backButton =
Platform.isIOS ? CupertinoIcons.back : Icons.arrow_back;
return Stack(
children: [
Image.asset('assets/mainBg.png',
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
fit: BoxFit.cover),
Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
centerTitle: true,
elevation: 0,
title: Text(
AppLocalizations.instance.text('RegisterScreenTitle'),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.orange,
fontSize: 22,
fontWeight: FontWeight.w500,
letterSpacing: 1),
),
backgroundColor: Colors.transparent,
leading: IconButton(
icon: Icon(backButton),
color: Colors.redAccent,
onPressed: () {
Navigator.pop(context);
}),
),
body: BlocProvider<RegisterBloc>(
create: (context) => RegisterBloc(userRepository: _userRepository),
child: RegisterForm(),
),
),
],
);
}
}
If on iOS the screen loads normally, while when running the web version it throws the Another exception was thrown: Failed assertion: boolean expression must not be null error.
Do you now what could cause this different behaviour? I followed all the widgets that pass the userRepository along the tree and is all good..as in fact on iOS runs properly.
Here is my flutter doctor :
[✓] Flutter (Channel unknown, v1.12.13+hotfix.5, on Mac OS X 10.13.6 17G65, locale en-IT)
• Flutter version 1.12.13+hotfix.5 at /Users/vinnytwice/Developer/flutter
• Framework revision 27321ebbad (5 months ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/vinnytwice/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.8.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (3 available)
• iPad Pro (10.5-inch) • 23C29147-A4F3-4B9F-8182-9C813D5A54AD • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
• Chrome • chrome • web-javascript • Google Chrome 81.0.4044.129
• Web Server • web-server • web-javascript • Flutter Tools
• No issues found!
Do you see anything to update? I'm on High Sierra so I think I can't go above Flutter version 1.12.13+hotfix.5. Also I see that the channel is unknown..could it have something to do with it ?
As always many thanks for your time and help.
Cheers.
found the reason.. it wasn't the assertion but the platform check I was doing on backButton, that only included iOS..I added the check for the web and it now works es expected. I'll leave the question up as might help others porting their apps to web.
dynamic backButton;
if (kIsWeb) {
backButton = Icons.arrow_back;
} else if (Platform.isIOS) {
backButton = CupertinoIcons.back;
} else {
backButton = Icons.arrow_back;
}