flutter_svg not loading some svg files and throw error - flutter

I am using the flutter_svg package(version ^1.0.3). I got svg icons from fathtericons site. But I have erros. I couldn’t find a better solution to this. filter icon
Output Error
══╡ EXCEPTION CAUGHT BY SVG ╞═══════════════════════════════════════════════════════════════════════
The following assertion was thrown resolving a single-frame picture stream:
Unable to load asset: assets/icons/task/filter.svg
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:237:7)
<asynchronous suspension>
#1 AssetBundle.loadString (package:flutter/src/services/asset_bundle.dart:72:27)
<asynchronous suspension>
#2 AssetBundlePictureProvider._loadAsync (package:flutter_svg/src/picture_provider.dart:546:25)
<asynchronous suspension>
Picture provider: ExactAssetPicture(name: "assets/icons/task/filter.svg", bundle: null, colorFilter:
null)
Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#75508(), name:
"assets/icons/task/filter.svg", colorFilter: null, theme: SvgTheme(currentColor: null, fontSize:
14.0, xHeight: 7.0))
════════════════════════════════════════════════════════════════════════════════════════════
My Code:
SvgButton(
svg: 'assets/icons/task/filter.svg',
onPressed: () {
},
),
class SvgButton extends StatelessWidget {
const SvgButton({
Key? key,
required this.svg,
this.width = 24,
this.height = 24,
this.color,
this.onPressed,
}) : super(key: key);
final String svg;
final double width;
final double height;
final Color? color;
final VoidCallback? onPressed;
#override
Widget build(BuildContext context) {
return IconButton(
icon: SvgPicture.asset(
svg,
color: color,
height: height.w,
width: width.w,
),
onPressed: onPressed,
alignment: Alignment.center,
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
);
}
}
My pubspec.yaml
flutter:
uses-material-design: true
assets:
- assets/icons/
My Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1706], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.1.3)
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.67.2)
[√] Connected device (4 available)
[√] HTTP Host Availability
• No issues found!

Could you please try with newer version : flutter_svg: ^1.1.0
Use SVG cleaner or LOAD Assets in pubspec.yaml: see this :
load assets in pubspec.yaml
see the answer to the same question download SVG cleaner or upload SVG online and clean it. it works for me.

Related

