我有一个使用 Stateless Widget 制作的屏幕。
我想在加载屏幕或创建无状态小部件时运行一些代码。
在 android 中,我们可以在 onCreate() 方法中执行此操作。
即 flutter 中是否有相当于 onCreate() 的东西。
我正在使用 flutter 开发一个应用程序。
在下面的代码中我收到此警告。
无法推断函数文字的类型,因为该文字有一个块作为其主体。
var onSelectSunriseNotification = () {
print('Sunrise Notification clicked');
};
Run Code Online (Sandbox Code Playgroud) 是否可以在飘动中创建带有渐变边框的轮廓(透明)按钮?我尝试在BorderSide样式中使用LinearGradient,但不允许这样做。
我试图在flutter应用程序中集成webview。在示例中添加代码后,页面正常加载,但是当我单击页面中的输入框时,没有弹出软键盘,
默认情况下,当 a 发生状态更改时StatefulWidget,状态转换没有动画。有什么办法可以吃一些吗?例如,在转换时,我想淡出旧状态并淡入新状态。
我知道如何在路线之间添加过渡动画,但找不到在状态转换之间执行此操作的方法。
有一个例子,让我们使用 Flutter 默认应用程序:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
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> {
int _counter …Run Code Online (Sandbox Code Playgroud) 我正在使用 flutter、dart 制作应用程序。
我正在使用一些 api 使用经度和纬度来获取日出时间。
但我得到的数据在 UST 时区。
我想将其转换为本地时区。
简而言之,我有位置,我想将时间转换为当地时间。
例如。我有时间“3:02:32 PM”在UST并且我有位置(比如印度是 +5:30)所以我想得到时间,在这种情况下是“8:32:32 PM”
我正在使用颤振fluro进行路由。我只能传递一个参数并且能够在页面中访问它。如何发送多个项目?
这是我的使用方法
router.define('/about/:id', handler: new Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
return new AboutPage(params["id"][0]);
}));
Run Code Online (Sandbox Code Playgroud)
我这样称呼这个
Navigator.pushNamed(context, "/about/23");
Run Code Online (Sandbox Code Playgroud)
现在我想传递多个这样的变量
Navigator.pushNamed(context, "/about/23/newdata");
我试图像这样访问这个新数据
router.define('/about/:id/:str', handler: new Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
return new AboutPage(params["id"][0], params["id"][1]);
}));
Run Code Online (Sandbox Code Playgroud)
它不起作用。它给了我这样的错误
Could not find a generator for route RouteSettings("/about/23/newdata", null) in the
Run Code Online (Sandbox Code Playgroud)
颤振:_WidgetsAppState。
Webview问题在Flutter中出现错误
[ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
PlatformException(error, Trying to create a platform view of unregistered type: plugins.flutter.io/webview, null)
Run Code Online (Sandbox Code Playgroud)
我想在我的应用程序中实现缓存,以便数据仅加载一次,然后每次重新加载页面时,不必再次获取数据
下面的代码是一个页面块。
import 'dart:async';
import 'dart:collection';
import 'package:eightoeight/eightoeight.dart';
import 'package:rxdart/rxdart.dart';
class AlbumBloc {
DatabaseClient db;
Stream<List<AudioTrack>> get albums => _albumSubject.stream;
final _albumSubject = BehaviorSubject<UnmodifiableListView<AudioTrack>>();
final modeController = StreamController<int>();
Sink<int> get mode => modeController.sink;
var _albums = <AudioTrack>[];
AlbumBloc() {
create();
}
void create() async {
if (db == null) {
this.db = new DatabaseClient();
await this.db.create();
}
modeController.add(0);
modeController.stream.listen(onData);
}
void onData(int num) {
if (num == null) {
_updateSongs(0).then((_) {
_albumSubject.add(UnmodifiableListView(_albums));
});
} else if (num == 1) { …Run Code Online (Sandbox Code Playgroud) 有人对如何在 Flutter 中将文本“Connecting”变为斜体有建议吗?
'字符串标题 = '正在连接';'
我尝试过 TextStyle 的变体,但无法开始工作。