小编the*_*imm的帖子

Flutter Format Time of Day 从时间选择器开始

我正在尝试从我的颤振应用程序中的时间选择器中格式化选定的时间。我不知道为什么,但事实证明这比它应该的要困难得多。我想要达到的最终结果是小时:分钟或下午 5:00。用户从时间选择器小部件中选择时间后,这将显示在框容器中。我有一个名为 'timeFormater()' 的方法,它将格式化选择的时间,但是当我运行我的代码时,我收到错误'flutter: type 'TimeOfDay' is not a subtype of type 'Widget'。是否有更简单的方法/方法来格式化 TimeOfDay()?

我的代码:

      import 'package:flutter/material.dart';
    import 'package:flutter/cupertino.dart';
    import 'package:intl/intl.dart';
    import 'package:auto_size_text/auto_size_text.dart';
    import 'dart:io' show Platform;

    class DateTimePicker extends StatefulWidget {
      @override
      _DateTimePickerState createState() => _DateTimePickerState();
    }

    class _DateTimePickerState extends State<DateTimePicker> {
      DateTime _date = new DateTime.now();
      TimeOfDay _time = new TimeOfDay.now();
      Duration initialtimer = new Duration();
      DateTime _datePicked;
      TimeOfDay _timePicked;


      @override
      void initState() {
       // timeController.addListener(_time);

      }

      @override
      Widget build(BuildContext context) {
        return Container(
          child: Column( …
Run Code Online (Sandbox Code Playgroud)

widget timeofday flutter

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

Circle Profile Image on Sliver Appbar

I'm trying to include a circle profile image button on my sliver app bar but the sliver app bar isn't quite rendering it right. This is what i'm getting, how can I achieve a circle profile image on a sliver app bar?

在此处输入图片说明

My Code:

    @override
  Widget build(BuildContext context) {
    return Scaffold(
       body: CustomScrollView(
          slivers: <Widget>[
            SliverAppBar(
              title: Text('Home'),
              leading: Container(),
              actions: <Widget>[
                IconButton(
                    icon: Icon(Icons.notifications),
                    onPressed: () {}),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: InkWell(
                    child: Container(
                      height: 30,
                      width: 30, …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-sliver flutter-layout

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

Flutter 从 Future&lt;bool&gt; 方法返回 bool 类型

这个问题与非常相似,但解释对我的用例并没有太大帮助。我有一个 Future 类型的方法,它返回一个 bool 执行对 cloud firestore 的查询,以检查用户输入的用户名是否已经存在。

static Future<bool> doesNameAlreadyExist(String value, String 
name) async{
final QuerySnapshot result = await Firestore.instance
  .collection('users')
  .where(value, isEqualTo: name)
  .limit(1)
  .getDocuments();
  final List<DocumentSnapshot> documents = result.documents;
 return  documents.length == 1;
Run Code Online (Sandbox Code Playgroud)

}

当我在这里调用该方法时,我收到此错误 在此处输入图片说明

有没有办法从 Future 获取返回类型的 bool

dart flutter google-cloud-firestore

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

在颤动的警报对话框中添加下拉菜单

当我尝试在我的 flutter 应用程序的警报对话框中添加带有日期和时间选择器的下拉菜单时,我遇到了 UI 呈现问题。一段时间以来,我一直在尝试解决此问题,但无济于事。这是我得到的输出:

图像输出

我的代码:

    import 'dart:async';

   import 'package:flutter/material.dart';
   import 'package:firebase_database/firebase_database.dart';
   import 'package:test_prep/utils/Reminder.dart';
   import 'package:intl/intl.dart';

 class RemindersPage extends StatefulWidget {
 @override
_RemindersPageState createState() => _RemindersPageState();
 }

class _RemindersPageState extends State<RemindersPage> {
final TextEditingController _titleController = new 
TextEditingController();

List<DropdownMenuItem<Future>> dateDrop = [];
List<DropdownMenuItem<Future>> timeDrop = [];
int selected = null;


void loadDateData() {
dateDrop = [];
dateDrop.add(new DropdownMenuItem(
  child: new Text('Pick Date'),
  value: _selectedDate(context),
));
}

void loadTimeData() {
 timeDrop = [];
 timeDrop.add(new DropdownMenuItem(
  child: new Text('Pick a Time'), …
Run Code Online (Sandbox Code Playgroud)

android-alertdialog dart drop-down-menu android-studio flutter

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