小编Cha*_* Jr的帖子

如何将ListView添加到Flutter中的列?

我正在尝试为我的Flutter应用程序构建一个简单的登录页面.我已经成功构建了TextFields和Login/Signin按钮.我想添加一个水平ListView.当我运行代码时,我的元素消失,如果我没有ListView,它再次没问题.我该怎么做才能正确?

return new MaterialApp(
        home: new Scaffold(
          appBar: new AppBar(
            title: new Text("Login / Signup"),
          ),
          body: new Container(
            child: new Center(
              child: new Column(
              mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new TextField(
                    decoration: new InputDecoration(
                      hintText: "E M A I L    A D D R E S S"
                    ),
                  ),
                  new Padding(padding: new EdgeInsets.all(15.00)),
                  new TextField(obscureText: true,
                    decoration: new InputDecoration(
                      hintText: "P A S S W O R D"
                    ),
                    ),
                  new Padding(padding: new EdgeInsets.all(15.00)),
                  new TextField(decoration: new InputDecoration(
                    hintText: "U …
Run Code Online (Sandbox Code Playgroud)

dart flutter

60
推荐指数
13
解决办法
3万
查看次数

如何在Dart/Flutter中使用另一个文件的功能?

我有一个Flutter应用程序,我正在使用flutter_web_view包.我在几个不同的文件中使用它,并且很乐意创建自己的文件,并且只需在我的应用程序中的任何地方使用_launchwebview函数进行引用,因为需要几行代码才能使其工作.我知道如何引用文件和传递信息,但不知道方法/函数.这是班级代码......

import 'package:flutter/material.dart';
import 'package:flutter_web_view/flutter_web_view.dart';

class ShopClass extends StatefulWidget {
  @override
  ShopClassState createState() => new ShopClassState();
}

class ShopClassState extends State<ShopClass> {
  String _redirectedToUrl;
  FlutterWebView flutterWebView = new FlutterWebView();
  bool _isLoading = false;

  @override
  initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Widget leading;
    if (_isLoading) {
      leading = new CircularProgressIndicator();
    }
    var columnItems = <Widget>[
      new MaterialButton(
          onPressed: launchWebViewExample, child: new Text("Launch"))
    ];
    if (_redirectedToUrl != null) {
      columnItems.add(new Text("Redirected to $_redirectedToUrl"));
    }
    var app = new MaterialApp( …
Run Code Online (Sandbox Code Playgroud)

methods function dart flutter

23
推荐指数
4
解决办法
3万
查看次数

如何使用Flutter将BASE64字符串转换为Image?

我正在将保存在Firebase数据库中的图像转换为Base64,并希望对其进行解码和编码.我研究了类似的问题,但我仍然遇到错误.这是我到目前为止的情况?

var image1 = String;

var pic = event.snapshot.value['image'];
var photo = BASE64.decode(pic);
image1 = photo;
Run Code Online (Sandbox Code Playgroud)

我收到以下错误...

A value of type "List<int>" cannot be assigned to a variable of type "Type"

如果你能提供一个反向过程来将图像编码到Base64中,那么它们可以保存回Firebase,这将是值得赞赏的.

***更新

这是我的更新代码,仍然会抛出错误.

image1 = event.snapshot.value['image'];
var image = BASE64.decode(image1.toString());
new Image.memory(image),
Run Code Online (Sandbox Code Playgroud)

错误是......

FormatException: Invalid Length must be a multiple of 4

base64 image list converter flutter

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

如何访问Flutter Back按钮功能?

我想在用户返回上一页之前提供AdWords插页式广告.按下返回按钮后如何执行此操作?

function dart flutter

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

如何使用Swift显示数组的唯一元素?

我有一个公式重新调整数组作为例子var Array = [a,s,d,s,f,g,g,h,e].我想要的是运行一个for循环或其他一些让我回来的选项a,s,d,f,g,h,e- 只有唯一的值.我怎么能用ios Swift做到这一点?

arrays sorting filter nsarray swift

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

Flutter AndroidManifest 错误

我刚刚将一个在早期版本的 Flutter 和 Android Studio 中构建的项目移植到新机器和更新的软件上。尝试在模拟器中构建我的 Android 项目时,我收到以下错误...

  • 出了什么问题:任务 ':app:processDebugManifest' 执行失败。

    清单合并失败:属性 meta-data#android.support.VERSION@value value=(25.4.0) from [com.android.support:appcompat-v7:25.4.0] AndroidManifest.xml:28:13-35 也是目前在 [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0)。建议:将 'tools:replace="android:value"' 添加到 AndroidManifest.xml:26:9-28:38 的元素以覆盖。

这就是我的清单的样子......

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.myfavkpopflutterexample"
 xmlns:tools="http://schemas.android.com/tools"
>

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />

<!-- The INTERNET permission is required for development. Specifically,
     flutter needs it to communicate with the running application
     to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases …
Run Code Online (Sandbox Code Playgroud)

android metadata android-manifest flutter

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

如何从网络映像中获取Flutter Uint8List?

我正在尝试将网络映像转换为文件,并且该文件的第一部分是将其转换为Uint8List。这是我对其中的一张资产图片执行的操作...

      final ByteData bytes = await rootBundle.load('assests/logo');
      final Uint8List list = bytes.buffer.asUint8List();

      final tempDir = await getTemporaryDirectory();
      final file = await new File('${tempDir.path}/image.jpg').create();
      file.writeAsBytesSync(list);
Run Code Online (Sandbox Code Playgroud)

我该怎么做 Image.network(imageUrl.com/image)

byte image file dart flutter

6
推荐指数
3
解决办法
5261
查看次数

如何在ios Swift中创建一个类似于半径50英里的MKCoordinate区域?

我正在尝试使用 CLLocation 创建一个类似于圆半径的区域。我了解半径逻辑以及它是如何以米为单位测量的,但在 MKCoordinate 区域上以及 delta 和 lat delta 转换为面积的长度不是很清楚。我想要一个 75 英里的区域。这是我的代码....

let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
Run Code Online (Sandbox Code Playgroud)

如果您能提供一个解释,而不仅仅是一个简短的答案,我们将不胜感激。

geolocation mkcoordinateregion cllocationmanager swift

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

如何从List中映射Flutter JSON字符串?

我已成功将我的响应打印为来自我的YouTube JSON网址的字符串,但当我尝试序列化"项目"时,我收到以下错误 Unhandled exception: type 'List' is not a subtype of type 'Map' of 'json' where List is from dart:core Map is from dart:core

这是我的代码......

class CardInfo {
  //Constructor
  String id;
  String description;
  String role;
  //int score;

  CardInfo.fromJson(Map json) {
    this.id = json['vieoId'];
    this.description = json['description'];
    this.role = json['title'];
    //this.score = json['score'];
  }
}

Future getData() async {
    String url = 'YouTube url';
    var httpClient  = createHttpClient();
    var response = await httpClient.get(url);
    Map data = JSON.decode(response.body);
    //String ip = data['items']; …
Run Code Online (Sandbox Code Playgroud)

serialization json dart flutter

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

Row抛出错误的相同颤振窗口小部件?

我在一行中生成2个FloatingActionButtons.路由到其文件时出现以下错误...

在调度程序回调期间抛出以下断言:有多个英雄在子树中共享相同的标记.在每个子树哪位大侠要动画(通常是PageRoute子树),每个英雄必须有一个唯一非空标签.在这种情况下,多个英雄的标签为"Instance of'Object'".

这是我的代码......

new Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                new FloatingActionButton(
                    child: new Icon(Icons.remove), onPressed: _decline),
                new Padding(padding: new EdgeInsets.all(10.0)),
                new Text(
                  _count.toString(),
                  style: new TextStyle(
                      fontSize: 40.0,
                      fontWeight: FontWeight.bold,
                      color: Colors.black),
                ),
                new Padding(padding: new EdgeInsets.all(10.0)),
                new FloatingActionButton(
                    child: new Icon(Icons.add), onPressed: _increment),
              ],
            )
Run Code Online (Sandbox Code Playgroud)

这是我如何路由到我的文件...

Navigator.push(context, new MaterialPageRoute(builder: (_) => new Video.VideoPage()));

当我注释掉第一个FloatingActionButton时它工作正常.只有当它们都被使用时它才会出错.如果重要的话,我Row也是Column小部件的孩子.

routes row widget flutter

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