I am currently developing an app with firebase. Using auth, Storage and Firestore Database. When I use an emulator or connect my device to a USB, the app works. But when I use the flutter build apk command and upload with that way app not working. A blank grey screen comes and nothing is happening.
I add <uses-permission android:name="android.permission.INTERNET"/> to android manifest
import 'package:flutter/material.dart';
import 'package:psikoloji/consts.dart';
import 'package:psikoloji/signScreens/onBoarding.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
//late FirebaseAuth _auth;
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
/* _auth = FirebaseAuth.instance;
_auth.signInWithEmailAndPassword(
email: "sezenhs22#gmail.com", password: "Ahmet2004");*/
return MaterialApp(
theme: ThemeData(
drawerTheme: DrawerThemeData(),
inputDecorationTheme: InputDecorationTheme(
focusColor: white,
border: UnderlineInputBorder(
borderRadius: BorderRadius.circular(36),
borderSide: BorderSide.none),
focusedBorder: InputBorder.none,
fillColor: white,
filled: true,
labelStyle: TextStyle(
fontFamily: "bold",
),
),
backgroundColor: grey,
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
elevation: 10,
backgroundColor: blue,
shadowColor: blue.withOpacity(1),
textStyle:
TextStyle(fontSize: 18, fontFamily: "normal", color: white),
minimumSize: Size(300, 60),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18)),
)),
/*bottomSheetTheme:
BottomSheetThemeData(constraints: BoxConstraints.expand()),*/
fontFamily: "normal",
primaryColor: black,
scaffoldBackgroundColor: grey,
appBarTheme: AppBarTheme(
iconTheme: IconThemeData(color: black),
titleTextStyle:
TextStyle(fontFamily: "bold", color: black, fontSize: 22),
color: Colors.transparent,
elevation: 0,
foregroundColor: black,
centerTitle: true)),
debugShowCheckedModeBanner: false,
title: 'Test Et App',
home:
OnBoardingSlider()); //_auth.currentUser != null ? TestlerEkrani() : OnBoardingSlider());
}
firebaseConfigure() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
}
}
And this is my flutter doctor -v
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.19044.2251], locale tr-TR)
• Flutter version 3.3.8 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc25f6 (9 days ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\SEZEN\AppData\Local\Android\sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.31702.278
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.1)
• Android Studio at C:\Program Files\Android\Android Studio1
• 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.11+9-b60-7590822)
[√] VS Code (version 1.73.1)
• VS Code at C:\Users\SEZEN\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.52.0
[√] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.2251]
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.107
• Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.42
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Related
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.
I'm trying introduction_screen 2.1.0 to show intro screen.
I imported it and declared import:
import 'package:introduction_screen/introduction_screen.dart';
But when I call IntroductionScreen(), an error occurred.
_AssertionError ('package:introduction_screen/src/introduction_screen.dart': Failed assertion: line 209 pos 16: '(showNextButton && next != null) || !showNextButton': is not true.)
I referenced some examples and wrote this simple code:
class Intro extends StatefulWidget {
const Intro({Key? key}) : super(key: key);
#override
_Intro createState() => _Intro();
}
class _Intro extends State<Intro> {
List<PageViewModel> getPages() {
return [
PageViewModel(
image: null,
title: "Live Demo page 1",
body: "Welcome to Proto Coders Point",
footer: Text("Footer Text here "),
decoration: const PageDecoration(
pageColor: Colors.blue,
)),
// .................
];
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Example"),
),
body: SafeArea(
child: IntroductionScreen( // ERROR!!
globalBackgroundColor: Colors.white,
pages: getPages(),
showNextButton: true,
showSkipButton: true,
skip: Text("Skip"),
done: Text("Got it "),
onDone: () {},
)));
}
}
As I said before, IntroductionScreen() is an issue.
I imported pub correctly, looks my environment is okay.
[√] Flutter (Channel beta, 2.6.0-5.2.pre, on Microsoft Windows [Version 10.0.22000.258], locale ja-JP)
• Flutter version 2.6.0-5.2.pre at D:\src\flutter_windows_2.5.0-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 400608f101 (5 weeks ago), 2021-09-15 15:50:26 -0700
• Engine revision 1d521d89d8
• Dart version 2.15.0 (build 2.15.0-82.2.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at D:\Android
• Platform android-30, build-tools 29.0.3
• Java binary at: D:\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.2)
• Android Studio at D:\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.61.2)
• VS Code at C:\Users\yukik\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.27.0
[√] Connected device (3 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.54
• Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.30
• No issues found!
From the documentation:
Define Next button (Widget), by adding next: Text('Next')
This param is required, except if you set showNextButton: false
in my case, which is version ^3.0.2 of introduction_screen package it is necessary to define "next" and "done" parameters in "IntroductionScreen" Class. These 2 properties are set to TRUE by Default:
IntroductionScreen(
pages: [
PageViewModel(
title: "Fractional shares",
body: "Instead of having to buy an entire share, invest any amount you want.",
),
PageViewModel(
title: "Learn as you go",
body: "Download the Stockpile app and master the market with our mini-lesson.",
),
],
onDone: () {
// When done button is press
},
showNextButton: true,
next: const Text("Next", style: TextStyle(fontWeight: FontWeight.w600)),
showBackButton: false,
done: const Text("Done", style: TextStyle(fontWeight: FontWeight.w600)),
),
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.
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;
}
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()