My ListView Widget is not showing any data - flutter

In my code, i have a listview widget, and i gave data to it from firestore using firebase, and tried to display data on screen as text. But nothing happens, i am not getting any error or something. Still my page is blank. So can anyone tell me that is there a mistake in firebase part or listview one. It will be very helpfull.
Here's my code -
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:social_app/widgets/header.dart';
import 'package:social_app/widgets/progress.dart';
final userRef = FirebaseFirestore.instance.collection("users");
class Timeline extends StatefulWidget {
#override
_TimelineState createState() => _TimelineState();
}
class _TimelineState extends State<Timeline> {
List<dynamic> users = [];
#override
void initState() {
// TODO: implement initState
super.initState();
getUserById();
getUsers();
}
getUserById() {
}
getUsers() async {
final QuerySnapshot snapshot = await userRef.get();
setState(() {
users = snapshot.docs;
});
// snapshot.docs.forEach((DocumentSnapshot doc) {
// print(doc.data());
// print(doc.id);
// print(doc.exists);
// });
}
#override
Widget build(context) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.black,
appBar: header(context, isAppTitle: true),
body: Container(
child: ListView(
children: users.map((user) => Text(user['username'], style: TextStyle(color: Colors.white),)).toList()
),
),
),
);
}
}
Here's my run output -
Performing hot reload...
Syncing files to device sdk gphone x86...
Reloaded 3 of 800 libraries in 817ms.
W/Firestore( 3283): (21.7.1) [Firestore]: Listen for Query(target=Query(users order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
E/flutter ( 3283): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.
E/flutter ( 3283): #0 MethodChannelQuery.get (package:cloud_firestore_platform_interface/src/method_channel/method_channel_query.dart:105:7)
E/flutter ( 3283): <asynchronous suspension>
E/flutter ( 3283): #1 Query.get (package:cloud_firestore/src/query.dart:178:25)
E/flutter ( 3283): #2 _TimelineState.getUsers (package:social_app/pages/timeline.dart:29:50)
E/flutter ( 3283): #3 _TimelineState.initState (package:social_app/pages/timeline.dart:22:5)
E/flutter ( 3283): #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58)
E/flutter ( 3283): #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter ( 3283): #6 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #7 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #8 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter ( 3283): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #11 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter ( 3283): #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter ( 3283): #15 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter ( 3283): #16 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter ( 3283): #17 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter ( 3283): #18 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #20 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter ( 3283): #21 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter ( 3283): #22 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter ( 3283): #23 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter ( 3283): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #26 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter ( 3283): #27 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter ( 3283): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter ( 3283): #29 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter ( 3283): #30 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11)
E/flutter ( 3283): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter ( 3283): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #34 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter ( 3283): #35 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter ( 3283): #36 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter ( 3283): #37 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter ( 3283): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter ( 3283): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter ( 3283): #40 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1158:36)
E/flutter ( 3283): #41 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1143:20)
E/flutter ( 3283): #42 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2683:19)
E/flutter ( 3283): #43 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1136:11)
E/flutter ( 3283): #44 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:350:23)
E/flutter ( 3283): #45 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1883:59)
E/flutter ( 3283): #46 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:915:15)
E/flutter ( 3283): #47 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1883:14)
E/flutter ( 3283): #48 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:339:5)
E/flutter ( 3283): #49 RenderSliverMultiBoxAdaptor.insertAndLayoutLeadingChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:455:5)
E/flutter ( 3283): #50 RenderSliverFixedExtentBoxAdaptor.performLayout (package:flutter/src/rendering/sliver_fixed_extent_list.dart:234:32)
E/flutter ( 3283): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1777:7)
E/flutter ( 3283): #52 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:132:12)
E/flutter ( 3283): #53 _RenderSliverFractionalPadding.performLayout (package:flutter/src/widgets/sliver_fill.dart:170:11)
E/flutter ( 3283): #54 RenderObject.layout (package:flutter/src/rendering/object.dart:1777:7)
E/flutter ( 3283): #55 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:507:13)
E/flutter ( 3283): #56 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1561:12)
E/flutter ( 3283): #57 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1470:20)
E/flutter ( 3283): #58 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1634:7)
E/flutter ( 3283): #59 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:884:18)
E/flutter ( 3283): #60 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:436:19)
E/flutter ( 3283): #61 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:914:13)
E/flutter ( 3283): #62 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:302:5)
E/flutter ( 3283): #63 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
E/flutter ( 3283): #64 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9)
E/flutter ( 3283): #65 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:971:5)
E/flutter ( 3283): #66 _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 3283): #67 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 3283): #68 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 3283): #69 _invoke (dart:ui/hooks.dart:251:10)
E/flutter ( 3283): #70 _drawFrame (dart:ui/hooks.dart:209:3)
E/flutter ( 3283):
W/Firestore( 3283): (21.7.1) [WatchStream]: (a99c49e) Stream closed with status: Status{code=CANCELLED, description=Disconnecting idle stream. Timed out waiting for new targets., cause=null}.
W/ansh.social_ap( 3283): Accessing hidden method Ldalvik/system/CloseGuard;->close()V (greylist,core-platform-api, linking, allowed)

Your code seems to be working fine. Let me explain your problem.
When you create your cloud_firestore for the first time, then permission for accessing the data is set to public in the rules tab. This permission is public for 30 days. After that firestore turned it off and you have to define your own rule.
Here, rules are the actual permission which decide who can access your data and who cannot. Hence, for the time being you can again make the data public by changing the Rules.
Access the Rule tab by following the image below:
Change the Rules at firestore console accordingly. Here is the link to rules documentation.
Note:
You can make the Rules public for testing purposes but don't make it public permanently it will make your data insecure.

Related

shared Preferences in flutter stop the app

I'm calling shared prefs in page I made as splash screen
void initState() {
super.initState();
getPreferences().then((value){
Timer(
Duration(seconds: 2),
(() => {
Navigator.of(context).pushReplacement(new MaterialPageRoute(
builder: (BuildContext context) => value))
}),
);
});
}
and here is my method
getPreferences() async {
WidgetsFlutterBinding.ensureInitialized();//??**
SharedPreferences prefs = await SharedPreferences.getInstance();//the same with home screen in the skip button
bool loadingScreen=prefs.getBool('seen');
print("loadingScreen = $loadingScreen");
StatefulWidget _screen= LoginScr();
if (loadingScreen == null|| loadingScreen == false){
_screen = Tut();
}
else if (loadingScreen == true){
userName = prefs.getString('userName');
if(userName ==null||userName=="null") {
print(userName+' userName in main');
_screen = LoginScr();
} else {
print(userName +'userName in main');
_screen = HomePage();
}
}
return _screen;
}
By the way I don't know what is this line
Widge,tsFlutterBinding.ensureInitialized();//??**
and here is my log
Performing hot restart... Syncing files to device Android SDK built
for x86... Restarted application in 1,776ms. I/flutter ( 8982):
loadingScreen = true E/flutter ( 8982):
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
NoSuchMethodError: The method '+' was called on null. E/flutter (
8982): Receiver: null E/flutter ( 8982): Tried calling: +(" userName
in main") E/flutter ( 8982): #0 Object.noSuchMethod
(dart:core-patch/object_patch.dart:51:5) E/flutter ( 8982): #1
_SplashSCRState.getPreferences (package:plaster/UI/SplashSCR.dart:138:24) E/flutter ( 8982):
E/flutter ( 8982): #2
_SplashSCRState.initState (package:plaster/UI/SplashSCR.dart:26:5) E/flutter ( 8982): #3 StatefulElement._firstBuild
(package:flutter/src/widgets/framework.dart:4765:58) E/flutter (
8982): #4 ComponentElement.mount
(package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8982):
#5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #6 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #7 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8982): #8 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #9 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #10 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16) E/flutter (
8982): #11 Element.rebuild
(package:flutter/src/widgets/framework.dart:4343:5) E/flutter ( 8982):
#12 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5) E/flutter ( 8982):
#13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8982):
#14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #15 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #16 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8982): #17 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #18 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #19 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8982): #20 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #21 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #22 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16) E/flutter (
8982): #23 StatefulElement.performRebuild
(package:flutter/src/widgets/framework.dart:4800:11) E/flutter (
8982): #24 Element.rebuild
(package:flutter/src/widgets/framework.dart:4343:5) E/flutter ( 8982):
#25 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5) E/flutter ( 8982):
#26 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11) E/flutter (
8982): #27 ComponentElement.mount
(package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8982):
#28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #29 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #30 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8982): #31 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #32 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #33 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8982): #34 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #35 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #36 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16) E/flutter (
8982): #37 StatefulElement.performRebuild
(package:flutter/src/widgets/framework.dart:4800:11) E/flutter (
8982): #38 Element.rebuild
(package:flutter/src/widgets/framework.dart:4343:5) E/flutter ( 8982):
#39 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5) E/flutter ( 8982):
#40 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11) E/flutter (
8982): #41 ComponentElement.mount
(package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8982):
#42 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8982): #43 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8982): #44 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16) E/flutter (
8982): #45 Element.r
You trying to print log:
print(userName + ' userName in main');
When userName is null:
if (userName == null || userName == "null")
And it raises exception. Modify print method usage ant try again. It should be like this:
userName = prefs.getString('userName');
if(userName == null || userName == "null") {
print('first start, userName in main is null');
_screen = LoginScr();
} else {
print('$userName is userName in main');
_screen = HomePage();
}

