小编Kod*_*ata的帖子

Flutter Web Firebase TypeError:dart.global.firebase.firestore 不是函数

我正在尝试在我的 flutter web 项目中使用 Firebase。
但是应用程序无法使用此消息运行。

TypeError: dart.global.firebase.firestore is not a function
at Object.firestore$ [as firestore] 
Run Code Online (Sandbox Code Playgroud)

我的index.html看起来像这样。

  <script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
  <script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-analytics.js"></script>

  <script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "MY_API_KEY",
      authDomain: "MY_AUTHDOMAIN",
      databaseURL: "MY_URL",
      projectId: "MY_ID",
      storageBucket: "MY_BUCKET",
      messagingSenderId: "MY_ID",
      appId: "MY_APPID",
      measurementId: "MY_ID"
    };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
    firebase.analytics();
  </script>
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?
谢谢!!

firebase flutter-web

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

Android 上的 fluttercompileSdkVersion 和 targetSdkVersion

我想知道,如果我希望我的应用程序支持 api 级别为 9.0(Pie) 的新 Android 手机,我应该为compileSdkVersiontargetSdkVersionon设置什么值build.gradle。有人知道这件事吗?

android flutter

25
推荐指数
3
解决办法
7万
查看次数

颤动检测杀死应用程序

我想知道是否有可能检测到杀死应用程序.让我们说在聊天应用程序中,当用户使用onWillPop离开聊天室时,我能够获得时间戳.但是,如果用户直接从聊天室中删除应用程序,它将不会被解雇.那么有没有办法检测到它?
或者任何建议以不同的方式获得时间戳?

flutter

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

Flutter VideoPlayerController“在构建过程中调用了 setState() 或 markNeedsBuild()。”

我正在播放视频并且没有问题,但是当导航到另一个页面时,控制台会这样说。
我尝试了我想出的所有方法,例如检查是否有效,mounted但它们都不起作用。
我错过了什么?有谁知道如何修复?