FirebaseException ([cloud_firestore/unavailable] The service is currently unavailable , and how to solve it

i created a simple app using flutter and firebase it all work well but when i click on profile icon from the navigationbar the app froze
Profile page code:
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:yumor/models/progress.dart';
import 'package:yumor/models/user_model.dart';
class profile extends StatefulWidget {
const profile({Key? key,required this.userProfile}) : super(key: key);
final String? userProfile;
#override
State<profile> createState() => _profileState();
}
class _profileState extends State<profile> {
final userRef = FirebaseFirestore.instance.collection('users');
buildprofileheader(){
return FutureBuilder(future:userRef.doc(widget.userProfile).get(),
builder: ((context, snapshot) {
if(!snapshot.hasData){
return CircularProgress();
}
UserModel user=UserModel.fromMap(Map);
return Padding(padding:EdgeInsets.all(16.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.account_circle, size: 90,)
],
),
Container(
alignment: Alignment.center,
padding: EdgeInsets.all(12.0),
child: Text(
user.Username as String,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize:16.0,
),
),
),
],
),
);
}),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
"Profile",
),
),
body: ListView(children: <Widget>[
// buildprofileHeader(),
]));
}
}
navigation Bar source code
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:yumor/models/user_model.dart';
import 'package:yumor/pages/Home_page.dart';
import 'package:yumor/pages/profile.dart';
import 'package:yumor/pages/search.dart';
import 'package:yumor/pages/upload.dart';
class BottomBar extends StatefulWidget {
const BottomBar({Key? key}) : super(key: key);
#override
State<BottomBar> createState() => _BottomBarState();
}
class _BottomBarState extends State<BottomBar> {
List pages = [
home_page(),
search(),
upload(),
profile(userProfile:FirebaseAuth.instance.currentUser!.uid),
];
// this current index means that this index depends on which one you click form 0 to 4
int currentIndex = 0;
void onTap(int index) {
// currentindex equale to index to take value
setState(() {
currentIndex = index;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: pages[currentIndex],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
selectedFontSize: 0,
unselectedFontSize: 0,
onTap: onTap,
currentIndex: currentIndex,
backgroundColor: Colors.white,
selectedItemColor: Colors.black87,
unselectedItemColor: Colors.grey.shade600.withOpacity(0.6),
elevation: 0,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home_outlined), label: 'home'),
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'search'),
BottomNavigationBarItem(
icon: Icon(Icons.add_box_outlined), label: 'add'),
BottomNavigationBarItem(
icon: Icon(Icons.person_outline_rounded), label: 'profile'),
]),
);
}
}
firebase user creation code
import 'package:flutter/foundation.dart';
class UserModel {
String? uid;
String? Username;
String? email;
String? photoUrl;
UserModel(
{this.uid, this.email, this.Username, this.photoUrl});
// receving data from the server
factory UserModel.fromMap(Map) {
return UserModel(
uid: Map['userId'],
Username: Map['Username'],
email: Map['email'],
photoUrl: Map['photoUrl'],
);
}
// /// sending data to firestore
Map<String, dynamic> toMap() {
return {
'userId': uid,
'Username': Username,
'email': email,
'photoUrl': photoUrl,
};
}
}
error_patch.dart
#patch
#pragma("vm:external-name", "Error_throwWithStackTrace")
external static Never _throw(Object error, StackTrace stackTrace);
}
NOTE
flutter doctor -v
[
[√] Flutter (Channel stable, 3.3.5, on Microsoft Windows [Version 10.0.19044.2130], locale en-US)
• Flutter version 3.3.5 on channel stable at C:\Dart\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d9111f6402 (8 days ago), 2022-10-19 12:27:13 -0700
• Engine revision 3ad69d7be3
• Dart version 2.18.2
• DevTools version 2.15.0
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\Abdou\AppData\Local\Android\Sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
• 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.12+7-b1504.28-7817840)
[√] VS Code, 64-bit edition (version 1.72.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.50.0
[√] Connected device (3 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 7.0 (API 24) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.2130]
• Edge (web) • edge • web-javascript • Microsoft Edge 106.0.1370.52
[√] HTTP Host Availability
• All required HTTP hosts are available ]
my pubspec.yaml
name: yumor
description: A new Flutter project.
# 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: 1.0.0+1
environment:
sdk: ">=2.16.1 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
cached_network_image: ^3.2.0
cloud_firestore: ^3.1.10
cupertino_icons: ^1.0.2
email_validator: ^2.0.1
firebase_auth: ^3.3.9
firebase_core: ^1.13.1
firebase_storage: ^10.2.15
flutter:
sdk: flutter
flutter_native_splash: ^2.2.9
flutter_svg: ^1.0.3
fluttertoast: ^8.0.9
get: ^4.6.5
image_picker: ^0.8.5
dev_dependencies:
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter
flutter_native_splash:
background_image: assets/splashcreen.png
image: assets/start_logo.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:
- assets/yumor-logo.png
- assets/search_page.svg
- assets/upload_page.svg
- assets/user.png
# 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
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:yumor/models/progress.dart';
import 'package:yumor/models/user_model.dart';
class profile extends StatefulWidget {
const profile({Key? key,required this.userProfile}) : super(key: key);
final String? userProfile;
#override
State<profile> createState() => _profileState();
}
class _profileState extends State<profile> {
final userRef = FirebaseFirestore.instance.collection('users');
final doc = await docRef.doc(docId).get();
if (doc.exists) {
data = doc.data();
}
buildprofileheader(){
return FutureBuilder( return FutureBuilder(future:doc,
builder: ((context, snapshot) {
if(!snapshot.hasData){
return CircularProgress();
}
UserModel user=UserModel.fromMap(Map);
return Padding(padding:EdgeInsets.all(16.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.account_circle, size: 90,)
],
),
Container(
alignment: Alignment.center,
padding: EdgeInsets.all(12.0),
child: Text(
user.Username as String,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize:16.0,
),
),
),
],
),
);
}),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
"Profile",
),
),
body: ListView(children: <Widget>[
// buildprofileHeader(),
]));
}
}