The video_player plugin fails to play videos - Flutter

I updated my flutter to 1.22.0 and now my video_player giving me Exception errors. It was working fine before I updated my flutter to 1.22.0.
Here is my error:
E/flutter ( 8545): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)]
Unhandled Exception:
'package:flutter/src/services/message_codec.dart': Failed assertion:
line 111 pos 15: 'code != null': is not true. E/flutter ( 8545): #0
_AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39) E/flutter ( 8545): #1 _AssertionError._throwNew
(dart:core-patch/errors_patch.dart:36:5) E/flutter ( 8545): #2
new PlatformException
(package:flutter/src/services/message_codec.dart:111:15) E/flutter (
8545): #3 VideoPlayerApi.create
(package:video_player_platform_interface/messages.dart:205:13)
E/flutter ( 8545): E/flutter ( 8545): #4
MethodChannelVideoPlayer.create
(package:video_player_platform_interface/method_channel_video_player.dart:46:42)
E/flutter ( 8545): #5 VideoPlayerController.initialize
(package:video_player/video_player.dart:275:45) E/flutter ( 8545): #6
_ScreenBackgroundVideoState.initState (package:flow/widget/background/screen_background_video.dart:17:9)
E/flutter ( 8545): #7 StatefulElement._firstBuild
(package:flutter/src/widgets/framework.dart:4765:58) E/flutter (
8545): #8 ComponentElement.mount
(package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8545):
#9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #10 MultiChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6236:32) E/flutter (
8545): #11 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #12 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #13 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8545): #14 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #15 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #16 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16) E/flutter (
8545): #17 Element.rebuild
(package:flutter/src/widgets/framework.dart:4343:5) E/flutter ( 8545):
#18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5) E/flutter ( 8545):
#19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8545):
#20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #21 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #22 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8545): #23 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #24 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #25 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8545): #26 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #27 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #28 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8545): #29 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #30 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #31 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8545): #32 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #33 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #34 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16) E/flutter (
8545): #35 Element.rebuild
(package:flutter/src/widgets/framework.dart:4343:5) E/flutter ( 8545):
#36 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5) E/flutter ( 8545):
#37 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5) E/flutter ( 8545):
#38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #39 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #40 SingleChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6118:14) E/flutter (
8545): #41 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3569:14) E/flutter (
8545): #42 Element.updateChild
(package:flutter/src/widgets/framework.dart:3327:18) E/flutter (
8545): #43 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:4652:16)
Here is my code:
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
class ScreenBackgroundVideo extends StatefulWidget {
#override
_ScreenBackgroundVideoState createState() => _ScreenBackgroundVideoState();
}
class _ScreenBackgroundVideoState extends State<ScreenBackgroundVideo> {
VideoPlayerController _controller;
#override
void initState() {
super.initState();
_controller = VideoPlayerController.asset('assets/vid/login.mp4')
// set background video using assets for login screen
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
}); // background video will play as soon as the splashscreen is closed
_controller.play();
_controller
.setLooping(true); // looping set to true for the background video
_controller.setVolume(0); // volume set to 0 for background video
}
#override
void dispose() {
super.dispose();
// TODO: implement dispose
_controller.dispose(); // Dispose the controller after play is done.
}
#override
Widget build(BuildContext context) {
return Container(
child: _controller.value.initialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(),
);
}
}
Need help to get this fixed.
I had to downgrade my flutter version to 1.20.2 for my video_player to work.
If there was any other solution, please let me know.
Alternatively you can downgrade video player to 0.10.11+2 instead of downgrading flutter if you are not using any of new features inside video player plugin.
You can find more details in here: https://github.com/flutter/flutter/issues/66627
Same issue I just upgraded the flutter version 1.22.5 and it worked

