Change Navigator.pop() animation duration with page_transition - flutter

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,
);
},
),
);

Related

In Scrollable Widget Google Map Widget Shifting Its Camera At Screen Edges (In case of fragment view)

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.

Animation Container onend function is not called in Flutter

Flutter Doctor
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19042.985], locale en-US)
• Flutter version 2.0.3 at C:\flutter
• Framework revision 4d7946a68d (2 months ago), 2021-03-18 17:24:33 -0700
• Engine revision 3459eb2436
• Dart version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\Anas\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• 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.8+10-b944.6842174)
[√] VS Code (version 1.56.2)
• VS Code at C:\Users\Anas\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (3 available)
• SM A305F (mobile) • R58M78MVZNJ • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
• Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.37
• No issues found!
Main Activity Code For Understanding
import 'package:flutter/material.dart';
import 'package:hungers_den/ui/display_screen.dart';
import 'package:hungers_den/ui/splash_screen.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/splashScreen',
debugShowCheckedModeBanner: false,
routes: {
'/splashScreen': (context) => SplashScreen(),
'/displayScreen': (context) => DisplayScreen(),
},
);
}
}
Actual code where the problem is (onend function of animation container not being called)
import 'package:flutter/material.dart';
import 'package:hungers_den/colors.dart';
class SplashScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: primaryAppColor,
body: Center(
child: AnimatedContainer(
width: 350,
height: 300,
curve: Curves.easeInOutQuint,
decoration: BoxDecoration(
gradient: RadialGradient(
colors: [Colors.yellow, Colors.transparent],
)),
child: Image.asset("assets/images/logo/hungersden-logo.png",
width: 150, height: 150),
duration: Duration(seconds: 4),
onEnd: () {
print('iam here');
//Navigator.pushNamed(context, "/displayScreen");
},
),
),
);
}
}
onend function of animation container is a callback which should be called after animation completes. i have tried this on two projects but onend print is not printed. also checked with breakpoint that it never goes to onend function idk why.

Application UI is completely distorted when Mobile Phone Display Text Size is enlarged - Not Responsive

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
);
},
);

What is _CompactLinkedHashSet in flutter?

I am trying to run my first flutter app and I am getting a redscreen error when I run it on my iPhone but it runs without a problem on the simulator:
type '_CompactLinkedHashSet' is not a subtype of type 'Widget'.
Does anyone know what this error refers to? The error-causing widget is a FutureBuilder. The type of the FutureBuilder is the same as the Future.
Flutter doctor:
[✓] Flutter (Channel dev, v1.18.0, on Mac OS X 10.15.4 19E287, locale en-AU)
• Flutter version 1.18.0 at /Users/Josh/Developer/flutter
• Framework revision 8f7327f83a (11 days ago), 2020-04-06 22:11:01 -0400
• Engine revision 49891e0653
• Dart version 2.8.0 (build 2.8.0-dev.20.0 1210d27678)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/Josh/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 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
class DisclaimerData {
bool agreed;
String version;
DisclaimerData({this.agreed, this.version});
}
class DisclaimerView extends StatefulWidget {
#override
_DisclaimerViewState createState() => _DisclaimerViewState();
}
class _DisclaimerViewState extends State<DisclaimerView> {
Future<DisclaimerData> _getAgreed() async {
final preferences = await SharedPreferences.getInstance();
final disclaimerValues = DisclaimerData();
disclaimerValues.agreed = preferences.getBool('disclaimer_agreed') ?? false;
disclaimerValues.version =
preferences.getString('disclaimer_version') ?? '0';
return disclaimerValues;
}
#override
Widget build(BuildContext context) {
return FutureBuilder<DisclaimerData>(
future: _getAgreed(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Scaffold(
...
_CompactLinkedHashSet is an alternative name for Set. It is internal default Set implementation that dart uses to optimize Set's data structure.
_CompactLinkedHashSet (default Set implementation) and _InternalLinkedHashMap (default Map) have good asymptotic storage efficiency as the size of the collection grows. They are always better than conveniently available alternatives above 10 elements and are designed for a better locality.
source:
https://github.com/dart-lang/sdk/issues/26081

Flutter : How to hide AlertDialog

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()