"Tried to paint a RenderObject reentrantly." error arise in flutter?

I'm trying to fetch the names of countries from an API and display it in a drop-down box. I'm using the bloc library for state management.
Here's my Code.
select_input_field.dart - Custom wrapper widget for DropdownButtonField
import 'package:flutter/material.dart';
class SelectInputField extends StatelessWidget {
final String label;
final List<String> options;
final TextEditingController controller;
final EdgeInsets padding;
const SelectInputField(this.label, this.options,
{ Key? key,
required this.controller,
this.padding =
const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30)})
: super(key: key);
#override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: DropdownButtonFormField(
decoration: InputDecoration(
labelText: label,
labelStyle: Theme.of(context).textTheme.bodyMedium,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).primaryColorDark,
width: 1,
),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).primaryColorDark,
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.secondary,
width: 1,
),
),
fillColor: Theme.of(context).primaryColorLight),
style: Theme.of(context).textTheme.bodyMedium,
items: options.map((String value) {
print(value);
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? value) {
controller.text = value ?? '';
},
),
);
}
}
This is the method I'm using to build it.
Widget _countriesDropDown(BuildContext context, TextEditingController controller){
return BlocProvider(
create: (context) => _signupBloc,
child: BlocBuilder<SignupBloc,SignupState>(
buildWhen: ((previous, current) => previous is! Loaded && current is Loaded),
builder: (context, state){
if (state is Initial){
_signupBloc.add(LoadEvent());
}
else if (state is Loaded){
countries = state.countries;
return SelectInputField("Country", countries, controller: controller);
}
return CircularProgressIndicator(color: Theme.of(context).colorScheme.secondary,);
},
)
);
}
And my bloc class is as follows.
class SignupBloc extends Bloc<SignupEvent, SignupState> {
static const String countriesUrl = "https://api.first.org/data/v1/countries";
SignupBloc() : super(Initial()) {
on<LoadEvent>((event, emit) async{
emit(Loading());
List<String> countries = [];
try{
final response = await http.get(Uri.parse(countriesUrl));
if(response.statusCode == 200){
var responseJson = jsonDecode(response.body);
responseJson['data'].values.forEach((element) {
countries.add(element['country']);
});
emit(Loaded(countries));
}
else{
emit(Failed("Error in getting data"));
}
}
catch(e){
print(e);
emit(Failed("Failed to access internet. Try again later!"));
}
});
}
The error appears to look like this. I cannot understand where this error occurs
======== Exception caught by rendering library =====================================================
The following assertion was thrown during paint():
Tried to paint a RenderObject reentrantly.
The following RenderObject was already being painted when it was painted again: RenderPointerListener#c100e relayoutBoundary=up20 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=351.4, 0.0<=h<=Infinity)
... size: Size(351.4, 64.0)
... behavior: opaque
... listeners: down, panZoomStart
Since this typically indicates an infinite recursion, it is disallowed.
The relevant error-causing widget was:
DropdownButtonFormField<String> DropdownButtonFormField:file:///D:/Projects/sem5/iblock/lib/widgets/forms/select_input_field.dart:20:14
When the exception was thrown, this was the stack:
#0 RenderObject._paintWithContext.<anonymous closure> (package:flutter/src/rendering/object.dart:2693:9)
#1 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2706:6)
#2 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:239:13)
#3 RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:144:15)
#4 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2796:7)
#5 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:239:13)
#6 RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:144:15)
#7 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2796:7)
I need an explanation about what's wrong with my code and how to fix this.
Output of flutter doctor
[√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Version 10.0.22621.608], locale en-US)
• Flutter version 3.3.2 on channel stable at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision e3c29ec00c (3 weeks ago), 2022-09-14 08:46:55 -0500
• Engine revision a4ff2c53d8
• Dart version 2.18.1
• DevTools version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\ISHAD\AppData\Local\Android\sdk
• Platform android-32, 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.13+0-b1751.21-8125866)
• All Android licenses accepted.
[√] Chrome - develop for the web
• CHROME_EXECUTABLE = C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.18)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.11.32802.440
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.3)
• 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.13+0-b1751.21-8125866)
[√] IntelliJ IDEA Ultimate Edition (version 2022.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.2
• Flutter plugin version 70.2.5
• Dart plugin version 222.4167.21
[√] VS Code (version 1.71.2)
• VS Code at C:\Users\ISHAD\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.48.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.608]
• Chrome (web) • chrome • web-javascript • unknown
• Edge (web) • edge • web-javascript • Microsoft Edge 105.0.1343.53
! Device DRGGAM5890805202 is not authorized.
You might need to check your device for an authorization dialog.
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
PS:
I'm not much familiar with Flutter/ bloc library.
Not sure if you still having this issue but I had a similar issue and I added isExpanded: true to my DropdownButtonFormField which resolved the error. My problem was caused by the length of the words in my DropdownMenuItem. When I look at the response of your API call I see some very long names. I could be wrong though
Converting the SelectInputField to a StatefulWidget solved the issue.
I think DropdownButtonFormField need to be rendered itself upon activities on it. So, StatelessWidget cannot rerender itself causing this problem.