Unhandled Exception: type 'PlatformException' is not a subtype of type 'String'

Using Google sign in API for a month now
Getting this error before google sign-in
Changed Cloud Firestore Rules, still showing the same results
API error? (sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null)
E/flutter ( 8552): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: type 'PlatformException' is not a subtype of type 'String'
E/flutter ( 8552): #0 _SignInState.initState.<anonymous closure> (package:event_management/google_signin.dart:35:32)
E/flutter ( 8552): #1 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter ( 8552): #2 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 8552): #3 _FutureListener.handleError (dart:async/future_impl.dart:160:20)
E/flutter ( 8552): #4 Future._propagateToListeners.handleError (dart:async/future_impl.dart:708:47)
E/flutter ( 8552): #5 Future._propagateToListeners (dart:async/future_impl.dart:729:24)
E/flutter ( 8552): #6 Future._completeError (dart:async/future_impl.dart:537:5)
E/flutter ( 8552): #7 _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:47:15)
E/flutter ( 8552): #8 GoogleSignIn.signInSilently (package:google_sign_in/google_sign_in.dart)
E/flutter ( 8552): <asynchronous suspension>
E/flutter ( 8552): #9 _SignInState.initState (package:event_management/google_signin.dart:32:13)
E/flutter ( 8552): #10 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4684:58)
E/flutter ( 8552): #11 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter ( 8552): #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #14 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #15 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #16 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #17 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter ( 8552): #18 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter ( 8552): #19 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter ( 8552): #20 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter ( 8552): #21 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #23 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #26 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #27 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #28 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #29 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter ( 8552): #30 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
E/flutter ( 8552): #31 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter ( 8552): #32 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter ( 8552): #33 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4710:11)
E/flutter ( 8552): #34 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter ( 8552): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #37 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #40 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #41 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter ( 8552): #44 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
E/flutter ( 8552): #45 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter ( 8552): #46 ComponentElement._firstBuild (package
Cloud Firestore Rules:
`
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020, 8, 31);
}
}
}
`
Cause:
This Problem occured as I had re-installed Android Studio in my external ssd, so SHA-1 values changed.
Solution:
Get SHA-1 again using "gradlew signingReport" command in gradlew terminal.
Add new SHA-1 value into the Firebase, it might solve your issue.

