I am trying to run sample Riverpod program from Getting started Riverpod page
Pubspec is specified as given on the page.
Debug Console dumps the following message:
Launching lib/main.dart on Chrome in debug mode...
lib/main.dart:1
: Error: Method not found: 'Error.throwWithStackTrace'.
../…/framework/provider_base.dart:985
Error.throwWithStackTrace(error, chain);
^^^^^^^^^^^^^^^^^^^
: Error: A non-null value must be returned since the return type 'Never' doesn't
allow null.
../…/framework/provider_base.dart:979
Never _rethrowProviderError(Object error, StackTrace stackTrace) {
^
Failed to compile application.
Exited (sigterm)
Just to be sure, following is main.dart:
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
// We create a "provider", which will store a value (here "Hello world").
// By using a provider, this allows us to mock/override the value exposed.
final helloWorldProvider = Provider((_) => 'Hello world');
void main() {
runApp(
// For widgets to be able to read providers, we need to wrap the entire
// application in a "ProviderScope" widget.
// This is where the state of our providers will be stored.
const ProviderScope(
child: MyApp(),
),
);
}
// Extend ConsumerWidget instead of StatelessWidget, which is exposed by Riverpod
class MyApp extends ConsumerWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context, WidgetRef ref) {
final String value = ref.watch(helloWorldProvider);
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Example')),
body: Center(
child: Text(value),
),
),
);
}
}
And pubspec is as follows:
name: simple_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.12.0 <3.0.0"
flutter: ">=2.0.0"
dependencies:
flutter:
sdk: flutter
flutter_riverpod: ^2.0.0-dev.4
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
uses-material-design: true
Environment:
Flutter (Channel stable, 2.5.3, on macOS 12.2.1 21D62 darwin-x64, locale en-US)
Related
I had reports of users telling my app restarts the device on android 7.0.0 I tried it on the emulator and that is true. I started trying a lot of things I thought it could be a package or something.
what I finished doing is trying in a whole new project the default app that flutter creates. I tried it in the same version android 7.0.0 and there wasn't any problem.
I grabbed and pasted the main.dart from the default in my project and it keeps closing. I'll show the code just in case:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
#override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
It's just the default code. This is what throws in the debug console before it restarts the device:
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
D/FlutterGeolocator( 8847): Attaching Geolocator to activity
D/FlutterGeolocator( 8847): Creating service.
D/FlutterGeolocator( 8847): Binding to location service.
D/FlutterLocationService( 8847): Creating service.
D/FlutterLocationService( 8847): Binding to location service.
D/FlutterGeolocator( 8847): Geolocator foreground service connected
D/FlutterGeolocator( 8847): Initializing Geolocator services
D/FlutterGeolocator( 8847): Flutter engine connected. Connected engine count 1
Connecting to VM Service at ws://127.0.0.1:61877/QRHypptu-ro=/ws
Lost connection to device.
Exited
Here's my pubspec.yaml
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter 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: 2.1.2+21
environment:
sdk: ">=2.17.0 <3.7.3"
dependencies:
age_calculator: ^1.0.0
animate_do: ^3.0.2
appinio_swiper: ^1.0.3
badges: ^2.0.3
cached_network_image: ^3.2.1
carousel_images: ^1.1.2
carousel_slider: ^4.1.1
chat_bubbles: ^1.2.0
cloud_firestore: ^4.1.0
cupertino_icons: ^1.0.2
date_time_picker: ^2.1.0
dio: ^4.0.6
email_validator: ^2.0.1
equatable: ^2.0.3
extended_image: ^6.2.1
faker: ^2.0.0
firebase_auth: ^4.1.4
firebase_core: ^2.3.0
firebase_database: ^10.0.6
firebase_storage: ^11.0.6
flutter:
sdk: flutter
flutter_bloc: ^8.1.2
flutter_cache_manager: ^3.3.0
flutter_dotenv: ^5.0.2
flutter_feather_icons: ^2.0.0+1
flutter_form_builder: ^7.2.1
flutter_google_places: ^0.3.0
flutter_localizations:
sdk: flutter
flutter_markdown: ^0.6.13
flutter_native_splash: ^2.2.12
flutter_secure_storage: ^6.0.0
flutter_svg: ^1.1.3
geocoder2: ^1.4.0
geolocator: ^9.0.2
google_fonts: ^3.0.1
google_maps_flutter: ^2.2.1
google_sign_in: ^5.3.1
gradient_borders: ^0.2.0
http: ^0.13.5
image_picker: ^0.8.5+3
insta_image_viewer: ^1.0.2
intl: ^0.17.0
jiffy: ^5.0.0
jwt_decode: ^0.3.1
loading_animation_widget: ^1.2.0+2
location: ^4.4.0
lottie: ^1.4.2
marquee: ^2.2.3
permission_handler: ^10.1.0
photo_view: ^0.14.0
pinch_zoom: ^1.0.0
preload_page_view: ^0.1.6
provider: ^6.0.4
share_plus: ^4.5.2
shared_preferences: ^2.0.15
shimmer: ^2.0.0
simple_gradient_text: ^1.2.3
text_scroll: ^0.1.2
theme_provider: ^0.5.0
url_launcher: ^6.1.8
video_player: ^2.4.7
zoom_pinch_overlay: ^1.2.0
dev_dependencies:
flutter_launcher_icons: ^0.11.0
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter
flutter_native_splash:
background_image: assets/img/brand/gradient.png
background_image_dark: assets/img/brand/gradientBlack.png
image: assets/img/others/splash.png
image_dark: assets/img/brand/wikenLogoBlack.png
branding: assets/img/brand/WikenBrand.png
branding_dark: assets/img/brand/WikenBrandBlack.png
android_12:
image: assets/img/brand/12logo.png
image_dark: assets/img/brand/13logo.png
color: "#EE7E58"
color_dark: "#1F1F1F"
flutter_icons:
android: true
ios: true
image_path: "assets/app_logo.png"
adaptative_icon_background: "#ffffff"
adaptative_icon_foreground: "assets/img/brand/logo_foreground.png"
# 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:
- .env
- assets/
- assets/img/
- assets/img/alertas/
- assets/img/brand/
- assets/img/login/
- assets/img/maps/
- assets/img/others/
- assets/img/placeholder/
- assets/img/muestra/
- assets/img/uploadScreen/
- assets/img/tutorial/
- assets/svg/
- assets/ca/
fonts:
- family: Montserrat
fonts:
- asset: assets/fonts/Montserrat-Regular.ttf
- asset: assets/fonts/Montserrat-Italic-VariableFont_wght.ttf
weight: 100
- asset: assets/fonts/Montserrat-Light.ttf
weight: 300
- asset: assets/fonts/Montserrat-Medium.ttf
weight: 500
- asset: assets/fonts/Montserrat-SemiBold.ttf
weight: 600
- asset: assets/fonts/Montserrat-Bold.ttf
weight: 700
- family: Montserrat Alternates
fonts:
- asset: assets/fonts/MontserratAlternates-Regular.ttf
- asset: assets/fonts/MontserratAlternates-Bold.ttf
weight: 700
I have already run flutter clean, flutter pub get, flutter upgrade. I'm on flutter 3.7.3
I hope you can help me! Thanks in advance.
I'm trying to create an app that performs a Firebase authorization on a desktop.
I didn't find any full sample code for this so I started by create a basic demo project on VScode.
As soon as I add the package flutter pub add firebase_auth_desktop (without adding code to the app), I get errors when I try to run the app.
/C:/Users/yvan_/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core-1.24.0/lib/src/firebase_app.dart(18,25): error G75B77105: Member not found: 'FirebaseAppPlatform.verifyExtends'.
[C:\FDSTiming\Project\Flutter\app3\build\windows\flutter\flutter_assemble.vcxproj]
/C:/Users/yvan_/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart(65,15): error GE5CFE876: The method 'FallThroughError' isn't defined for the class 'ActionCodeInfo'. [C:\FDSTiming\Project\Flutter\app3\build\windows\flutter\flutter_assemble.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'C:\FDSTiming\Project\Flutter\app3\build\windows\CMakeFiles\18de2b4c67371752531dc30d7008f913\flutter_windows.dll.rule;C:\FDSTiming\Project\Flutter\app3\build\windows\CMakeFiles\122a37675ed5a5d637290377de62a3e1\flutter_assemble.rule;C:\FDSTiming\Project\Flutter\app3\windows\flutter\CMakeLists.txt' exited with code 1. [C:\FDSTiming\Project\Flutter\app3\build\windows\flutter\flutter_assemble.vcxproj]
Exception: Build process failed.
The code is:
import 'package:flutter/material.dart';
//import 'package:firebase_auth_desktop/firebase_auth_desktop.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
#override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello World!'),
),
),
);
}
}
And pubspec.yaml:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
firebase_auth_desktop: ^1.0.2
Any idea?
I managed to get rid of the first error by adding:
firebase_core_platform_interface: 4.5.1
firebase_messaging: ^13.0.4
But didn't find any clues for the others errors
The flutter firebase_core dependency currently not supported by windows platform.
I am using Firebase Authentication on my Flutter Web app, but the session is not persisted after hot restart or refresh in chrome.
In Android it work properly but in web app after hot reload or chrome refresh user logged out.
After googling and finding for about more than 12hr still not I still not get solution.
also follow this answer of #frank-van-puffelen 's solution but still facing same problem.
this ticket is still not resolved.
If possible please run below code.
I look forward to your answer.
Here is my code in main.dart
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const AuthGate());
}
class AuthGate extends StatelessWidget {
const AuthGate({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
home: StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (BuildContext context, AsyncSnapshot<User?> snapshot) {
if (!snapshot.hasData) {
return const FlutterFireUiLogin();
} else {
return const Text("You are Logged In");
}
},
),
);
}
}
And here is my flutterfire_ui_login.dart
import 'package:flutter/material.dart';
import 'package:flutterfire_ui/auth.dart';
class FlutterFireUiLogin extends StatelessWidget {
const FlutterFireUiLogin({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(
padding: const EdgeInsets.all(20),
child: SignInScreen(
providerConfigs: const [
EmailProviderConfiguration(),
PhoneProviderConfiguration(),
],
),
),
);
}
}
Here is my pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
authentication_repository:
path: packages/authentication_repository
form_inputs:
path: packages/form_inputs
cupertino_icons: ^1.0.2
firebase_auth: ^3.5.0
firebase_core: ^1.20.0
equatable: ^2.0.3
cloud_firestore: ^3.4.0
flutter_bloc: ^8.0.1
firebase_storage: ^10.3.3
rxdart: ^0.27.5
formz: any
meta: any
very_good_analysis: any
flow_builder: any
google_fonts: ^3.0.1
flutterfire_ui: ^0.4.3
font_awesome_flutter: ^10.1.0
google_sign_in: ^5.4.0
google_sign_in_web: ^0.10.2
http: ^0.13.4
path: ^1.8.1
csv: ^5.0.1
provider: ^6.0.3
flutter_lints: ^1.0.4
dev_dependencies:
flutter_test:
sdk: flutter
mocktail: ^0.3.0
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.22000.795], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.8)
X The current Visual Studio installation is incomplete. Please reinstall Visual Studio.
[√] Android Studio (version 2020.3)
[√] IntelliJ IDEA Community Edition (version 2021.2)
[√] VS Code (version 1.69.2)
[√] Connected device (3 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.
This fix has just been released in the latest version 3.6.0.
I tried to run a simple project but i gives me errors:
Launching lib\main.dart on ASUS Z01QD in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform play-services-base-16.0.1.aar (com.google.android.gms:play-services-base:16.0.1) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
> Execution failed for AarResourcesCompilerTransform: C:\Users\win\.gradle\caches\transforms-2\files-2.1\f260781842f212c36494d469961b4620\jetified-play-services-base-16.0.1.
> AAPT2 aapt2-4.1.0-6503028-windows Daemon #0: Unexpected error during compile 'C:\Users\win\.gradle\caches\transforms-2\files-2.1\f260781842f212c36494d469961b4620\jetified-play-services-base-16.0.1\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_normal_background.9.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 58s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
main.dart ->
import 'package:flutter/material.dart';
import 'package:locationflutter/splashscreen.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: SplashScreen(),
);
}
}
splashscreen.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:location/location.dart';
import 'package:locationflutter/location_service.dart';
import 'package:locationflutter/mainscreen.dart';
class SplashScreen extends StatefulWidget {
const SplashScreen({Key? key}) : super(key: key);
#override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
#override
void initState() {
super.initState();
locationService();
}
Future<void> locationService() async {
Location location = new Location();
bool _serviceEnabled;
PermissionStatus _permissionLocation;
LocationData _locData;
_serviceEnabled = await location.serviceEnabled();
if(!_serviceEnabled) {
_serviceEnabled = await location.requestService();
if (!_serviceEnabled) {
return;
}
}
_permissionLocation = await location.hasPermission();
if(_permissionLocation == PermissionStatus.denied) {
_permissionLocation = await location.requestPermission();
if(_permissionLocation != PermissionStatus.granted) {
return;
}
}
_locData = await location.getLocation();
setState(() {
UserLocation.lat = _locData.latitude!;
UserLocation.long = _locData.longitude!;
});
Timer(Duration(milliseconds: 500), () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => MainScreen()));
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text("WELCOME"),
),
);
}
}
mainscreen.dart
import 'package:flutter/material.dart';
import 'package:geocoding/geocoding.dart';
import 'package:locationflutter/location_service.dart';
class MainScreen extends StatefulWidget {
const MainScreen({Key? key}) : super(key: key);
#override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
String country = '';
String name = '';
String street = '';
String postalCode = '';
#override
void initState() {
super.initState();
getLocation();
}
Future<void> getLocation() async {
List<Placemark> placemark = await placemarkFromCoordinates(UserLocation.lat, UserLocation.long);
print(placemark[0].country);
print(placemark[0].name);
print(placemark[0].street);
print(placemark[0].postalCode);
setState(() {
country = placemark[0].country!;
name = placemark[0].name!;
street = placemark[0].street!;
postalCode = placemark[0].postalCode!;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Lat : " + "${UserLocation.lat}"),
Text("Long : " + "${UserLocation.long}"),
Text("Country : " + "$country"),
Text("Name : " + "$name"),
Text("Street : " + "$street"),
Text("PostalCode : " + "$postalCode"),
],
),
),
);
}
}
location_service.dart
class UserLocation {
static double lat = 0;
static double long = 0;
}
pubspec.yaml
name: locationflutter
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.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
location: ^4.3.0
geocoding: ^2.0.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.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:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# 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
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19043.1415], locale
en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.4)
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.63.2)
[√] Connected device (4 available)
! Device 127.0.0.1:5555 is offline.
• No issues found!
I don't know what am I doing wrong.
I Fixed this issue by:
In gradle-wrapper.properties I defined Gradle version 6.1.1
by adding at the last of the file
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
And in the project-level build.gradle I set version 4.0.2
by adding
classpath 'com.android.tools.build:gradle:4.0.2'
reference: solution
The app just begin and I do the sign in first. It was both working on android and ios, but then later in fews day I resume to work on the app, the sign in only work on android.
On iOS, when I use google sign in, and it open a page to accounts.google.com i supposed, then it should ask for the email and password, but it didn't. It only say
Safari cannot open the page because it could not establish a secure connection to the server.
The output of flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.5.9-pre.56, on Mac OS X 10.14.4 18E226, locale en-KH)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
[!] Android Studio (version 3.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
The pubspec.yml
name: xxx
description: xxx
version: 0.0.1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
google_sign_in: ^4.0.1+3
rxdart: ^0.21.0
corsac_jwt: ^0.1.2
graphql_flutter: ^1.0.0
qr_flutter: ^2.0.0
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/google.png
Here is the login_screen.dart
import 'package:flutter/material.dart' as flutter_material;
import 'package:flutter/cupertino.dart' show CupertinoButton;
import '../blocs/bloc_provider.dart' show BlocProvider;
import '../blocs/login_bloc.dart' show LoginBloc;
const String _loginInText = 'Sign In';
const String _googleIconPath = 'assets/google.png';
const double _iconWidth = 39.0;
const double _iconHeight = 39.0;
const double _sizedBoxWidth = 10.0;
const double _signInFontSize = 23.0;
class LoginScreen extends flutter_material.StatelessWidget {
#override
flutter_material.Widget build(flutter_material.BuildContext context) {
final LoginBloc loginBloc = BlocProvider.of<LoginBloc>(context);
return flutter_material.Scaffold(
body: flutter_material.Center(
child: CupertinoButton(
// splashColor: flutter_material.Colors.transparent,
child: flutter_material.Row(
mainAxisSize: flutter_material.MainAxisSize.min,
crossAxisAlignment: flutter_material.CrossAxisAlignment.center,
children: const <flutter_material.Widget>[
const flutter_material.Image(
image: flutter_material.AssetImage(_googleIconPath),
width: _iconWidth,
height: _iconHeight,
),
const flutter_material.SizedBox(width: _sizedBoxWidth, height: 0.0),
const flutter_material.Text(
_loginInText,
style: flutter_material.TextStyle(
fontSize: _signInFontSize,
),
),
],
),
onPressed: loginBloc.signIn,
),
),
);
}
}
the logic_bloc.dart
import 'package:google_sign_in/google_sign_in.dart'
show GoogleSignIn, GoogleSignInAccount, GoogleSignInAuthentication;
import 'package:rxdart/rxdart.dart' as rxdart;
import './bloc_provider.dart' show BlocBase;
class LoginBloc extends BlocBase {
final GoogleSignIn _gSignIn = GoogleSignIn(scopes: ['openid']);
final rxdart.PublishSubject<GoogleSignInAuthentication> _googleSignIn =
rxdart.PublishSubject<GoogleSignInAuthentication>();
rxdart.Observable<GoogleSignInAuthentication> get loginStream => this._googleSignIn.stream;
void signIn() async {
final GoogleSignInAccount account = await this._gSignIn.signIn();
if (account != null) {
this._googleSignIn.sink.add(await account.authentication);
}
}
void signOut() async {
await this._gSignIn.signOut();
this._googleSignIn.sink.add(null);
}
#override
void dispose() async {
await this._googleSignIn.drain();
this._googleSignIn.close();
}
}
So below are the actual result:
UPDATE 1: I also tested on example of the package. It also show cannot connect to the page
In the iOS Simulator
Settings > Developer > Allow HTTP Services (turn on);
Restart Xcode and simulator.