如何更改在 Text 或 TextFormField 或 .. 在 Flutter 中选择文本时出现的气泡颜色?
这是相同的问题,但针对本机代码。
有关于格式化卢比货币(印度卢比 - INR)的问题。
例如,这里的数字表示为:
1
10
100
1,000
10,000
1,00,000
10,00,000
1,00,00,000
10,00,00,000
但无法找到任何可以在印度甲酸盐中分隔逗号编号的参考库。
我有这个有状态的小部件,它使用一个名为的块RecorderBloc
:
class _RecorderScreenWidgetState extends State<RecorderScreenWidget> {
late final RecorderBloc _recorderBloc;
@override
void initState() {
super.initState();
_recorderBloc = serviceLocator.get<RecorderBloc>();
}
@override
void dispose() {
_recorderBloc.add(RecorderEvent.dispose());
super.dispose();
}
@override
Widget build(BuildContext context) {
//.....ommitted code
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我需要在完成后处理该集团的一些成员,这是通过添加处理事件来完成的。
但我不知道将块定义为有状态小部件的成员变量是否是正确的方法?
如果没有,那么如何在添加处理事件dispose()
的方法中获取块的实例?StatefulWidget
我正在使用 CMake 配置我正在创建的 flutter 插件。
我有这个宏可以从 github 存储库下载 zip 文件:
# Download the zipped folder of dart-sdk-api from the dependencies repo
set(dart_sdk_api_zip_url "https://github.com/Haidar0096/image_magick_ffi_deps/raw/master/dart_sdk_api.zip")
message(STATUS "Downloading dart-sdk-api from ${dart_sdk_api_zip_url}")
FetchContent_Declare(
dart_sdk_api
URL ${dart_sdk_api_zip_url}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(dart_sdk_api)
# Include the include folder of dart_sdk_api from the downloaded zip
include_directories(${dart_sdk_api_SOURCE_DIR}/include)
# Create a target from the sources of the downloaded zip and link it to the executable
file(GLOB_RECURSE DART_SDK_API_SOURCES "${dart_sdk_api_SOURCE_DIR}/src/*.c")
add_library(dart_sdk_api STATIC ${DART_SDK_API_SOURCES})
target_link_libraries(image_magick_ffi dart_sdk_api)
Run Code Online (Sandbox Code Playgroud)
如果我为 Windows 构建,它效果很好,并且可以正常下载。
但是,如果我为 android 构建,我会收到此错误并且构建失败:
[ …
Run Code Online (Sandbox Code Playgroud) 所以我在颤振中尝试这段代码:
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int _i = 1;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: MaterialButton(
child: Text('You Pressed Me $_i'),
onPressed: () {
setState(() {
_i++;
print('inside i = $_i');
});
sleep(Duration(seconds: 10));
_i++;
print('outside i = $_i');
}
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
预期行为(运行并按下按钮一次后):按钮显示文本"You Pressed Me 2",
然后变量_i在不影响视觉效果的情况下增加到 3。
实际行为 …