答案 0 :(得分:12)
cursorColor
现在已弃用,ThemeData
使用它代替(适用于 iOS 和 android):
MaterialApp(
title: "Rate your Colleagues",
theme: ThemeData(
textSelectionTheme: TextSelectionThemeData(
cursorColor: darkPrimarySwatchColor,
selectionColor: darkPrimarySwatchColor,
selectionHandleColor: darkPrimarySwatchColor,
),
),
home: SplashScreen(),
);
答案 1 :(得分:6)
Flutter 已更新,现在 cursorColor 使用如下:
ThemeData(
...
textSelectionTheme: TextSelectionThemeData(
cursorColor: Colors.blue, //thereby
),
),
如果它对你有帮助,请:)
答案 2 :(得分:2)
您可以使用:
TextField( cursorColor: Colors.red),
答案 3 :(得分:1)
这在iOS和Android上均正常运行
TextField(cursorColor: Colors.white)
但是,如果您希望将其设置为主题,那么我找到了解决方法here:
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
MaterialApp(
title: "Rate your Colleagues",
theme: ThemeData(
// for iOS
cupertinoOverrideTheme: CupertinoThemeData(
primaryColor: Colors.red,
),
// for others(Android, Fuchsia)
cursorColor: Colors.red,
home: SplashScreen(),
);
...
答案 4 :(得分:1)
我必须将true
设置为ThemeData _defaultDarkTheme = ThemeData.dark();
ThemeData _darkTheme = initializeDefaultLineHeight(ThemeData(
brightness: Brightness.dark,
// How to set cursor color for TextFormField
useTextSelectionTheme: true,
textSelectionTheme: _defaultDarkTheme.textSelectionTheme.copyWith(
cursorColor: Colors.grey[600]),
并为我的自定义深色主题设置textSelectionTheme:
server.cpp
答案 5 :(得分:0)
对于问题1,您可以像下面这样调用cursorColor
时为theme
属性设置MaterialApp
new MaterialApp(
title: "Flutter App",
theme: ThemeData(
cursorColor: Colors.red,
home: HomeScreen(),
)
答案 6 :(得分:0)
对齐Flutter布局小部件:
阅读更多:https://flutter.dev/docs/development/ui/layout#aligning-widgets
这是一个示例示例:
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(
//Question 1
cursorColor: Colors.green,
),
home: Scaffold(
body: Column(
// Qurestion 2
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Center(
child: Container(
child: Text("Hello World ! "),
),
),
],
)),
);
}
}
答案 7 :(得分:0)
将myDF.set_index('animals')['count'].to_frame().T.plot.barh(stacked=True)
放在TextFormField中