小编Arn*_*nav的帖子

Flutter - 如何将元素移动到列表末尾?

我有一个在 Flutter 中ListView显示 a 的东西List。我希望该元素移动到列表的末尾并将onTap()其显示在我的列表中?我怎么做?

代码:

List<String> list = ["A", "B", "C", "D", "E", "F"];

void main() {
  return runApp(
    MaterialApp(
      title: 'Flutter New AppDemo',
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: ListView(children: [
            listItem(list[1]),
            divider,
            listItem(list[2]),
            divider,
            listItem(list[3]),
            divider,
            listItem(list[4]),
            divider,
            listItem(list[5]),
            divider,
            listItem(list[0])
          ]),
        ),
      ),
    ),
  );
}

Widget divider = Container(height: 1, color: Colors.black);

Widget listItem(String text) {
  return Container(
    height: 100,
    padding: EdgeInsets.only(left: 16),
    child: Align(
      alignment: Alignment.centerLeft,
      child: …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

如何在 Flutter 中从 GoogleSignIn 获取附加范围?

我有一个方法用来获取用户的基本信息,如生日、性别和电话号码,我现在知道如何在 Flutter 中实现它?

 void signInWithGoogle(context) async {
final GoogleSignIn _googleSignIn = GoogleSignIn();
    try {
      final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
      final GoogleSignInAuthentication googleAuth =
          await googleUser.authentication;
      final AuthCredential credential = GoogleAuthProvider.credential(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );
      final User user = (await _auth.signInWithCredential(credential)).user;
      
    } catch (error) {
      print('Google error: $error');
    }
  }
Run Code Online (Sandbox Code Playgroud)

dart google-oauth google-signin flutter

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

How to call arguments from Flutter in Swift native code?

I am trying to use PlatformViews in Flutter to show Swift code natively in my Flutter app, however my app is crashing with my current code.

This is my AppDelegate currently where I am invoking my method channel:

import Foundation

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, TJPlacementDelegate {
    var p = TJPlacement()
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        let channelName = "NativeView"
        let rootViewController : FlutterViewController = window?.rootViewController as! FlutterViewController
        let methodChannel = …
Run Code Online (Sandbox Code Playgroud)

ios dart swift flutter

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

Flutter - 无法在初始化程序中访问实例成员“remoteConfig”

我试图remoteConfig在我的内部调用一个字符串List

    class HomeModel {
      final RemoteConfig remoteConfig; //HomeModel() is called in Home() and fetches the param from there
      HomeModel({this.remoteConfig});
    
    List taskList = [
      { 
        'title': 'Hello',
        'url': remoteConfig.getString(''),
      },
    ];
}
Run Code Online (Sandbox Code Playgroud)

但是,它向我显示了错误-

The instance member 'remoteConfig' can't be accessed in an initializer
Run Code Online (Sandbox Code Playgroud)

dart firebase flutter firebase-remote-config

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

Flutter:Hive 方法“get”方法在 null 上调用

我试图在我的应用程序中使用 Hive 作为 Flutter 中共享首选项的替代方案。但是,我不断收到一条错误消息:

I/flutter ( 4004): The method 'get' was called on null.
I/flutter ( 4004): Receiver: null
I/flutter ( 4004): Tried calling: get("counter", defaultValue: 0)

E/flutter ( 4004): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] 
Unhandled Exception: HiveError: This should not happen. Please open an 
issue on GitHub.
Run Code Online (Sandbox Code Playgroud)

我遵循了pub.dev文档中显示的所有步骤,但是,我没有使用任何步骤TypeAdapters,我只是尝试使用int. 这是我的实现:

var box = Hive.box('box');
int counter;
        
 void initHive() async {
 await openBox();
 getCounter();  //Updated code
 }

Future openBox() async {
var dir = await getApplicationDocumentsDirectory();
Hive.init(dir.path);
box …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-hive

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

如何在Flutter中突出显示特定字母的文本?

我试图突出显示两个字母“Rs”,任何特殊字符,如“% 或 !” 以及 1234 等数字。

我已经从这个问题中得到了一半的答案 -如何在 Flutter 中突出显示文本? 但我不知道如何编辑字母,因为我是正则表达式的新手?

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String str = "Hey I'm 1234 …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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