小编gre*_*nes的帖子

如何获取列表中所选项目的索引/键Flutter?

我正在使用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)

dart flutter

11
推荐指数
2
解决办法
2万
查看次数

为什么在 flutter 中调用 Navigator.of(context).pushNamed(..) 时小部件会构建两次?

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)

flutter

8
推荐指数
1
解决办法
1679
查看次数

为什么.net core 2.1 SPA有3个不同的端口?

我正在学习dotnet core 2.1 SPA,当我运行donet core 2.1 SPA Angularwith时dotnet run,我注意到有3个不同的端口:

  1. https:localhost:5001
  2. http:localhost:5000
  3. http:localhost:34941

当我使用第二个网址时,它只是自动重定向到第一个网址,我收到了安全错误.对于第3个网址,它可以工作.我认为因为它是针对客户端的,第一和第二个URL将用于带有身份验证的API调用?在现场环境中会发生什么?

运行<code> dotnet run </ code>的结果

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)

asp.net-core asp.net-core-2.1

8
推荐指数
1
解决办法
1954
查看次数

如何将 iOS 原生框架导入 Flutter?

我想在这个Flutter_blue 插件项目中做出贡献,使用 Objective C 框架添加原生 iOS 的功能CoreBluetooth。我如何将框架导入到库中,以便我可以开始使用它的 API?

更新:

CoreBluetooth不适合Flutter项目,因为它不是 cocoapod 依赖项。所以我做了什么,去 cocopods 网站并从那里寻找其他蓝牙依赖项。您还可以在那里找到有关如何安装依赖项的说明。对我来说,我在插件项目中添加pod <depdencyname><plugin-project>/example/ios/Podfile。然后添加dependency: <dependencyname><plugin-project>/ios/pubspec

flutter

7
推荐指数
1
解决办法
6742
查看次数

如何在屏幕上听键盘颤振?

我正在构建一个移动应用程序,我想在键盘出现在屏幕上时(即当输入文本字段成为焦点时)删除小部件。

我尝试使用,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

6
推荐指数
2
解决办法
4362
查看次数

如何修改Dart代码Flutter插件?

我正在开发Flutter应用,它使用map_view插件。我想通过修改源代码为插件添加新功能。通过Flutter安装插件后,如何在项目中找到插件的实际源代码?

如何在Flutter中添加插件

map_view插件的依赖项添加到pubspec.yaml下面,然后运行flutter packages get会将其添加到项目中。dev_dependecies:map_view:

dart flutter

5
推荐指数
3
解决办法
2838
查看次数

如何为 Flutter 应用绘制折线图?

目前,我发现了两种可以用来画线的方法,可能可以改进为折线图:

  1. 使用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)

    点线

  2. 使用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 一样可见?您知道可用于绘制折线图的其他更好方法吗?

dart flutter

4
推荐指数
1
解决办法
4041
查看次数

如何在 Flutter 中将 PointMode 传递到 Canvas.drawPoints(..) 中?

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

dart flutter

2
推荐指数
1
解决办法
4617
查看次数

如何更改 Flutter 中自定义绘制的来源?

代码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) 位于绘画框的左下角?

这是屏幕截图: 在此输入图像描述

dart flutter

2
推荐指数
1
解决办法
4142
查看次数

LINQ错误:GroupBy选择上的System.NotSupportedException

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)

.net c# linq

1
推荐指数
1
解决办法
52
查看次数

标签 统计

flutter ×8

dart ×5

.net ×1

asp.net-core ×1

asp.net-core-2.1 ×1

c# ×1

linq ×1