小编Cha*_*air的帖子

如何在flutter中实现下拉列表?

我有一个我希望在Flutter中作为下拉列表实现的位置列表.我对这门语言很陌生.这就是我所做的.

new DropdownButton(
  value: _selectedLocation,
  onChanged: (String newValue) {
    setState(() {
      _selectedLocation = newValue;
     });
},
items: _locations.map((String location) {
  return new DropdownMenuItem<String>(
     child: new Text(location),
  );
}).toList(),
Run Code Online (Sandbox Code Playgroud)

这是我的项目清单:

List<String> _locations = ['A', 'B', 'C', 'D'];
Run Code Online (Sandbox Code Playgroud)

我收到以下错误.

Another exception was thrown: 'package:flutter/src/material/dropdown.dart': Failed assertion: line 468 pos 15: 'value == null || items.where((DropdownMenuItem<T> item) => item.value == value).length == 1': is not true.
Run Code Online (Sandbox Code Playgroud)

我假设值为_selectedLocationnull.但我正在初始化它.

String _selectedLocation = 'Please choose a location';

dart drop-down-menu flutter

33
推荐指数
9
解决办法
5万
查看次数

Flutter:Cocoapods 'Pods-Runner' 目标具有传递依赖关系,包括静态二进制文件:Flutter.framework

我在运行时收到此错误 pod install

[!] The 'Pods-Runner' target has transitive dependencies that include static binaries: (/Users/me/Documents/flutter/flutter/bin/cache/artifacts/engine/ios/Flutter.framework)
Run Code Online (Sandbox Code Playgroud)

在做了一些研究之后,它说use frameworks!Podfile的问题是造成这个问题的。如果我注释掉use frameworks!我会收到这个错误。知道问题是什么吗?过去三天我一直被困在这里。

ld: framework not found Flutter
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

也根据这里写的内容。添加以下内容Podfile对我也不起作用。这就是我的Podfile样子。

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true' …
Run Code Online (Sandbox Code Playgroud)

xcode dart swift flutter podfile

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

如何在Flutter中禁用FlatButton的启动突出显示?

我有一个FlatButton。单击按钮时,我不希望启动突出显示。我尝试将初始颜色更改为透明,但这没有用。这是我的FlatButton的代码。

Widget button = new Container(
  child: new Container(
    padding: new EdgeInsets.only(bottom: 20.0),
    alignment: Alignment.center,
    child: new FlatButton(
      onPressed: () {
        _onClickSignInButton();
      },
      splashColor: Colors.transparent,
      child: new Stack(
        alignment: Alignment.center,
        children: <Widget>[
          new Image.asset('images/1.0x/button1.png',
          ),
          new Text("SIGN IN",
            style: new TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.bold,
                fontSize: 16.0
              ),
          )
        ],
      ),
    ),
  ),
);
Run Code Online (Sandbox Code Playgroud)

user-interface android ios dart flutter

15
推荐指数
3
解决办法
4033
查看次数

Flutter Xcode:clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

尝试在 Xcode 中构建时出现此错误。我尝试删除派生数据并重新启动 Xcode,但没有任何帮助。

ld: framework not found Flutter
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

这是整个错误日志:

Ld /Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator/Runner.app/Runner normal x86_64
    cd /Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/ios
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk -L/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator -L/Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/ios/Pods/EstimoteSDK -L/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator/Alamofire -L/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator/SwiftKeychainWrapper -L/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator/device_info -L/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator/flutter_secure_storage -L/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator/shared_preferences -L/Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/ios/Flutter -F/Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Products/Debug-iphonesimulator -F/Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/ios/Pods/EstimoteSDK/EstimoteSDK -F/Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/ios/Pods/../../../../flutter/flutter/bin/cache/artifacts/engine/ios -F/Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/ios/Flutter -filelist /Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/chaythanyanair/Library/Developer/Xcode/DerivedData/Runner-efsxwbzqcezyswaezzytcnxazinn/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner.swiftmodule -ObjC -lAlamofire …
Run Code Online (Sandbox Code Playgroud)

xcode dart flutter

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

如何在Flutter中获取当前上下文?

我正在使用底部导航栏。在某个事件触发器上,我需要在当前屏幕上显示一些警报。

这就是我实现底部导航栏的方式。我有四个标签。在这里,当第4个选项卡的图标_isHomeDetected为true且用户单击该图标(即在索引3上)时,我需要更改该图标,无论用户位于哪个选项卡中,我都必须显示一条警报消息。我该如何做?