flutter:在为 VideoPlayerController 调度通知时抛出以下断言:
flutter: setState() 或 markNeedsBuild() 在构建期间调用。
flutter: 这个 VideoProgressIndicator 小部件不能被标记为需要构建,因为框架是
flutter: 已经在构建小部件的过程中。小部件可以在
flutter: build 阶段被标记为需要构建,仅当其祖先之一当前正在构建时。允许此异常是因为
flutter: 框架在子级之前构建父小部件,这意味着脏后代将始终是
flutter: 构建的。否则,框架可能不会在此构建阶段访问此小部件。
flutter:调用 setState() 或 markNeedsBuild() 的小部件是:
flutter: VideoProgressIndicator(state: _VideoProgressIndicatorState#09ac7)

代码:

class _VideoScreenState extends State<VideoScreen> {
      VideoPlayerController _controller;
      FadeAnimation imageFadeAnim =
          new FadeAnimation(child: const Icon(Icons.play_arrow, size: 100.0));
      VoidCallback listener;
      bool _isPlaying = false;
      List<String> videos = [
        'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4',
      ];

      _VideoScreenState() {
        listener = () {
          if (mounted) setState(() {});
        };
      }

      Future _videoOnTap() async {
        if …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

Flutter 如何在视频上保存(重新编码)文本叠加

我想实现像 instagram 故事(仅文本叠加)这样的功能。我能够让用户可以在视频上添加一些文本,如下面的屏幕截图(右上角的图标开始输入文本,左上角刚回到上一页)。在用户输入一些文本后,我想将视频存储到Firebase storage. 但问题是我怎样才能在视频中保留这段文字?有没有办法重写用户放置的文本覆盖文件(重新编码)?或者我是否必须将文本信息存储到数据库中然后每次都获取并显示?

在此处输入图片说明

encode overlay flutter

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

Flutter- Firebase 存储上传视频

我想上传视频Firebase Storage。我是这样试的。

 Future uploadToStorage() async {
    try {
      final DateTime now = DateTime.now();
      final int millSeconds = now.millisecondsSinceEpoch;
      final String month = now.month.toString();
      final String date = now.day.toString();
      final String storageId = (millSeconds.toString() + uid);
      final String today = ('$month-$date'); 

      final file = await ImagePicker.pickVideo(source: ImageSource.gallery);

      StorageReference ref = FirebaseStorage.instance.ref().child("video").child(today).child(storageId);
      StorageUploadTask uploadTask = ref.putFile(file);

      Uri downloadUrl = (await uploadTask.future).downloadUrl;

        final String url = downloadUrl.toString();

     print(url);

    } catch (error) {
      print(error);
      }

    }
Run Code Online (Sandbox Code Playgroud)

但问题是我上传了 3 个不同的视频。一个来自真实设备,其他来自 Ios 模拟器,只有一个来自模拟器的视频被识别为这样的视频。

图像在这里

文件:/Users/Daibaku/Library/Developer/CoreSimulator/Devices/C99406E4-12F3-480A-82A6-F6144ADD21AB/data/Containers/Data/Application/23E82E18-9293-4EEB-AEEA-6A7BB773F2F2-6A7BB773F2F2-6A7BB773F2F2-12F3-480A-82A6-F6144ADD21AB …

firebase flutter firebase-storage

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

由于底部导航栏,Flutter 底部工作表不可见

我正在尝试显示底部工作表并让用户选择。我喜欢这样

showModalBottomSheet(
  context: context,
  builder: (builder) {
   return Column(
     mainAxisSize: MainAxisSize.min,
      children: <Widget>[
       new ListTile(
        leading: new Icon(Icons.image),
        title: new Text('From gallary'),
       ),
       new ListTile(
        leading: new Icon(Icons.camera_alt),
        title: new Text('Take video'),
       ),
      ],
    );
   });
Run Code Online (Sandbox Code Playgroud)

然而,由于底部导航栏,它几乎不可见。它看起来像这样。图片 我想实现从底部导航栏的顶部边缘出现的最小高度底部工作表。我怎样才能做到这一点?

flutter

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

Flutter Firestore分页

我正在尝试使用进行分页,Firestore并阅读了文档,并在Swift

let first = db.collection("cities")
    .order(by: "population")
    .limit(to: 25)

first.addSnapshotListener { (snapshot, error) in
    guard let snapshot = snapshot else {
        print("Error retrieving cities: \(error.debugDescription)")
        return
    }

    guard let lastSnapshot = snapshot.documents.last else {
        // The collection is empty.
        return
    }

    // Construct a new query starting after this document,
    // retrieving the next 25 cities.
    let next = db.collection("cities")
        .order(by: "population")
        .start(afterDocument: lastSnapshot)

    // Use the query for pagination.
    // ...
}
Run Code Online (Sandbox Code Playgroud)

只是为了练习,我尝试获取三个文档,如果轻按按钮,则再获取一个文档。

 Firestore.instance.collection('user').where('name', isEqualTo: 'Tom').orderBy('age').limit(3).getDocuments().then((snapshot) …
Run Code Online (Sandbox Code Playgroud)

flutter google-cloud-firestore

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

Flutter 如何获取最后一个 PageView 滚动方向

我正在尝试使用PageView. 我能够像这样得到方向。

代码:

 PageController _controller;

  @override
  void initState() {
    _controller = new PageController()..addListener(_listener);
    super.initState();
  }

  _listener() {
    if (_controller.position.userScrollDirection == ScrollDirection.reverse) {
      print('swiped to right');
    } else {
      print('swiped to left');
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(),
      body: PageView.builder(
          itemCount: 10,
          controller: _controller,
          itemBuilder: (context, index) {
            return new Center(child: Text('item ${++index}'));
          }),
    );
  }
Run Code Online (Sandbox Code Playgroud)

但是,由于滚动还没有结束,print方法会多次返回。在当前页面完全切换到下一页后,我有什么办法可以得到这个吗?

flutter:向右
滑动
flutter:向右
滑动
flutter:向右
滑动
flutter:向右
滑动
flutter:向右
滑动 flutter:向右滑动 flutter:向右滑动 flutter:向右滑动 …

flutter

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

列表视图内的Flutter GridView

我想构建像Ios应用商店这样的设计,如下图所示。我想要实现的是有5个顶级类别,每个类别都有显示图像的网格。我尝试过这样。

像这样

return new Scaffold(
  backgroundColor: Colors.white,
  appBar: buildBar(context),
  // wrap in gesture to dismiss keyboard
  body: new GestureDetector(
    behavior: HitTestBehavior.opaque,
    onPanDown: (detail) {
      FocusScope.of(context).requestFocus(new FocusNode());
    },
    child: new ListView(
      shrinkWrap: true,
      children: <Widget>[
        new Container(
          decoration: new BoxDecoration(color: Colors.grey[400]),
          child: new Column(
            children: <Widget>[
              new SizedBox(height: 15.0),
              new Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new Icon(Icons.invert_colors,
                      color: Colors.red, size: 45.0),
                  new Text('Top 5',
                      style: new TextStyle(
                          color: Colors.white,
                          fontSize: 25.0,
                          fontWeight: FontWeight.bold)),
                ],
              ),
              new SizedBox(height: 15.0),
            ],
          ),
        ),
        new …
Run Code Online (Sandbox Code Playgroud)

flutter

5
推荐指数
4
解决办法
8510
查看次数