我正在使用ListTile列表中的每个项目.每个项目都是从数据阵列动态创建的.ListTile提供onTap,但它对我来说不够,因为我需要通过获取密钥或索引来找出点击了哪个项目.
ListTile:
new ListTile(
//leading: const Icon(Icons.flight_land),
title: const Text('Trix\'s airplane'),
subtitle: const Text('The airplane is only in Act II.'),
enabled: true,
onTap: () { //TODO: get the identifier for this item },
trailing: new Container(
child: new Row(
children: [
new Text("70%"),
const Icon(Icons.flight_land)
]
)
),
)
Run Code Online (Sandbox Code Playgroud) build执行导航代码时,下面类中的函数会TestWidget被调用两次。Test Widget在控制台上打印两次。
有谁知道为什么会这样?
class TestWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("Test Widget");
return new Scaffold(body: new Text("TEST WIDGET"),);
}
}
Run Code Online (Sandbox Code Playgroud)
导航代码:
Navigator.of(context).pushNamed(AppRoutes.fieldData);`
Run Code Online (Sandbox Code Playgroud)
路线定义:
AppRoutes.fieldData: (context) {
return new TestWidget();
},
Run Code Online (Sandbox Code Playgroud) 我正在学习dotnet core 2.1 SPA,当我运行donet core 2.1 SPA Angularwith时dotnet run,我注意到有3个不同的端口:
https:localhost:5001http:localhost:5000http:localhost:34941 当我使用第二个网址时,它只是自动重定向到第一个网址,我收到了安全错误.对于第3个网址,它可以工作.我认为因为它是针对客户端的,第一和第二个URL将用于带有身份验证的API调用?在现场环境中会发生什么?
Program.cs文件中的配置
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
Run Code Online (Sandbox Code Playgroud) 我想在这个Flutter_blue 插件项目中做出贡献,使用 Objective C 框架添加原生 iOS 的功能CoreBluetooth。我如何将框架导入到库中,以便我可以开始使用它的 API?
更新:
CoreBluetooth不适合Flutter项目,因为它不是 cocoapod 依赖项。所以我做了什么,去 cocopods 网站并从那里寻找其他蓝牙依赖项。您还可以在那里找到有关如何安装依赖项的说明。对我来说,我在插件项目中添加pod <depdencyname>了<plugin-project>/example/ios/Podfile。然后添加dependency: <dependencyname>到<plugin-project>/ios/pubspec
我正在构建一个移动应用程序,我想在键盘出现在屏幕上时(即当输入文本字段成为焦点时)删除小部件。
我尝试使用,RawKeyboardListener但似乎无法正常工作,我的代码如下:
new Container(
child: new RawKeyboardListener(focusNode: new FocusNode(),
onKey: (input) => debugPrint("*****KEY PRESSED"),
child: new TextField(
controller: new TextEditingController(),
)));
Run Code Online (Sandbox Code Playgroud) 我正在开发Flutter应用,它使用map_view插件。我想通过修改源代码为插件添加新功能。通过Flutter安装插件后,如何在项目中找到插件的实际源代码?
如何在Flutter中添加插件
map_view插件的依赖项添加到pubspec.yaml下面,然后运行flutter packages get会将其添加到项目中。dev_dependecies:map_view:
目前,我发现了两种可以用来画线的方法,可能可以改进为折线图:
使用canvas.drawCircle(..)和canvas.drawLine(..)
canvas.drawCircle(new Offset(2.0, 5.0), 10.0, paint);
canvas.drawCircle(new Offset(50.0, 100.0), 10.0, paint);
canvas.drawLine(new Offset(2.0, 5.0), new Offset(50.0, 100.0), paint);
Run Code Online (Sandbox Code Playgroud)
使用canvas.drawPoints(PointMode.lines, ..)我更喜欢#2,因为我可以将所有点传递给一个函数canvas.drawPoints(..)。
List offsetList = [new Offset(2.0, 5.0), new Offset(50.0, 100.0),];
canvas.drawPoints(PointMode.lines, offsetList, paint);
Run Code Online (Sandbox Code Playgroud)
涂装对象:
final paint = new Paint()
..color = Colors.blue[400]
..strokeCap = StrokeCap.round
..style = PaintingStyle.fill;
Run Code Online (Sandbox Code Playgroud)
题:
目前,我认为 #2 是绘制折线图的更好方法,但是如何使点像 #1 一样可见?您知道可用于绘制折线图的其他更好方法吗?
drawPoints我正在调用如下函数,该函数遵循API 文档
final paint = new Paint()
..color = Colors.blue[400]
..strokeCap = StrokeCap.round;
var offsetList = [new Offset(2.0, 5.0), new Offset(50.0, 100.0)];
canvas.drawPoints(const PointMode(1), offsetList, paint);
Run Code Online (Sandbox Code Playgroud)
当我传入 时const PointMode(1),canvas.drawPoints它会抛出编译器错误。传递到这个函数的正确方法是什么PointMode?
代码CustomPaint:
return new Scaffold(
body:
new GestureDetector(
onTap: () {
debugPrint("hello");
},
child:
new Container(
alignment: FractionalOffset.center,
child: new CustomPaint(
size: new Size(400.0, 400.0),
painter: new BarChartPainter(currentHeight),
))),
);
//x axis code
canvas.drawLine(new Offset(0.0, 0.0), new Offset(500.0, 0.0), paintAx);```
Run Code Online (Sandbox Code Playgroud)
x 轴代码将从 (0,0) 到 (500,0) 绘制一条线,该线位于Paint. 原点位于框的左上角。如何更改原点以使 (0,0) 位于绘画框的左下角?
当var items = q3.ToList();从代码执行下面的代码片段,它会抛出异常System.NotSupportedException.目的是获得items分组后的列表.
例外:
Unable to create a constant value of type 'AppDB.Stage.Rules'. Only primitive types or enumeration types are supported in this context.
var valuations = context.stage
.Where(q => q.stageID == stageID && !rules.ToList().Any(r => r.type1 == q.type1 || r.type2 == q.type2))
.GroupBy(q => q.stageKey)
.Select(g => g) ;
var q3 = valuations.Select(y => new StageType
{
TypeKey = y.Key,
TypeName= "UNKNOWN",
});
var items = q3.ToList(); //error here
Run Code Online (Sandbox Code Playgroud)