我正在尝试使用Flutter中的圆角创建一个警告对话框,如下面的屏幕截图所示.也在这里添加我的代码,但我的输出与预期的完全不同.有人,请帮帮我.

我的代码在这里.
void _showAlert() {
AlertDialog dialog = new AlertDialog(
content: new Container(
width: 260.0,
height: 230.0,
decoration: new BoxDecoration(
shape: BoxShape.rectangle,
color: const Color(0xFFFFFF),
borderRadius: new BorderRadius.all(new Radius.circular(32.0)),
),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
// dialog top
new Expanded(
child: new Row(
children: <Widget>[
new Container(
// padding: new EdgeInsets.all(10.0),
decoration: new BoxDecoration(
color: Colors.white,
),
child: new Text(
'Rate',
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontFamily: 'helvetica_neue_light',
),
textAlign: TextAlign.center,
),
),
],
),
), …Run Code Online (Sandbox Code Playgroud) 输入yo polymer一个干净的目录后,这是完整的错误.
module.js:338
throw err;
^
Error: Cannot find module 'find-index'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/index.js:4:17)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Run Code Online (Sandbox Code Playgroud)
我刚刚重新安装了与节点相关的所有东西,但这里有版本.
node: v0.12.7
npm: 2.11.3
yo: 1.4.7
bower: 1.4.1
grunt-cli: v0.1.13
gulp: 3.9.0
generator-polymer: 1.0.5
Run Code Online (Sandbox Code Playgroud)
请注意,我在安装时会收到警告generator-polymer.
npm WARN deprecated CSSselect@0.4.1: the module is now available as 'css-select'
npm WARN deprecated CSSwhat@0.4.7: the module is now …Run Code Online (Sandbox Code Playgroud) 我正在编写一个带有颤振的应用程序,但在开发过程中遇到了问题。我正在尝试使用自定义小部件的列表视图,它有一个最喜欢的图标,表示您喜欢它的产品。我在构造函数上传递一个布尔值来设置一个变量,该变量控制图标是满还是空。当我点击它时,我会改变它的状态。它工作得很好,但是当我向下和向上滚动时,它会丢失最新状态并返回到初始状态。你知道如何在滚动后保持状态吗?
很多 <3
这是我的代码:
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar( …Run Code Online (Sandbox Code Playgroud) 我想让我的列表项在点击时执行此动画(mp4).我尝试使用AnimatedCrossFade但它需要两个孩子在同一级别,例如细节视图与ListView交叉淡入而不是轻敲项目.事实上,似乎Hero动画是唯一可以在小部件上制作动画的动画.
我在使用英雄时遇到了麻烦.它应该包装列表项吗?如果Widget子树在Hero源/目的地中有显着差异,这是否重要?此外,Hero动画可以与LocalHistoryRoutes或交错动画一起使用吗?
编辑
它现在看起来像我需要做的是使用一个Overlay硬件,我需要将所选项目添加到屏幕上被点击的同一位置的叠加层,然后动画部分将很容易.这里可能使用的是目标/跟随者模式,例如CompositedTransformTarget
当然,我的数据库中的用户拥有可以公开访问的信息以及他们应该看到的其他信息.我正在考虑两种不同的方式来实现它.
选项1:有/users/$uid只由用户读取,并有/users/$uid/profile被任何人读取.
选项2:/users/$uid仅由该用户保持可读性且具有/profiles/$uid公共性.这遵循了更扁平的数据结构的建议,但我不知道在这种情况下它是如何更好的.
我有一个包含GLSurfaceView的Activity.当我点击后退按钮去上一个Activity时,它设法显示该Activity,但屏幕没有响应,最终会出现ANR.
这是onSurfaceCreated()代码:
-编辑-
如果我移动mSurfaceView.onPause();到所有者片段,onPause()那么应用程序在退出片段后不会冻结,但是在退出片段后几秒钟它通常会无声地崩溃(没有强制关闭).
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
if (mOpenGlesVersion == OPENGLES_VERSION_10) mOpenGles = new OpenGles10();
else if (mOpenGlesVersion == OPENGLES_VERSION_11) mOpenGles = new OpenGles11();
else if (mOpenGlesVersion == OPENGLES_VERSION_20) mOpenGles = new OpenGles20();
// Let the caller know the surface has been created.
if (mListener != null) mListener.onGLSurfaceViewCreated();
// No intention of drawing anything, just gathering info.
mSurfaceView.onPause();
}
Run Code Online (Sandbox Code Playgroud)
这是从/data/anr/traces.txt获取的日志信息:(由于--MORE--有两行被弄乱了)
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0) …Run Code Online (Sandbox Code Playgroud) 请帮我理解它的确切含义:
声明为final的本地,顶级或类变量在第一次使用时初始化
所以这是我的测试代码:
lazyTest(msg) => print(msg);
class Printer{
Printer(msg){
print(msg);
}
final finalClassVariable = lazyTest("final class variable");
}
var globalsAreLazy = lazyTest("top-level");
var lazyInitialized = lazyTest("lazy initialized");
void main() {
final localFinal = new Printer("local final");
var initialize = lazyInitialized;
}
Run Code Online (Sandbox Code Playgroud)
输出:
final类变量
local final
lazy initialized
无论finalClassVariable和localFinal 初始化,并且只globalsAreLazy不是.lazyInitialized按照我的预期在访问时初始化.
当我更改特定 futurebuilder 小部件所依赖的状态时,该小部件在异步任务完成之前不会重绘。我希望在状态发生变化后立即重新绘制小部件。下面是futurebuilder的代码:
child: new FutureBuilder(
future: _api.getListOfTourneys(searchTerm, filterChecks, pageNum),
builder: (context, snapshot) {
if (snapshot.hasData) {
if(!(snapshot.data is List)){
return new TourneyItem(snapshot.data['tournament']);
}
return new Expanded(
child: ListView.builder(
shrinkWrap: false,
scrollDirection: Axis.vertical,
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return TourneyItem(snapshot.data[index]);
},
));
} else if (snapshot.hasError) {
return new Text("No results found");
} else {
return new CircularProgressIndicator();
}
},
)
Run Code Online (Sandbox Code Playgroud) 我在Flutter中有一个匿名帐户,正在尝试使用Google的AuthCredential对其进行升级。我已验证凭据是使用似乎有效的accessToken和idToken创建的。
因此,如果auth.currentUser()是我的匿名FirebaseUser,则linkAccountToGoogle()在下面进行调用会导致错误。
/// Upgrade an anonymous account by linking it to a Google account.
Future<FirebaseUser> linkAccountToGoogle() async {
final credential = await _getGoogleAuthCredential();
if (credential != null) {
try {
return auth.linkWithCredential(credential); // <=== THROWS ERROR
} catch (e) {
print(e);
}
}
return null;
}
/// Tries to sign-in silently first. May return `null`.
Future<AuthCredential> _getGoogleAuthCredential() async {
GoogleSignInAccount account;
try {
account = await _googleAuthService.signInSilently() ??
await _googleAuthService.signIn();
} catch (e) {
print(e);
} …Run Code Online (Sandbox Code Playgroud) 假设我要从中读取RAM使用情况/proc/meminfo。我可以想到两种基本方法。
使用shell命令
output = subprocess.check_output('cat /proc/meminfo', shell=True)
# or output = subprocess.check_output(['cat', '/proc/meminfo'])
lines = output.splitlines()
Run Code Online (Sandbox Code Playgroud)
使用open()
with open('/proc/meminfo') as meminfo:
output = meminfo.read()
lines = output.splitlines()
Run Code Online (Sandbox Code Playgroud)
我的问题是两种方法有什么区别?有明显的性能差异吗?我的假设是使用open()是首选方法,因为使用shell命令有点hacker,并且可能与系统有关,但是我找不到关于此的任何信息,所以我想问一下。