gpt4 book ai didi

firebase - Google 登录后发送消息后屏幕卡住(Flutter Firebase Codelab 友好聊天应用程序)

转载 作者:IT王子 更新时间:2023-10-29 07:01:18 25 4
gpt4 key购买 nike

flutter firebase 的代码实验室我已经完成了一半

应用程序加载正常,接受输入,然后加载 Google 登录选项(如果尚未登录则添加帐户)。在此之后,应用程序卡住。

下面是一些抛出异常的截图:message_codecs.dart 第 514 行

throw new PlatformException(code: errorCode, message: errorMessage, details: errorDetails);

带有新 Flutter 插件运行模拟器的 Android Studio 截图: AndroidStudioFlutterPluginEmulatorRuntimeOutput

在实际 Nexus 5 手机上运行时的屏幕截图: AndroidStudioFlutterPhoneError

这是 main.dart:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'dart:async';

const String _name = "GCom";
final googleSignIn = new GoogleSignIn();
final ThemeData kIOSTheme = new ThemeData(
primarySwatch: Colors.orange,
primaryColor: Colors.grey[100],
primaryColorBrightness: Brightness.light,
);
final ThemeData kDefaultTheme = new ThemeData(
primarySwatch: Colors.red,
accentColor: Colors.orangeAccent[400],
);

void main() {
runApp(new FriendlychatApp());
}

Future<Null> _ensureLoggedIn() async {
GoogleSignInAccount user = googleSignIn.currentUser;
if (user == null) user = await googleSignIn.signInSilently();
if (user == null) {
await googleSignIn.signIn();
}
}

class FriendlychatApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "friendly chatty patch",
theme: defaultTargetPlatform == TargetPlatform.android
? kDefaultTheme
: kIOSTheme,
home: new ChatScreen(),
);
}
}

class ChatMessage extends StatelessWidget {
ChatMessage({this.text, this.animationController});
final String text;
final AnimationController animationController;

@override
Widget build(BuildContext context) {
return new SizeTransition(
sizeFactor: new CurvedAnimation(
parent: animationController, curve: Curves.easeOut),
axisAlignment: 0.0,
child: new Container(
margin: const EdgeInsets.symmetric(
vertical: 15.0), //10 vertical depth from top of screen. height.
child: new Row(
crossAxisAlignment:
CrossAxisAlignment.start, //distance vertical of avatar icon
children: <Widget>[
new Container(
margin: const EdgeInsets.only(
right: 16.0), //0-36- move r of Icon orig 16
child: new CircleAvatar(
backgroundImage:
new NetworkImage(googleSignIn.currentUser.photoUrl))),
new Column(
crossAxisAlignment: CrossAxisAlignment
.end, //.start brings _name end to end of text vertical
children: <Widget>[
new Text(googleSignIn.currentUser.displayName, //_name
style: Theme.of(context).textTheme.subhead), //headline
new Container(
margin: const EdgeInsets.only(
top: 5.0), //distance under _name 40
child: new Text(text +
" whenever") // style: Theme.of(context).textTheme.subhead),
),
],
),
],
),
));
}
}

class ChatScreen extends StatefulWidget {
@override
State createState() => new ChatScreenState();
}

class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
final List<ChatMessage> _messages = <ChatMessage>[];
final TextEditingController _textController = new TextEditingController();
bool _isComposing = false;

@override
Widget build(BuildContext context) {
return new Scaffold(
//can be different than title?
appBar: new AppBar(
title: new Text("friendly chatty patchy codelab."),
elevation:
Theme.of(context).platform == TargetPlatform.iOS ? 0.0 : 4.0,
),
body: new Container(
child: new Column(children: <Widget>[
new Flexible(
child: new ListView.builder(
padding: new EdgeInsets.all(8.0),
reverse: false, //true to place at bottom of screen.
itemBuilder: (_, int index) => _messages[index],
itemCount: _messages.length,
)),
new Divider(height: 1.0),
new Container(
decoration: new BoxDecoration(color: Theme.of(context).cardColor),
child: _buildTextComposer(),
),
]))); //extra )?
}

