我有一个在 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) 我有一个方法用来获取用户的基本信息,如生日、性别和电话号码,我现在知道如何在 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) 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) 我试图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) 我试图在我的应用程序中使用 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) 我试图突出显示两个字母“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)