Flutter Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111

I'm attempting to get a flutter app, made in android studio, to connect to a c# api hosted locally. Running the api on IIS Express gives a url of https://localhost:44364/api/trip, which I believe relates to http://10.0.2.2:44364/api in Android studio when using the emulator.
I'm attempting to retrieve a list of Trips from the db via API. Postman works fine.
I get multiple errors. I have tried the emulator, I've also tried plugging a phone in directly and switching the address to my ip address. I've even tried switching the api to run in the console and not IIS. Nothing works.
I did attempt to reach the api through the emulator browser and was told the site was unsafe, leading me to think it's a certificate problem.
The flutter project is fairly simple, it's in its infancy stage and I'm still learning how to program it.
Here are the three flutter files, and the error list.
main.dart
import 'dart:convert';
import 'package:bike_client/API.dart';
import 'package:bike_client/models/Trip.dart';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Track It',
theme: new ThemeData(
primarySwatch: Colors.red,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
createState() => new _MyHomePageState();
}
class _MyHomePageState extends State {
var trips = new List<Trip>();
_getTrips() {
API.getTrips().then((response) {
setState(() {
Iterable list = json.decode(response.body);
trips = list.map((model) => Trip.fromJson(model)).toList();
});
});
}
initState() {
super.initState();
_getTrips();
}
dispose() {
super.dispose();
}
#override
build(context) {
return Scaffold(
appBar: AppBar(
title: Text("Trip List"),
),
body: ListView.builder(
itemCount: trips.length,
itemBuilder: (context, index) {
return ListTile(title: Text((trips[index].tripId).toString()));
},
));
}
}
API.dart
import 'dart:async';
import 'package:http/http.dart' as http;
//const baseUrl = "https://192.168.1.14:44364/api";
const baseUrl = "http://10.0.2.2:44364/api";
class API {
static Future getTrips() {
var url = baseUrl + "/trip/1";
return http.get(url);
}
}
Trip.dart
class Trip {
int tripId;
int userId;
Trip(int tripId, int userId) {
this.tripId = tripId;
this.userId = userId;
}
Trip.fromJson(Map json)
: tripId = json['tripId'],
userId = json['userId'];
Map toJson() {
return {'tripId': tripId, 'userId': userId};
}
}
Console
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
E/flutter ( 7781): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 38612
E/flutter ( 7781): #0 IOClient.send (package:http/src/io_client.dart:33:24)
E/flutter ( 7781): <asynchronous suspension>
E/flutter ( 7781): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:176:38)
E/flutter ( 7781): #2 BaseClient.get (package:http/src/base_client.dart:35:7)
E/flutter ( 7781): #3 get.<anonymous closure> (package:http/http.dart:46:36)
E/flutter ( 7781): #4 _withClient (package:http/http.dart:166:20)
E/flutter ( 7781): #5 get (package:http/http.dart:46:5)
E/flutter ( 7781): #6 API.getTrips (package:bike_client/API.dart:9:12)
E/flutter ( 7781): #7 _MyHomePageState._getTrips (package:bike_client/main.dart:30:9)
E/flutter ( 7781): #8 _MyHomePageState.initState (package:bike_client/main.dart:40:5)
E/flutter ( 7781): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter ( 7781): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #13 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 7781): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #38 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 7781): #45 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #47 Element.updateChild (package:flutter/src/wid
E/flutter ( 7781): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 38760
E/flutter ( 7781): #0 IOClient.send (package:http/src/io_client.dart:33:24)
E/flutter ( 7781): <asynchronous suspension>
E/flutter ( 7781): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:176:38)
E/flutter ( 7781): #2 BaseClient.get (package:http/src/base_client.dart:35:7)
E/flutter ( 7781): #3 get.<anonymous closure> (package:http/http.dart:46:36)
E/flutter ( 7781): #4 _withClient (package:http/http.dart:166:20)
E/flutter ( 7781): #5 get (package:http/http.dart:46:5)
E/flutter ( 7781): #6 API.getTrips (package:bike_client/API.dart:9:12)
E/flutter ( 7781): #7 _MyHomePageState._getTrips (package:bike_client/main.dart:30:9)
E/flutter ( 7781): #8 _MyHomePageState.initState (package:bike_client/main.dart:40:5)
E/flutter ( 7781): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter ( 7781): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #13 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 7781): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #38 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 7781): #45 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #47 Element.updateChild (package:flutter/src/wid
E/flutter ( 7781): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 38884
E/flutter ( 7781): #0 IOClient.send (package:http/src/io_client.dart:33:24)
E/flutter ( 7781): <asynchronous suspension>
E/flutter ( 7781): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:176:38)
E/flutter ( 7781): #2 BaseClient.get (package:http/src/base_client.dart:35:7)
E/flutter ( 7781): #3 get.<anonymous closure> (package:http/http.dart:46:36)
E/flutter ( 7781): #4 _withClient (package:http/http.dart:166:20)
E/flutter ( 7781): #5 get (package:http/http.dart:46:5)
E/flutter ( 7781): #6 API.getTrips (package:bike_client/API.dart:9:12)
E/flutter ( 7781): #7 _MyHomePageState._getTrips (package:bike_client/main.dart:30:9)
E/flutter ( 7781): #8 _MyHomePageState.initState (package:bike_client/main.dart:40:5)
E/flutter ( 7781): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter ( 7781): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #13 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 7781): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #38 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 7781): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7781): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 7781): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 7781): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 7781): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 7781): #45 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7781): #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7781): #47 Element.updateChild (package:flutter/src/wid
E/flutter ( 7781): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException:
AND MUCH MORE!
This error occurs mostly when your android AVD or android device is not connected to internet. Sometimes, the developer tries to access plugin on localhost from android device instead of AVD, in such cases, same error occurs. I hope this solves your problem.
Other scenarios involves port blocked by firewalls on serverside.
Kindly upvote if you find my answer usable.
Learn Cybers
If you use the emulator with localhost. please change the IP address from 127.0.0.1 to 10.0.2.2 in API urls.
to avoid the following problems:
write failed
connection closed before ...
Flutter Doctor Error - SocketException: Write failed (OS Error: Broken pipe, errno = 32)
you need to add the correct parameters in the headers.
In my case these problems occur with uploading images and sending base64 encoded requests.
I solved it by adding the following 'connection' header: 'keep-alive',
final response = await this.httpClient.put(
url,
encoding: Utf8Codec(),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Accept': "*/*",
'connection': 'keep-alive',
'Accept-Encoding' : 'gzip, deflate, br',
},
body: body,
);
it works for me
I had the same problem.
I've connencted my PC to my Phone hotspot, got my ip adress using "ipconfig" and made it as my base URL like this
"http://PC_IP_Adress:8000/api"