@override
Widget _buildTextComposer() {
return new IconTheme(
data: new IconThemeData(color: Theme.of(context).accentColor),
child: new Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0), //distance from r
child: new Row(children: <Widget>[
new Flexible(
child: new TextField(
controller: _textController,
onChanged: (String text) {
setState(() {
_isComposing = text.length > 2; //>0
});
},
onSubmitted: _handleSubmitted,
decoration: new InputDecoration.collapsed(
hintText: "send a message..."),
),
),
new Container(
margin: new EdgeInsets.symmetric(horizontal: 4.0),
child: Theme.of(context).platform == TargetPlatform.iOS
? new CupertinoButton(
child: new Text("Send"),
onPressed: _isComposing
? () => _handleSubmitted(_textController.text)
: null,
)
: new IconButton(
icon: new Icon(Icons.send), //whatever icon
onPressed: _isComposing
? () => _handleSubmitted(_textController.text)
: null,
)),
]),
decoration: Theme.of(context).platform == TargetPlatform.iOS
? new BoxDecoration(
border:
new Border(top: new BorderSide(color: Colors.grey[200])))
: null),
);
}

Future<Null> _handleSubmitted(String text) async {
_textController.clear();
setState(() {
_isComposing = false;
});
await _ensureLoggedIn();
// ignore: referenced_before_declaration
void _sendMessage({String text}) {
ChatMessage message = new ChatMessage(
text: text,
animationController: new AnimationController(
duration: new Duration(milliseconds: 1000),
vsync: this,
),
);
setState(() {
_messages.insert(0, message);
});
message.animationController.forward();
}

_sendMessage(text: text);
}

@override
void dispose() {
for (ChatMessage message in _messages)
message.animationController.dispose();
super.dispose();
}
}

Android 监视器显示应用程序正在加载,启动 Google 登录。只有当我点击谷歌帐户时,才会出现“未知缓冲区”。

   20 13:15:39.403 3342-3367/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
10-20 13:15:39.468 3342-3367/? I/OpenGLRenderer: Initialized EGL, version 1.4

[ 10-20 13:15:39.469 3342: 3367 D/ ]
HostConnection::get() New Host Connection established 0x7f629efd1ea0, tid 3367


[ 10-20 13:15:39.470 3342: 3367 W/ ]
Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1
10-20 13:15:39.470 3342-3367/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
10-20 13:15:39.482 3342-3367/? D/EGL_emulation: eglCreateContext: 0x7f629efe2220: maj 2 min 0 rcv 2
10-20 13:15:39.489 3342-3367/? D/EGL_emulation: eglMakeCurrent: 0x7f629efe2220: ver 2 0 (tinfo 0x7f629f08ec60)
10-20 13:15:39.504 3342-3367/? D/EGL_emulation: eglMakeCurrent: 0x7f629efe2220: ver 2 0 (tinfo 0x7f629f08ec60)
10-20 13:15:39.519 3342-3342/? D/EGL_emulation: eglCreateContext: 0x7f629b407b20: maj 2 min 0 rcv 2
10-20 13:15:39.533 3342-3342/? D/EGL_emulation: eglMakeCurrent: 0x7f629b407b20: ver 2 0 (tinfo 0x7f629b38bfa0)
10-20 13:15:39.632 3342-3361/? D/EGL_emulation: eglMakeCurrent: 0x7f629b407b20: ver 2 0 (tinfo 0x7f629b38bee0)
10-20 13:15:39.635 3342-3368/? I/flutter: Diagnostic server listening on http://127.0.0.1:35653/
10-20 13:15:39.719 3342-3368/? I/flutter: Observatory listening on http://127.0.0.1:45464/
10-20 13:16:16.163 3342-3367/com.yourcompany.gcodelab D/EGL_emulation: eglMakeCurrent: 0x7f629efe2220: ver 2 0 (tinfo 0x7f629f08ec60)
10-20 13:16:23.166 3342-3367/com.yourcompany.gcodelab D/EGL_emulation: eglMakeCurrent: 0x7f629efe2220: ver 2 0 (tinfo 0x7f629f08ec60)
10-20 13:16:23.166 3342-3367/com.yourcompany.gcodelab E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f629efe1640

最佳答案

我认为如果未启用 Google 登录(可以在 Firebase 控制台或 here 中完成),或者用于签署 APK 的公钥哈希未上传到 Firebase 控制台,或者如果应用程序标识符(例如 com.example.myapp)未在 Firebase 控制台中正确设置。我建议检查这三件事以确保它们已完成。不过,您没有看到任何有用的控制台日志,这有点奇怪。

关于firebase - Google 登录后发送消息后屏幕卡住(Flutter Firebase Codelab 友好聊天应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46848740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com