My Flutter web app logout every time whenever I made change in code in vs code and hot reload

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.

Geocoder Runtime error in new flutter upgrade

I have been using Geocoder-0.1.2, from starting, and it did not cause me any problem. I have just upgraded my flutter and while running my project, I get this error:
Compiler message:
file:///Users/alok/flutter/.pub-cache/hosted/pub.dartlang.org/geocoder-0.1.2/lib/services/d
istant_google.dart:38:56: Error: The argument type 'Utf8Decoder' can't be assigned to the
parameter type 'StreamTransformer<Uint8List, dynamic>'.
- 'Utf8Decoder' is from 'dart:convert'.
- 'StreamTransformer' is from 'dart:async'.
- 'Uint8List' is from 'dart:typed_data'.
Try changing the type of the parameter, or casting the argument to
'StreamTransformer<Uint8List, dynamic>'.
final responseBody = await response.transform(utf8.decoder).join();
^
Compiler failed on /Users/alok/MyProjects/newmonkapp/lib/main.dart
Error launching application on iPhone 7.
Since the error shows it is in the main.dart, there is no code related to that, I have doubled checked it. Here you go.
main.dart
import 'package:flutter/material.dart';
void main() => runApp(NewMonkApp());
class NewMonkApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
print("in the main builder");
return MaterialApp(
title: 'XYZ',
debugShowCheckedModeBanner: false,
theme: ThemeData(
backgroundColor: Color.fromRGBO(249, 249, 251, 1),
fontFamily: 'SF Pro',
primaryColor: Color.fromRGBO(253, 92, 99, 1),
textTheme: TextTheme(
headline: TextStyle(
fontSize: 34.0, fontWeight: FontWeight.bold,
color: Color.fromRGBO(64, 72, 82, 1)
)
)
),
initialRoute: "/",
routes: {
"/": (context) => InitPage(),
// "/": (context) => SearchFilterPage()
}
);
}
}
And it exits the application. Don't know what the problem is, and how should I fix this. I have tried to google it, seems like couldn't find a better solution for this. Any help would be appreciated.
Flutter Doctor results:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.8.1-pre.44, on Mac OS X 10.14.5 18F132, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Chrome - develop for the web
[!] Android Studio (version 3.4)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (3 available)
! Doctor found issues in 1 category.
Any help would be appreciated. Thanks :)
change this line final response = await request. close().
to
final response = await request.close().then((response){ response.cast>().transform(utf8.decoder).listen((content) { return content; }); });
This worked for me😘
Inside flutter plugins, geocoder and file name distant_google.dart

How to fix 'Safari cannot open the page...' error when signing in to google in flutter google sign in

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.