No working audio_service and firebase_messaging together

In my project audio_service and firebase_messaging not working together.
Error message is:
E/flutter ( 5794): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void com.ryanheise.audioservice.AudioServicePlugin$BackgroundHandler.init(io.flutter.plugin.common.PluginRegistry$Registrar)' on a null object reference, null) E/flutter ( 5794): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7) E/flutter ( 5794): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33) E/flutter ( 5794): E/flutter ( 5794): #2 FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:118:16) E/flutter ( 5794): #4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27) E/flutter ( 5794): #5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15) E/flutter ( 5794): #6 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5794): #7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5) E/flutter ( 5794): #8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11) E/flutter ( 5794): #9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5) E/flutter ( 5794): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #12 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14) E/flutter ( 5794): #13 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #15 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16) E/flutter ( 5794): #16 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5794): #17 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5) E/flutter ( 5794): #18 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5) E/flutter ( 5794): #19 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #20 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #21 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14) E/flutter ( 5794): #22 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #23 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #24 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14) E/flutter ( 5794): #25 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16) E/flutter ( 5794): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5794): #29 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5) E/flutter ( 5794): #30 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11) E/flutter ( 5794): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5) E/flutter ( 5794): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #34 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14) E/flutter ( 5794): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #37 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14) E/flutter ( 5794): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 5794): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 5794): #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16) E/flutter ( 5794): #41 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5794): #42 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5) E/flutter ( 5794): #43 StatefulElement._firs E/flutter ( 5794): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#initialized on channel plugins.flutter.io/firebase_messaging_background) E/flutter ( 5794): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7) E/flutter ( 5794): E/flutter ( 5794): #1 _fcmSetupBackgroundChannel (package:firebase_messaging/firebase_messaging.dart:50:21) E/flutter ( 5794): #2 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45:6) E/flutter ( 5794): #3 _fcmSetupBackgroundChannel (package:firebase_messaging/firebase_messaging.dart:23:32) E/flutter ( 5794): #4 _runMainZoned.. (dart:ui/hooks.dart:239:25) E/flutter ( 5794): #5 _rootRun (dart:async/zone.dart:1126:13) E/flutter ( 5794): #6 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter ( 5794): #7 _runZoned (dart:async/zone.dart:1518:10) E/flutter ( 5794): #8 runZoned (dart:async/zone.dart:1502:12) E/flutter ( 5794): #9 _runMainZoned. (dart:ui/hooks.dart:231:5) E/flutter ( 5794): #10 _startIsolate. (dart:isolate-patch/isolate_patch.dart:307:19) E/flutter ( 5794): #11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)*
Someone has any idea about this error?
Thanks!