class LandingScreen extends StatefulWidget {
  static Widget bottomNavigationBar;
  ..
}

class _LandingScreenState extends State<LandingScreen> {
  ...
  StreamSubscription<String> _subscription;
  bool _isHomeDetected = false;

  @override
  void initState() {
    ...
    _subscription = server.messages.listen(onData, onError: onError);
  }
  onData(message) {
    setState(() {
      _isHomeDetected = json.decode(message)["isHomeBeacon"];
    });
  }
  ...
  @override
  Widget build(BuildContext context) {
    LandingScreen.bottomNavigationBar = new BottomNavigationBar(
        ....
    );
    return new Scaffold(
      body: _currentPage,
      bottomNavigationBar: LandingScreen.bottomNavigationBar,
    );
  }

  _navigateToScreens(int currentIndex) {
    List screens = [
      ..
    ];
    setState((){

      if (!_isHomeDetected || …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

通过键入 a+b 来实现集合并集,其中 a 和 b 是两个字典

我想使用python中的类和字典来实现python中设置的内置数据类型。我已经包含了某些基本函数,但我无法执行在其上定义的并集和交集操作。我只想写 c=a+b 其中 a 和 b 是两个字典 c 是另一个字典,其键给出了 'a' 和 'b' 的并集。我尝试了 try 和 except 在我下面的代码中给出的,但我想要一个更好的解决方案。谁能帮我这个?

class My_Set:
      def  __init__(self,listt):
            if listt:
                    self.dictionary={}
                    i=0
                    for x in listt:
                            self.dictionary[x]=len(x)
                            i=i+1
            else:
                    self.dictionary={}

    def is_element(self,element):
            if element in self.dictionary:
                    return True
            else:
                    return False

    def remove(self,element):
            if element in self.dictionary:
                    self.dictionary.pop(element)
            else:
                    print 'element missing'
    def add_element(self,element):
            self.dictionary.update({element:len(element)})
            #return self.dictionary
    def union(self,other):
            self.dictionary.update(other.dictionary)
            return self.dictionary.keys()
Run Code Online (Sandbox Code Playgroud)

python-2.7

5
推荐指数
0
解决办法
155
查看次数

解散Cupertino对话行动Flutter

在使用解释的方法解雇呈现的Cupertino警报对话动作时,我的整个屏幕都会弹出并且警报对话保留在屏幕上.这是我的代码.

if (deviceList.isEmpty){

      var alert = new CupertinoAlertDialog(
        title: new Text("Alert"),
        content: new Text("There was an error signing in. Please try again."),
        actions: <Widget>[
          new CupertinoDialogAction(
              child: const Text('Discard'),
              isDestructiveAction: true,
              onPressed: () { Navigator.pop(context, 'Discard'); }
          ),
          new CupertinoDialogAction(
              child: const Text('Cancel'),
              isDefaultAction: true,
              onPressed: () { Navigator.pop(context, 'Cancel'); }
          ),
        ],
      );
      showDialog(context: context, child: alert);
    }
Run Code Online (Sandbox Code Playgroud)

我在做什么有什么不对吗?我找不到任何其他解决方案来解雇警报对话.请帮忙.

ios android-alertdialog dart flutter

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

Flutter 错误 - 无效的内核二进制格式版本(发现 4,预期 6)

在升级颤动后运行我的应用程序时,我收到此错误。

error: Invalid kernel binary format version (found 4, expected 6)

我目前处于master, I tried switch the branch to测试阶段。还是没有帮助。这是堆栈跟踪。

2018-05-28 15:22:46.214821+0530 Runner[579:57143] ../../third_party/dart/runtime/vm/kernel_binary.cc: 39: error: Invalid kernel binary format version (found 4, expected 6)
2018-05-28 15:22:46.214912+0530 Runner[579:57143] Dumping native stack trace for thread 7c03
2018-05-28 15:22:46.237923+0530 Runner[579:57143]   [0x0000000100fda4a0] dart::Profiler::DumpStackTrace(void*)
2018-05-28 15:22:46.239415+0530 Runner[579:57143]   [0x0000000100fda4a0] dart::Profiler::DumpStackTrace(void*)
2018-05-28 15:22:46.271484+0530 Runner[579:57143]   [0x0000000000000000] Unknown symbol
2018-05-28 15:22:46.273617+0530 Runner[579:57143]   [0x0000000100eda158] dart::kernel::Program::ReadFromBuffer(unsigned char const*, long, bool)
2018-05-28 15:22:46.273681+0530 Runner[579:57143] -- End of DumpStackTrace
Run Code Online (Sandbox Code Playgroud)

这是 的输出flutter …

upgrade dart flutter

4
推荐指数
2
解决办法
3100
查看次数

滚动颤振时表单数据消失

我已经实现了一个带有几个 TextFormFields 的表单。当我滚动表单时,视图外的 TextFormFields 会丢失输入的数据。这里已经发布一个类似的问题。我不知道如何使用 TextEditingController 来保存状态,因为我对 Dart 和 Flutter 还很陌生。我什至尝试在这个github repo 之后使用 FormFieldStatePersistor 。那也没有用。关于如何解决问题的任何想法?

forms textfield dart flutter

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

小部件库'!children.any((Widget child)=> child == null)'抛出的异常:不是真的

嗨我在运行应用程序时收到以下错误可能是什么原因导致问题?

??? EXCEPTION CAUGHT BY WIDGETS LIBRARY ????????????????????????????????????????????????????????????
The following assertion was thrown building Home(dirty, state: _HomeState#f7a67):
'package:flutter/src/widgets/framework.dart': Failed assertion: line 1639: '!children.any((Widget
child) => child == null)': is not true. 

widget stack-trace dart flutter

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

通过Android中的意图访问谷歌翻译应用程序

我正在开发一个Android应用程序,我通过Intents调用Google Translate应用程序.这里描述的过程非常有用,但我无法弄清楚为什么我的应用程序崩溃说"没有找到活动来处理Intent".

提前致谢!

这是我的代码,

public void translate()
{
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, "hello");
    intent.putExtra("key_text_input", "hello");
    intent.putExtra("key_text_output", "");
    intent.putExtra("key_language_from", "en");
    intent.putExtra("key_language_to", "mal");
    intent.putExtra("key_suggest_translation", "");
    intent.putExtra("key_from_floating_window", false);
            new ComponentName(
                "com.google.android.apps.translate",
                "com.google.android.apps.translate.HomeActivity");
    startActivity(intent);

}
Run Code Online (Sandbox Code Playgroud)

这就是我的logcat显示的内容

04-20 07:29:01.647: E/AndroidRuntime(31465): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND flg=0x1 (has clip) (has extras) }
04-20 07:29:01.647: E/AndroidRuntime(31465):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
04-20 07:29:01.647: E/AndroidRuntime(31465):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1423)
04-20 07:29:01.647: E/AndroidRuntime(31465):    at android.app.Activity.startActivityForResult(Activity.java:3388)
04-20 07:29:01.647: E/AndroidRuntime(31465):    at android.app.Activity.startActivityForResult(Activity.java:3349)
04-20 07:29:01.647: E/AndroidRuntime(31465):    at android.app.Activity.startActivity(Activity.java:3584) …
Run Code Online (Sandbox Code Playgroud)

java android google-translate android-intent android-logcat

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

在 Dart 中返回 Future 时为空

我有两个类, auser_api_manager和 a base_api_manager。从user_api_manager我调用该get方法base_api_manager执行 http get 请求并返回一个Future<String>. 该get执行请求,但我不是结果传递给我的user_api_manager班。回调结果始终为空。

这是我的 user_api_manager.dart

static Future<Map<String,dynamic>> forgotPasswordAPI(String email) async{

String url = Constants.BASE_URL + Constants.FORGOT_PASSWORD_URL + email;

await BaseApiManager.get(url: url).then((val) {

  var response = JSON.decode(val);

  var status = response['status'];
  String message = '';
  print(response);
  switch (response['status']) {
    case Constants.SUCCESS:
      message = Constants.SUCCESS_RESPONSE;
      break;
    case Constants.SERVER_ERROR:
      message = Constants.SERVER_ERROR_MESSAGE;
      break;
    case Constants.UNAUTHORISED:
      message = Constants.UNAUTHORISED_MESSAGE;
      break;
  }
  return {'status':status,'message':message};
 }); …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

在Flutter iOS中将jpg图像转换为png图像

如何将从照片库中选择的jpg图像转换为颤动的png图像?

ios dart flutter

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