小编sag*_*mar的帖子

在 Flutter 中保存网络图片以离线加载

如何使网络图像在我的应用中离线可用?所以,当我没有网络时,下次可以从缓存中加载它。

我也试过network_to_file_image包和cache network image包,但它对我不起作用。

当我使用缓存网络并且我下次(没有网络)打开应用程序时,图像没有从缓存中再次加载。

这是我在 Flutter 应用程序中使用网络图像包的代码:

CarouselSlider(
          enlargeCenterPage: true,
          autoPlay: true,
          height: 350,
          initialPage: 0,
          items: keyPlans.map((key) {
            File file;
            getData() {
              DirServices().file("loacliamge_${counter++}").then((File data) {
                file = data;
              });
              return file;
            }

            return new CarousalCard(
              image: NetworkToFileImage(file: getData(), url: key, debug: true),
              onPressed: () {
                setState(() {
                  Navigator.push(
                      context,
                      MaterialPageRoute(
                          builder: (context) => ImageView(
                                image: CachedNetworkImageProvider(key),
                                text: appTitle,
                              )));
                });
              },
            );
          }).toList());
Run Code Online (Sandbox Code Playgroud)

network_to_file_image 包总是从网络获取数据。

firebase flutter

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

登录时出现一些错误 PlatformException(ERROR_ADMIN_RESTRICTED_OPERATION, 此操作仅限管理员。, null)

我是 firebase 的新手我试图通过使用 firebase 的匿名身份验证来验证用户,但它给出了以下错误。

这是错误屏幕截图。

示例代码在这里:

验证 dart 文件。

class AuthServices {
  final FirebaseAuth _auth = FirebaseAuth.instance;

  //sign in method.
  Future signningAnon() async {
    try {
      AuthResult result = await _auth.signInAnonymously();
      FirebaseUser user = result.user;
      return user;
    } catch (e) {
      print("There is some error while singing $e");
      return null;
    }
  }
}

Run Code Online (Sandbox Code Playgroud)

主文件:

void main() {
  AuthServices _auth = AuthServices();
  runApp(MaterialApp(
    title: 'chekcing firbase authentication',
    home: Scaffold(
      backgroundColor: Colors.blueAccent,
        appBar: AppBar(
          title: Text("Firbase authentication"),
        ),
        body: Center(
          child: RaisedButton( …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication flutter

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