时间:2024-12-26 20:07
人气:
作者:admin
本文更新于2024-12-26,使用Flutter 3.3.3。
官方文档:https://api.flutter.dev或https://api.flutter-io.cn
目录import 'dart:ui';
import 'package:flutter/animation.dart';
Flutter支持120FPS(Frames Per Second,帧每秒)的帧率。
可用于实现动画叠加,即交错动画。
AnimatedBuilder({
Key? key,
required Listenable animation,
required TransitionBuilder builder,
Widget? child
})
一方面生成动画的值,另一方面用来得知动画的状态。但是无法通过它得知动画的具象,且和渲染无关。
Animation()
管理Animation。
继承
Object > Listenable > Animation<double> > AnimationController
构造函数
AnimationController({
double? value,
Duration? duration,
Duration? reverseDuration,
String? debugLabel,
double lowerBound = 0.0,
double upperBound = 1.0,
AnimationBehavior animationBehavior = AnimationBehavior.normal,
required TickerProvider vsync
})
属性
方法
ColorTween({Color? begin, Color? end})
Curve()
将动画的过程抽象成非线性曲线。
CurvedAnimation({
required Animation<double> parent,
required Curve curve,
Curve? reverseCurve
})
可以用来定义动画在执行上的时间线顺序。
Interval(
double begin,
double end,
{
Curve curve = Curves.linear
}
)
Locale(String _languageCode, [String? _countryCode])
定义正在执行动画的对象所使用的数据范围内的值。
Tween({
T? begin,
T? end
})
import 'package:flutter/cupertino.dart';
与Material的类比关系:
| Cupertino | Material |
|---|---|
| CupertinoApp | MaterialApp |
| CupertinoPageScaffold | Scaffold |
| CupertinoTabScaffold | Scaffold |
| CupertinoNavigationBar | AppBar |
| CupertinoTabBar | BottomNavigationBar |
| CupertinoAlertDialog | AlertDialog |
| CupertinoSlider | Slider |
CupertinoActionSheet({
Key? key,
Widget? title,
Widget? message,
List<Widget>? actions,
ScrollController? messageScrollController,
ScrollController? actionScrollController,
Widget? cancelButton
})
CupertinoActionSheetAction({
Key? key,
required VoidCallback onPressed,
bool isDefaultAction = false,
bool isDestructiveAction = false,
required Widget child
})
CupertinoActivityIndicator({
Key? key,
Color? color,
bool animating = true,
double radius = _kDefaultIndicatorRadius
})
CupertinoAlertDialog({
Key? key,
Widget? title,
Widget? content,
List<Widget> actions = const <Widget>[],
ScrollController? scrollController,
ScrollController? actionScrollController,
Duration insetAnimationDuration = const Duration(milliseconds: 100),
Curve insetAnimationCurve = Curves.decelerate
})
CupertinoApp({
Key? key,
GlobalKey<NavigatorState>? navigatorKey,
Widget? home,
CupertinoThemeData? theme,
Map<String,
Widget Function(BuildContext)> routes = const <String, WidgetBuilder>{},
String? initialRoute,
RouteFactory? onGenerateRoute,
InitialRouteListFactory? onGenerateInitialRoutes,
RouteFactory? onUnknownRoute,
NotificationListenerCallback<NavigationNotification>? onNavigationNotification,
List<NavigatorObserver> navigatorObservers = const <NavigatorObserver>[],
TransitionBuilder? builder,
String title = '',
GenerateAppTitle? onGenerateTitle,
Color? color,
Locale? locale,
Iterable<LocalizationsDelegate>? localizationsDelegates,
LocaleListResolutionCallback? localeListResolutionCallback,
LocaleResolutionCallback? localeResolutionCallback,
Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')],
bool showPerformanceOverlay = false,
bool checkerboardRasterCacheImages = false,
bool checkerboardOffscreenLayers = false,
bool showSemanticsDebugger = false,
bool debugShowCheckedModeBanner = true,
Map<ShortcutActivator, Intent>? shortcuts,
Map<Type, Action<Intent>>? actions,
String? restorationScopeId,
ScrollBehavior? scrollBehavior,
@Deprecated(
'Remove this parameter as it is now ignored. '
'CupertinoApp never introduces its own MediaQuery; the View widget takes care of that. '
'This feature was deprecated after v3.7.0-29.0.pre.'
)
bool useInheritedMediaQuery = false})
CupertinoButton({
Key? key,
required Widget child,
EdgeInsetsGeometry? padding,
Color? color,
Color disabledColor = CupertinoColors.quaternarySystemFill,
double? minSize = kMinInteractiveDimensionCupertino,
double? pressedOpacity = 0.4,
BorderRadius? borderRadius = const BorderRadius.all(Radius.circular(8.0)),
AlignmentGeometry alignment = Alignment.center,
Color? focusColor,
FocusNode? focusNode,
ValueChanged<bool>? onFocusChange,
bool autofocus = false,
required VoidCallback? onPressed
})
color时生效。onPressed赋值来使其可用。CupertinoDatePicker({
Key? key,
CupertinoDatePickerMode mode = CupertinoDatePickerMode.dateAndTime,
required ValueChanged<DateTime> onDateTimeChanged,
DateTime? initialDateTime,
DateTime? minimumDate,
DateTime? maximumDate,
int minimumYear = 1,
int? maximumYear,
int minuteInterval = 1,
bool use24hFormat = false,
DatePickerDateOrder? dateOrder,
Color? backgroundColor,
bool showDayOfWeek = false,
double itemExtent = _kItemExtent,
SelectionOverlayBuilder? selectionOverlayBuilder
})
CupertinoNavigationBar({
Key? key,
Widget? leading,
bool automaticallyImplyLeading = true,
bool automaticallyImplyMiddle = true,
String? previousPageTitle,
Widget? middle,
Widget? trailing,
Border? border = _kDefaultNavBarBorder,
Color? backgroundColor,
Brightness? brightness,
EdgeInsetsDirectional? padding,
bool transitionBetweenRoutes = true,
Object heroTag = _defaultHeroTag
})
CupertinoPageRoute({
required WidgetBuilder builder,
String? title,
RouteSettings? settings,
bool maintainState = true,
bool fullscreenDialog = false,
bool allowSnapshotting = true,
bool barrierDismissible = false
})
CupertinoPageScaffold({
Key? key,
ObstructingPreferredSizeWidget? navigationBar,
Color? backgroundColor,
bool resizeToAvoidBottomInset = true,
required Widget child
})
继承
Object > DiagnosticableTree > Widget > StatefulWidget > CupertinoPicker
构造函数
CupertinoPicker({
Key? key,
double diameterRatio = _kDefaultDiameterRatio,
Color? backgroundColor,
double offAxisFraction = 0.0,
bool useMagnifier = false,
double magnification = 1.0,
FixedExtentScrollController? scrollController,
double squeeze = _kSqueeze,
required double itemExtent,
required ValueChanged<int>? onSelectedItemChanged,
required List<Widget> children,
Widget? selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(),
bool looping = false
})
属性
CupertinoSlider({
Key? key,
required double value,
required ValueChanged<double>? onChanged,
ValueChanged<double>? onChangeStart,
ValueChanged<double>? onChangeEnd,
double min = 0.0,
double max = 1.0,
int? divisions,
Color? activeColor,
Color thumbColor = CupertinoColors.white
})
CupertinoTabBar({
Key? key,
required List<BottomNavigationBarItem> items,
ValueChanged<int>? onTap,
int currentIndex = 0,
Color? backgroundColor,
Color? activeColor,
Color inactiveColor = _kDefaultTabBarInactiveColor,
double iconSize = 30.0,
double height = _kTabBarHeight,
Border? border = const Border(top: BorderSide(color: _kDefaultTabBarBorderColor, width: 0.0))
})
CupertinoTabScaffold({
Key? key,
required CupertinoTabBar tabBar,
required IndexedWidgetBuilder tabBuilder,
CupertinoTabController? controller,
Color? backgroundColor,
bool resizeToAvoidBottomInset = true,
String? restorationId
})
CupertinoTabView({
Key? key,
WidgetBuilder? builder,
GlobalKey<NavigatorState>? navigatorKey,
String? defaultTitle,
Map<String,
WidgetBuilder>? routes,
RouteFactory? onGenerateRoute,
RouteFactory? onUnknownRoute,
List<NavigatorObserver> navigatorObservers = const <NavigatorObserver>[],
String? restorationScopeId
})
可选范围是0至23小时59分59秒。
CupertinoTimerPicker({
Key? key,
CupertinoTimerPickerMode mode = CupertinoTimerPickerMode.hms,
Duration initialTimerDuration = Duration.zero,
int minuteInterval = 1,
int secondInterval = 1,
AlignmentGeometry alignment = Alignment.center,
Color? backgroundColor,
double itemExtent = _kItemExtent,
required ValueChanged<Duration> onTimerDurationChanged,
SelectionOverlayBuilder? selectionOverlayBuilder
})
Future<T?> showCupertinoDialog<T>({
required BuildContext context,
required WidgetBuilder builder,
String? barrierLabel,
bool useRootNavigator = true,
bool barrierDismissible = false,
RouteSettings? routeSettings,
Offset? anchorPoint,
})
Future<T?> showCupertinoModalPopup<T>({
required BuildContext context,
required WidgetBuilder builder,
ImageFilter? filter,
Color barrierColor = kCupertinoModalBarrierColor,
bool barrierDismissible = true,
bool useRootNavigator = true,
bool semanticsDismissible = false,
RouteSettings? routeSettings,
Offset? anchorPoint,
})
void enableFlutterDriverExtension({
DataHandler? handler,
bool silenceErrors = false,
bool enableTextEntryEmulation = true,
List<FinderExtension>? finders,
List<CommandExtension>? commands,
})
FlutterDriver.connectedTo({FlutterWebConnection? webConnection, VmService? serviceClient, Isolate? appIsolate})
find → const CommonFinders
findsNothing → const Matcher
findsOneWidget → const Matcher
void expect(
dynamic actual,
dynamic matcher, {
String? reason,
dynamic skip,
})
@isTestGroup
void group(
Object description,
void body(), {
dynamic skip,
int? retry,
})
void setUpAll( dynamic body() )
void tearDownAll( dynamic body() )
@isTest
void test(
Object description,
dynamic body(), {
String? testOn,
Timeout? timeout,
dynamic skip,
dynamic tags,
Map<String, dynamic>? onPlatform,
int? retry,
})
@isTest
void testWidgets(
String description,
WidgetTesterCallback callback, {
bool? skip,
Timeout? timeout,
bool semanticsEnabled = true,
TestVariant<Object?> variant = const DefaultTestVariant(),
dynamic tags,
int? retry,
LeakTesting? experimentalLeakTesting,
})
自动导入。
debugPrint ↔ DebugPrintCallback
import 'package:flutter/gestures.dart';
GestureArenaMember()
内部结合Listener实现。
GestureRecognizer({
Object? debugOwner,
Set<PointerDeviceKind>? supportedDevices,
AllowedButtonsFilter allowedButtonsFilter = _defaultButtonAcceptBehavior
})
import 'package:flutter/physics.dart';
此库是对animation库的再封装。
import 'package:flutter/material.dart';
AboutListTile({
Key? key,
Widget? icon,
Widget? child,
String? applicationName,
String? applicationVersion,
Widget? applicationIcon,
String? applicationLegalese,
List<Widget>? aboutBoxChildren,
bool? dense
})
AlertDialog({
Key? key,
Widget? icon,
EdgeInsetsGeometry? iconPadding,
Color? iconColor,
Widget? title,
EdgeInsetsGeometry? titlePadding,
TextStyle? titleTextStyle,
Widget? content,
EdgeInsetsGeometry? contentPadding,
TextStyle? contentTextStyle,
List<Widget>? actions,
EdgeInsetsGeometry? actionsPadding,
MainAxisAlignment? actionsAlignment,
OverflowBarAlignment? actionsOverflowAlignment,
VerticalDirection? actionsOverflowDirection,
double? actionsOverflowButtonSpacing,
EdgeInsetsGeometry? buttonPadding,
Color? backgroundColor,
double? elevation,
Color? shadowColor,
Color? surfaceTintColor,
String? semanticLabel,
EdgeInsets? insetPadding,
Clip? clipBehavior,
ShapeBorder? shape,
AlignmentGeometry? alignment,
bool scrollable = false
})
AppBar({
Key? key,
Widget? leading,
bool automaticallyImplyLeading = true,
Widget? title,
List<Widget>? actions,
Widget? flexibleSpace,
PreferredSizeWidget? bottom,
double? elevation,
double? scrolledUnderElevation,
ScrollNotificationPredicate notificationPredicate = defaultScrollNotificationPredicate,
Color? shadowColor,
Color? surfaceTintColor,
ShapeBorder? shape,
Color? backgroundColor,
Color? foregroundColor,
IconThemeData? iconTheme,
IconThemeData? actionsIconTheme,
bool primary = true,
bool? centerTitle,
bool excludeHeaderSemantics = false,
double? titleSpacing,
double toolbarOpacity = 1.0,
double bottomOpacity = 1.0,
double? toolbarHeight,
double? leadingWidth,
TextStyle? toolbarTextStyle,
TextStyle? titleTextStyle,
SystemUiOverlayStyle? systemOverlayStyle,
bool forceMaterialTransparency = false,
Clip? clipBehavior
})
BottomNavigationBar({
Key? key,
required List<BottomNavigationBarItem> items,
ValueChanged<int>? onTap,
int currentIndex = 0,
double? elevation,
BottomNavigationBarType? type,
Color? fixedColor,
Color? backgroundColor,
double iconSize = 24.0,
Color? selectedItemColor,
Color? unselectedItemColor,
IconThemeData? selectedIconTheme,
IconThemeData? unselectedIconTheme,
double selectedFontSize = 14.0,
double unselectedFontSize = 12.0,
TextStyle? selectedLabelStyle,
TextStyle? unselectedLabelStyle,
bool? showSelectedLabels,
bool? showUnselectedLabels,
MouseCursor? mouseCursor,
bool? enableFeedback,
BottomNavigationBarLandscapeLayout? landscapeLayout,
bool useLegacyColorScheme = true
})
内容不允许滚动。
Card({
Key? key,
Color? color,
Color? shadowColor,
Color? surfaceTintColor,
double? elevation,
ShapeBorder? shape,
bool borderOnForeground = true,
EdgeInsetsGeometry? margin,
Clip? clipBehavior,
Widget? child,
bool semanticContainer = true
})
Checkbox({
Key? key,
required bool? value,
bool tristate = false,
required ValueChanged<bool?>? onChanged,
MouseCursor? mouseCursor,
Color? activeColor,
MaterialStateProperty<Color?>? fillColor,
Color? checkColor,
Color? focusColor,
Color? hoverColor,
MaterialStateProperty<Color?>? overlayColor,
double? splashRadius,
MaterialTapTargetSize? materialTapTargetSize,
VisualDensity? visualDensity,
FocusNode? focusNode,
bool autofocus = false,
OutlinedBorder? shape,
BorderSide? side,
bool isError = false,
String? semanticLabel
})
Chip({
Key? key,
Widget? avatar,
required Widget label,
TextStyle? labelStyle,
EdgeInsetsGeometry? labelPadding,
Widget? deleteIcon,
VoidCallback? onDeleted,
Color? deleteIconColor,
String? deleteButtonTooltipMessage,
BorderSide? side,
OutlinedBorder? shape,
Clip clipBehavior = Clip.none,
FocusNode? focusNode,
bool autofocus = false,
MaterialStateProperty<Color?>? color,
Color? backgroundColor,
EdgeInsetsGeometry? padding,
VisualDensity? visualDensity,
MaterialTapTargetSize? materialTapTargetSize,
double? elevation,
Color? shadowColor,
Color? surfaceTintColor,
IconThemeData? iconTheme,
BoxConstraints? avatarBoxConstraints,
BoxConstraints? deleteIconBoxConstraints,
ChipAnimationStyle? chipAnimationStyle
})
CircleAvatar({
Key? key,
Widget? child,
Color? backgroundColor,
ImageProvider<Object>? backgroundImage,
ImageProvider<Object>? foregroundImage,
ImageErrorListener? onBackgroundImageError,
ImageErrorListener? onForegroundImageError,
Color? foregroundColor,
double? radius,
double? minRadius,
double? maxRadius
})
CircularProgressIndicator({
Key? key,
double? value,
Color? backgroundColor,
Color? color,
Animation<Color?>? valueColor,
double strokeWidth = 4.0,
double strokeAlign = strokeAlignCenter,
String? semanticsLabel,
String? semanticsValue,
StrokeCap? strokeCap
})
Divider({
Key? key,
double? height,
double? thickness,
double? indent,
double? endIndent,
Color? color
})
Drawer({
Key? key,
Color? backgroundColor,
double? elevation,
Color? shadowColor,
Color? surfaceTintColor,
ShapeBorder? shape,
double? width,
Widget? child,
String? semanticLabel,
Clip? clipBehavior
})
DrawerHeader({
Key? key,
Decoration? decoration,
EdgeInsetsGeometry? margin = const EdgeInsets.only(bottom: 8.0),
EdgeInsetsGeometry padding = const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
Duration duration = const Duration(milliseconds: 250),
Curve curve = Curves.fastOutSlowIn,
required Widget? child
})
ElevatedButton({
Key? key,
required VoidCallback? onPressed,
VoidCallback? onLongPress,
ValueChanged<bool>? onHover,
ValueChanged<bool>? onFocusChange,
ButtonStyle? style,
FocusNode? focusNode,
bool autofocus = false,
Clip? clipBehavior,
MaterialStatesController? statesController,
required Widget? child,
IconAlignment iconAlignment = IconAlignment.start
})
ExpansionPanel({
required ExpansionPanelHeaderBuilder headerBuilder,
required Widget body,
bool isExpanded = false,
bool canTapOnHeader = false,
Color? backgroundColor,
Color? splashColor,
Color? highlightColor
})
ExpansionPanelList({
Key? key,
List<ExpansionPanel> children = const <ExpansionPanel>[],
ExpansionPanelCallback? expansionCallback,
Duration animationDuration = kThemeAnimationDuration,
EdgeInsets expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
Color? dividerColor,
double elevation = 2,
Color? expandIconColor,
double materialGapSize = 16.0
})
继承
Object > DiagnosticableTree > Widget > StatelessWidget > FloatingActionButton
构造函数
FloatingActionButton({
Key? key,
Widget? child,
String? tooltip,
Color? foregroundColor,
Color? backgroundColor,
Color? focusColor,
Color? hoverColor,
Color? splashColor,
Object? heroTag = const _DefaultHeroTag(),
double? elevation,
double? focusElevation,
double? hoverElevation,
double? highlightElevation,
double? disabledElevation,
required VoidCallback? onPressed,
MouseCursor? mouseCursor,
bool mini = false,
ShapeBorder? shape,
Clip clipBehavior = Clip.none,
FocusNode? focusNode,
bool autofocus = false,
MaterialTapTargetSize? materialTapTargetSize,
bool isExtended = false,
bool? enableFeedback
})
FloatingActionButton.extended({
Key? key,
String? tooltip,
Color? foregroundColor,
Color? backgroundColor,
Color? focusColor,
Color? hoverColor,
Object? heroTag = const _DefaultHeroTag(),
double? elevation,
double? focusElevation,
double? hoverElevation,
Color? splashColor,
double? highlightElevation,
double? disabledElevation,
required VoidCallback? onPressed,
MouseCursor? mouseCursor = SystemMouseCursors.click,
ShapeBorder? shape,
bool isExtended = true,
MaterialTapTargetSize? materialTapTargetSize,
Clip clipBehavior = Clip.none,
FocusNode? focusNode,
bool autofocus = false,
double? extendedIconLabelSpacing,
EdgeInsetsGeometry? extendedPadding,
TextStyle? extendedTextStyle,
Widget? icon,
required Widget label,
bool? enableFeedback
})
属性
必需由MaterialApp包装Material设计风格的组件。
继承
Object > DiagnosticableTree > Widget > StatefulWidget > MaterialApp
构造函数
MaterialApp({
Key? key,
GlobalKey<NavigatorState>? navigatorKey,
GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey,
Widget? home,
Map<String,
WidgetBuilder> routes = const <String, WidgetBuilder>{},
String? initialRoute,
RouteFactory? onGenerateRoute,
InitialRouteListFactory? onGenerateInitialRoutes,
RouteFactory? onUnknownRoute,
NotificationListenerCallback<NavigationNotification>? onNavigationNotification,
List<NavigatorObserver> navigatorObservers = const <NavigatorObserver>[],
TransitionBuilder? builder,
String title = '',
GenerateAppTitle? onGenerateTitle,
Color? color,
ThemeData? theme,
ThemeData? darkTheme,
ThemeData? highContrastTheme,
ThemeData? highContrastDarkTheme,
ThemeMode? themeMode = ThemeMode.system,
Duration themeAnimationDuration = kThemeAnimationDuration,
Curve themeAnimationCurve = Curves.linear,
Locale? locale,
Iterable<LocalizationsDelegate>? localizationsDelegates,
LocaleListResolutionCallback? localeListResolutionCallback,
LocaleResolutionCallback? localeResolutionCallback,
Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')],
bool debugShowMaterialGrid = false,
bool showPerformanceOverlay = false,
bool checkerboardRasterCacheImages = false,
bool checkerboardOffscreenLayers = false,
bool showSemanticsDebugger = false,
bool debugShowCheckedModeBanner = true,
Map<ShortcutActivator, Intent>? shortcuts,
Map<Type, Action<Intent>>? actions,
String? restorationScopeId,
ScrollBehavior? scrollBehavior,
@Deprecated(
'Remove this parameter as it is now ignored. '
'MaterialApp never introduces its own MediaQuery; the View widget takes care of that. '
'This feature was deprecated after v3.7.0-29.0.pre.'
)
bool useInheritedMediaQuery = false,
AnimationStyle? themeAnimationStyle
})
属性
MaterialButton({
Key? key,
required VoidCallback? onPressed,
VoidCallback? onLongPress,
ValueChanged<bool>? onHighlightChanged,
MouseCursor? mouseCursor,
ButtonTextTheme? textTheme,
Color? textColor,
Color? disabledTextColor,
Color? color,
Color? disabledColor,
Color? focusColor,
Color? hoverColor,
Color? highlightColor,
Color? splashColor,
Brightness? colorBrightness,
double? elevation,
double? focusElevation,
double? hoverElevation,
double? highlightElevation,
double? disabledElevation,
EdgeInsetsGeometry? padding,
VisualDensity? visualDensity,
ShapeBorder? shape,
Clip clipBehavior = Clip.none,
FocusNode? focusNode,
bool autofocus = false,
MaterialTapTargetSize? materialTapTargetSize,
Duration? animationDuration,
double? minWidth,
double? height,
bool enableFeedback = true,
Widget? child
})
MaterialPageRoute({
required WidgetBuilder builder,
RouteSettings? settings,
bool? requestFocus,
bool maintainState = true,
bool fullscreenDialog = false,
bool allowSnapshotting = true,
bool barrierDismissible = false
})
点击时产生圆形背景和水波纹效果。
IconButton({
Key? key,
double? iconSize,
VisualDensity? visualDensity,
EdgeInsetsGeometry? padding,
AlignmentGeometry? alignment,
double? splashRadius,
Color? color,
Color? focusColor,
Color? hoverColor,
Color? highlightColor,
Color? splashColor,
Color? disabledColor,
required VoidCallback? onPressed,
MouseCursor? mouseCursor,
FocusNode? focusNode,
bool autofocus = false,
String? tooltip,
bool? enableFeedback,
BoxConstraints? constraints,
ButtonStyle? style,
bool? isSelected,
Widget? selectedIcon,
required Widget icon
})
点击产生水波纹效果。
InkWell({
Key? key,
Widget? child,
GestureTapCallback? onTap,
GestureTapCallback? onDoubleTap,
GestureLongPressCallback? onLongPress,
GestureTapDownCallback? onTapDown,
GestureTapUpCallback? onTapUp,
GestureTapCallback? onTapCancel,
GestureTapCallback? onSecondaryTap,
GestureTapUpCallback? onSecondaryTapUp,
GestureTapDownCallback? onSecondaryTapDown,
GestureTapCallback? onSecondaryTapCancel,
ValueChanged<bool>? onHighlightChanged,
ValueChanged<bool>? onHover,
MouseCursor? mouseCursor,
Color? focusColor,
Color? hoverColor,
Color? highlightColor,
MaterialStateProperty<Color?>? overlayColor,
Color? splashColor,
InteractiveInkFeatureFactory? splashFactory,
double? radius,
BorderRadius? borderRadius,
ShapeBorder? customBorder,
bool? enableFeedback = true,
bool excludeFromSemantics = false,
FocusNode? focusNode,
bool canRequestFocus = true,
ValueChanged<bool>? onFocusChange,
bool autofocus = false,
MaterialStatesController? statesController,
Duration? hoverDuration
})
InputDecoration({
Widget? icon,
Color? iconColor,
Widget? label,
String? labelText,
TextStyle? labelStyle,
TextStyle? floatingLabelStyle,
Widget? helper,
String? helperText,
TextStyle? helperStyle,
int? helperMaxLines,
String? hintText,
TextStyle? hintStyle,
TextDirection? hintTextDirection,
int? hintMaxLines,
Duration? hintFadeDuration,
Widget? error,
String? errorText,
TextStyle? errorStyle,
int? errorMaxLines,
FloatingLabelBehavior? floatingLabelBehavior,
FloatingLabelAlignment? floatingLabelAlignment,
bool? isCollapsed,
bool? isDense,
EdgeInsetsGeometry? contentPadding,
Widget? prefixIcon,
BoxConstraints? prefixIconConstraints,
Widget? prefix,
String? prefixText,
TextStyle? prefixStyle,
Color? prefixIconColor,
Widget? suffixIcon,
Widget? suffix,
String? suffixText,
TextStyle? suffixStyle,
Color? suffixIconColor,
BoxConstraints? suffixIconConstraints,
Widget? counter,
String? counterText,
TextStyle? counterStyle,
bool? filled,
Color? fillColor,
Color? focusColor,
Color? hoverColor,
InputBorder? errorBorder,
InputBorder? focusedBorder,
InputBorder? focusedErrorBorder,
InputBorder? disabledBorder,
InputBorder? enabledBorder,
InputBorder? border,
bool enabled = true,
String? semanticCounterText,
bool? alignLabelWithHint,
BoxConstraints? constraints
})
LinearProgressIndicator({
Key? key,
double? value,
Color? backgroundColor,
Color? color,
Animation<Color?>? valueColor,
double? minHeight,
String? semanticsLabel,
String? semanticsValue,
BorderRadiusGeometry borderRadius = BorderRadius.zero
})
ListTile({
Key? key,
Widget? leading,
Widget? title,
Widget? subtitle,
Widget? trailing,
bool isThreeLine = false,
bool? dense,
VisualDensity? visualDensity,
ShapeBorder? shape,
ListTileStyle? style,
Color? selectedColor,
Color? iconColor,
Color? textColor,
TextStyle? titleTextStyle,
TextStyle? subtitleTextStyle,
TextStyle? leadingAndTrailingTextStyle,
EdgeInsetsGeometry? contentPadding,
bool enabled = true,
GestureTapCallback? onTap,
GestureLongPressCallback? onLongPress,
ValueChanged<bool>? onFocusChange,
MouseCursor? mouseCursor,
bool selected = false,
Color? focusColor,
Color? hoverColor,
Color? splashColor,
FocusNode? focusNode,
bool autofocus = false,
Color? tileColor,
Color? selectedTileColor,
bool? enableFeedback,
double? horizontalTitleGap,
double? minVerticalPadding,
double? minLeadingWidth,
double? minTileHeight,
ListTileTitleAlignment? titleAlignment
})
未点击时有浅浅的边框,背景透明;点击时边框亮起,显示背景色并伴有水波纹扩散。
OutlinedButton({
Key? key,
required VoidCallback? onPressed,
VoidCallback? onLongPress,
ValueChanged<bool>? onHover,
ValueChanged<bool>? onFocusChange,
ButtonStyle? style,
FocusNode? focusNode,
bool autofocus = false,
Clip? clipBehavior,
MaterialStatesController? statesController,
required Widget? child,
IconAlignment iconAlignment = IconAlignment.start
})
PopupMenuButton({
Key? key,
required PopupMenuItemBuilder<T> itemBuilder,
T? initialValue,
VoidCallback? onOpened,
PopupMenuItemSelected<T>? onSelected,
PopupMenuCanceled? onCanceled,
String? tooltip,
double? elevation,
Color? shadowColor,
Color? surfaceTintColor,
EdgeInsetsGeometry padding = const EdgeInsets.all(8.0),
EdgeInsetsGeometry? menuPadding,
Widget? child,
double? splashRadius,
Widget? icon,
double? iconSize,
Offset offset = Offset.zero,
bool enabled = true,
ShapeBorder? shape,
Color? color,
Color? iconColor,
bool? enableFeedback,
BoxConstraints? constraints,
PopupMenuPosition? position,
Clip clipBehavior = Clip.none,
bool useRootNavigator = false,
AnimationStyle? popUpAnimationStyle,
RouteSettings? routeSettings,
ButtonStyle? style
})
PopupMenuItem({
Key? key,
T? value,
VoidCallback? onTap,
bool enabled = true,
double height = kMinInteractiveDimension,
EdgeInsets? padding,
TextStyle? textStyle,
MaterialStateProperty<TextStyle?>? labelTextStyle,
MouseCursor? mouseCursor,
required Widget? child
})
Radio({
Key? key,
required T value,
required T? groupValue,
required ValueChanged<T?>? onChanged,
MouseCursor? mouseCursor,
bool toggleable = false,
Color? activeColor,
MaterialStateProperty<Color?>? fillColor,
Color? focusColor,
Color? hoverColor,
MaterialStateProperty<Color?>? overlayColor,
double? splashRadius,
MaterialTapTargetSize? materialTapTargetSize,
VisualDensity? visualDensity,
FocusNode? focusNode,
bool autofocus = false
})
Scaffold({
Key? key,
PreferredSizeWidget? appBar,
Widget? body,
Widget? floatingActionButton,
FloatingActionButtonLocation? floatingActionButtonLocation,
FloatingActionButtonAnimator? floatingActionButtonAnimator,
List<Widget>? persistentFooterButtons,
AlignmentDirectional persistentFooterAlignment = AlignmentDirectional.centerEnd,
Widget? drawer,
DrawerCallback? onDrawerChanged,
Widget? endDrawer,
DrawerCallback? onEndDrawerChanged,
Widget? bottomNavigationBar,
Widget? bottomSheet,
Color? backgroundColor,
bool? resizeToAvoidBottomInset,
bool primary = true,
DragStartBehavior drawerDragStartBehavior = DragStartBehavior.start,
bool extendBody = false,
bool extendBodyBehindAppBar = false,
Color? drawerScrimColor,
double? drawerEdgeDragWidth,
bool drawerEnableOpenDragGesture = true,
bool endDrawerEnableOpenDragGesture = true,
String? restorationId
})
SimpleDialog({
Key? key,
Widget? title,
EdgeInsetsGeometry titlePadding = const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0),
TextStyle? titleTextStyle,
List<Widget>? children,
EdgeInsetsGeometry contentPadding = const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0),
Color? backgroundColor,
double? elevation,
Color? shadowColor,
Color? surfaceTintColor,
String? semanticLabel,
EdgeInsets? insetPadding,
Clip? clipBehavior,
ShapeBorder? shape,
AlignmentGeometry? alignment
})
SimpleDialogOption({
Key? key,
VoidCallback? onPressed,
EdgeInsets? padding,
Widget? child
})
Slider({
Key? key,
required double value,
double? secondaryTrackValue,
required ValueChanged<double>? onChanged,
ValueChanged<double>? onChangeStart,
ValueChanged<double>? onChangeEnd,
double min = 0.0,
double max = 1.0,
int? divisions,
String? label,
Color? activeColor,
Color? inactiveColor,
Color? secondaryActiveColor,
Color? thumbColor,
MaterialStateProperty<Color?>? overlayColor,
MouseCursor? mouseCursor,
SemanticFormatterCallback? semanticFormatterCallback,
FocusNode? focusNode,
bool autofocus = false,
SliderInteraction? allowedInteraction
})
Slider不维护任何状态,需要在此方法中重绘滑块。SnackBar({
Key? key,
required Widget content,
Color? backgroundColor,
double? elevation,
EdgeInsetsGeometry? margin,
EdgeInsetsGeometry? padding,
double? width,
ShapeBorder? shape,
HitTestBehavior? hitTestBehavior,
SnackBarBehavior? behavior,
SnackBarAction? action,
double? actionOverflowThreshold,
bool? showCloseIcon,
Color? closeIconColor,
Duration duration = _snackBarDisplayDuration,
Animation<double>? animation,
VoidCallback? onVisible,
DismissDirection? dismissDirection,
Clip clipBehavior = Clip.hardEdge
})
*属性
* action → SnackBarAction?:用来触发一个快捷操作。
* backgroundColor → Color?:背景色。默认为深灰色。
* content → Widget:内容。
* duration → Duration:显示的持续时长。
Switch({
Key? key,
required bool value,
required ValueChanged\<bool>? onChanged,
Color? activeColor,
Color? activeTrackColor,
Color? inactiveThumbColor,
Color? inactiveTrackColor,
ImageProvider<Object>? activeThumbImage,
ImageErrorListener? onActiveThumbImageError,
ImageProvider<Object>? inactiveThumbImage,
ImageErrorListener? onInactiveThumbImageError,
MaterialStateProperty<Color?>? thumbColor,
MaterialStateProperty<Color?>? trackColor,
MaterialStateProperty<Color?>? trackOutlineColor,
MaterialStateProperty<double?>? trackOutlineWidth,
MaterialStateProperty<Icon?>? thumbIcon,
MaterialTapTargetSize? materialTapTargetSize,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
MouseCursor? mouseCursor,
Color? focusColor,
Color? hoverColor,
MaterialStateProperty<Color?>? overlayColor,
double? splashRadius,
FocusNode? focusNode,
ValueChanged<bool>? onFocusChange,
bool autofocus = false
})
Tab({
Key? key,
String? text,
Widget? icon,
EdgeInsetsGeometry? iconMargin,
double? height,
Widget? child
})
TabBar({
Key? key,
required List<Widget> tabs,
TabController? controller,
bool isScrollable = false,
EdgeInsetsGeometry? padding,
Color? indicatorColor,
bool automaticIndicatorColorAdjustment = true,
double indicatorWeight = 2.0,
EdgeInsetsGeometry indicatorPadding = EdgeInsets.zero,
Decoration? indicator,
TabBarIndicatorSize? indicatorSize,
Color? dividerColor,
double? dividerHeight,
Color? labelColor,
TextStyle? labelStyle,
EdgeInsetsGeometry? labelPadding,
Color? unselectedLabelColor,
TextStyle? unselectedLabelStyle,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
MaterialStateProperty<Color?>? overlayColor,
MouseCursor? mouseCursor,
bool? enableFeedback,
ValueChanged<int>? onTap,
ScrollPhysics? physics,
InteractiveInkFeatureFactory? splashFactory,
BorderRadius? splashBorderRadius,
TabAlignment? tabAlignment,
TextScaler? textScaler
})
TabBarView({
Key? key,
required List<Widget> children,
TabController? controller,
ScrollPhysics? physics,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
double viewportFraction = 1.0,
Clip clipBehavior = Clip.hardEdge
})
TabController({
int initialIndex = 0,
Duration? animationDuration,
required int length,
required TickerProvider vsync
})
TextButton({
Key? key,
required VoidCallback? onPressed,
VoidCallback? onLongPress,
ValueChanged<bool>? onHover,
ValueChanged<bool>? onFocusChange,
ButtonStyle? style,
FocusNode? focusNode,
bool autofocus = false,
Clip? clipBehavior,
MaterialStatesController? statesController,
bool? isSemanticButton = true,
required Widget child,
IconAlignment iconAlignment = IconAlignment.start
})
TextField({
Key? key,
Object groupId = EditableText,
TextEditingController? controller,
FocusNode? focusNode,
UndoHistoryController? undoController,
InputDecoration? decoration = const InputDecoration(),
TextInputType? keyboardType,
TextInputAction? textInputAction,
TextCapitalization textCapitalization = TextCapitalization.none,
TextStyle? style,
StrutStyle? strutStyle,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
TextDirection? textDirection,
bool readOnly = false,
@Deprecated(
'Use `contextMenuBuilder` instead. '
'This feature was deprecated after v3.3.0-0.5.pre.'
)
ToolbarOptions? toolbarOptions,
bool? showCursor,
bool autofocus = false,
MaterialStatesController? statesController,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
MaxLengthEnforcement? maxLengthEnforcement,
ValueChanged<String>? onChanged,
VoidCallback? onEditingComplete,
ValueChanged<String>? onSubmitted,
AppPrivateCommandCallback? onAppPrivateCommand,
List<TextInputFormatter>? inputFormatters,
bool? enabled,
bool? ignorePointers,
double cursorWidth = 2.0,
double? cursorHeight,
Radius? cursorRadius,
bool? cursorOpacityAnimates,
Color? cursorColor,
Color? cursorErrorColor,
BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool? enableInteractiveSelection,
TextSelectionControls? selectionControls,
GestureTapCallback? onTap,
bool onTapAlwaysCalled = false,
TapRegionCallback? onTapOutside,
MouseCursor? mouseCursor,
InputCounterWidgetBuilder? buildCounter,
ScrollController? scrollController,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints = const <String>[],
ContentInsertionConfiguration? contentInsertionConfiguration,
Clip clipBehavior = Clip.hardEdge,
String? restorationId,
bool scribbleEnabled = true,
bool enableIMEPersonalizedLearning = true,
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
bool canRequestFocus = true,
SpellCheckConfiguration? spellCheckConfiguration,
TextMagnifierConfiguration? magnifierConfiguration
})
TextFormField({
Key? key,
Object groupId = EditableText,
TextEditingController? controller,
String? initialValue,
FocusNode? focusNode,
String? forceErrorText,
InputDecoration? decoration = const InputDecoration(),
TextInputType? keyboardType,
TextCapitalization textCapitalization = TextCapitalization.none,
TextInputAction? textInputAction,
TextStyle? style,
StrutStyle? strutStyle,
TextDirection? textDirection,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
bool autofocus = false,
bool readOnly = false,
@Deprecated(
'Use `contextMenuBuilder` instead. '
'This feature was deprecated after v3.3.0-0.5.pre.'
)
ToolbarOptions? toolbarOptions,
bool? showCursor,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
MaxLengthEnforcement? maxLengthEnforcement,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
ValueChanged<String>? onChanged,
GestureTapCallback? onTap,
bool onTapAlwaysCalled = false,
TapRegionCallback? onTapOutside,
VoidCallback? onEditingComplete,
ValueChanged<String>? onFieldSubmitted,
FormFieldSetter<String>? onSaved,
FormFieldValidator<String>? validator,
List<TextInputFormatter>? inputFormatters,
bool? enabled,
bool? ignorePointers,
double cursorWidth = 2.0,
double? cursorHeight,
Radius? cursorRadius,
Color? cursorColor,
Color? cursorErrorColor,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
bool? enableInteractiveSelection,
TextSelectionControls? selectionControls,
InputCounterWidgetBuilder? buildCounter,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints,
AutovalidateMode? autovalidateMode,
ScrollController? scrollController,
String? restorationId,
bool enableIMEPersonalizedLearning = true,
MouseCursor? mouseCursor,
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
SpellCheckConfiguration? spellCheckConfiguration,
TextMagnifierConfiguration? magnifierConfiguration,
UndoHistoryController? undoController,
AppPrivateCommandCallback? onAppPrivateCommand,
bool? cursorOpacityAnimates,
BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ContentInsertionConfiguration? contentInsertionConfiguration,
MaterialStatesController? statesController,
Clip clipBehavior = Clip.hardEdge,
bool scribbleEnabled = true,
bool canRequestFocus = true
})
Theme({
Key? key,
required ThemeData data,
required Widget child
})
构造函数
ThemeData({
Iterable<Adaptation<Object>>? adaptations,
bool? applyElevationOverlayColor,
NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
Iterable<ThemeExtension>? extensions,
InputDecorationTheme? inputDecorationTheme,
MaterialTapTargetSize? materialTapTargetSize,
PageTransitionsTheme? pageTransitionsTheme,
TargetPlatform? platform,
ScrollbarThemeData? scrollbarTheme,
InteractiveInkFeatureFactory? splashFactory,
bool? useMaterial3,
VisualDensity? visualDensity,
ColorScheme? colorScheme,
Brightness? brightness,
Color? colorSchemeSeed,
Color? canvasColor,
Color? cardColor,
Color? dialogBackgroundColor,
Color? disabledColor,
Color? dividerColor,
Color? focusColor,
Color? highlightColor,
Color? hintColor,
Color? hoverColor,
Color? indicatorColor,
Color? primaryColor,
Color? primaryColorDark,
Color? primaryColorLight,
MaterialColor? primarySwatch,
Color? scaffoldBackgroundColor,
Color? secondaryHeaderColor,
Color? shadowColor,
Color? splashColor,
Color? unselectedWidgetColor,
String? fontFamily,
List<String>? fontFamilyFallback,
String? package,
IconThemeData? iconTheme,
IconThemeData? primaryIconTheme,
TextTheme? primaryTextTheme,
TextTheme? textTheme,
Typography? typography,
ActionIconThemeData? actionIconTheme,
AppBarTheme? appBarTheme,
BadgeThemeData? badgeTheme,
MaterialBannerThemeData? bannerTheme,
BottomAppBarTheme? bottomAppBarTheme,
BottomNavigationBarThemeData? bottomNavigationBarTheme,
BottomSheetThemeData? bottomSheetTheme,
ButtonThemeData? buttonTheme,
CardTheme? cardTheme,
CheckboxThemeData? checkboxTheme,
ChipThemeData? chipTheme,
DataTableThemeData? dataTableTheme,
DatePickerThemeData? datePickerTheme,
DialogTheme? dialogTheme,
DividerThemeData? dividerTheme,
DrawerThemeData? drawerTheme,
DropdownMenuThemeData? dropdownMenuTheme,
ElevatedButtonThemeData? elevatedButtonTheme,
ExpansionTileThemeData? expansionTileTheme,
FilledButtonThemeData? filledButtonTheme,
FloatingActionButtonThemeData? floatingActionButtonTheme,
IconButtonThemeData? iconButtonTheme,
ListTileThemeData? listTileTheme,
MenuBarThemeData? menuBarTheme,
MenuButtonThemeData? menuButtonTheme,
MenuThemeData? menuTheme,
NavigationBarThemeData? navigationBarTheme,
NavigationDrawerThemeData? navigationDrawerTheme,
NavigationRailThemeData? navigationRailTheme,
OutlinedButtonThemeData? outlinedButtonTheme,
PopupMenuThemeData? popupMenuTheme,
ProgressIndicatorThemeData? progressIndicatorTheme,
RadioThemeData? radioTheme,
SearchBarThemeData? searchBarTheme,
SearchViewThemeData? searchViewTheme,
SegmentedButtonThemeData? segmentedButtonTheme,
SliderThemeData? sliderTheme,
SnackBarThemeData? snackBarTheme,
SwitchThemeData? switchTheme,
TabBarTheme? tabBarTheme,
TextButtonThemeData? textButtonTheme,
TextSelectionThemeData? textSelectionTheme,
TimePickerThemeData? timePickerTheme,
ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme,
@Deprecated(
'Use OverflowBar instead. '
'This feature was deprecated after v3.21.0-10.0.pre.'
)
ButtonBarThemeData? buttonBarTheme
})
属性
方法
构造函数
TimeOfDay({required int hour, required int minute})
当前时间:
TimeOfDay.now()
在长按时进行提示。
Tooltip({
Key? key,
String? message,
InlineSpan? richMessage,
double? height,
EdgeInsetsGeometry? padding,
EdgeInsetsGeometry? margin,
double? verticalOffset,
bool? preferBelow,
bool? excludeFromSemantics,
Decoration? decoration,
TextStyle? textStyle,
TextAlign? textAlign,
Duration? waitDuration,
Duration? showDuration,
Duration? exitDuration,
bool enableTapToDismiss = true,
TooltipTriggerMode? triggerMode,
bool? enableFeedback,
TooltipTriggeredCallback? onTriggered,
Widget? child
})
为子组件添加下划线。
UnderlineTabIndicator({
BorderRadius? borderRadius,
BorderSide borderSide = const BorderSide(width: 2.0, color: Colors.white),
EdgeInsetsGeometry insets = EdgeInsets.zero
})
UserAccountsDrawerHeader({
Key? key,
Decoration? decoration,
EdgeInsetsGeometry? margin = const EdgeInsets.only(bottom: 8.0),
Widget? currentAccountPicture,
List<Widget>? otherAccountsPictures,
Size currentAccountPictureSize = const Size.square(72.0),
Size otherAccountsPicturesSize = const Size.square(40.0),
required Widget? accountName,
required Widget? accountEmail,
VoidCallback? onDetailsPressed,
Color arrowColor = Colors.white
})
调用系统的组件。
Future<DateTime?> showDatePicker({
required BuildContext context,
DateTime? initialDate,
required DateTime firstDate,
required DateTime lastDate,
DateTime? currentDate,
DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar,
SelectableDayPredicate? selectableDayPredicate,
String? helpText,
String? cancelText,
String? confirmText,
Locale? locale,
bool barrierDismissible = true,
Color? barrierColor,
String? barrierLabel,
bool useRootNavigator = true,
RouteSettings? routeSettings,
TextDirection? textDirection,
TransitionBuilder? builder,
DatePickerMode initialDatePickerMode = DatePickerMode.day,
String? errorFormatText,
String? errorInvalidText,
String? fieldHintText,
String? fieldLabelText,
TextInputType? keyboardType,
Offset? anchorPoint,
ValueChanged<DatePickerEntryMode>? onDatePickerModeChange,
Icon? switchToInputEntryModeIcon,
Icon? switchToCalendarEntryModeIcon,
})
Future<T?> showDialog<T>({
required BuildContext context,
required WidgetBuilder builder,
bool barrierDismissible = true,
Color? barrierColor,
String? barrierLabel,
bool useSafeArea = true,
bool useRootNavigator = true,
RouteSettings? routeSettings,
Offset? anchorPoint,
TraversalEdgeBehavior? traversalEdgeBehavior,
})
调用系统的组件。
Future<TimeOfDay?> showTimePicker({
required BuildContext context,
required TimeOfDay initialTime,
TransitionBuilder? builder,
bool barrierDismissible = true,
Color? barrierColor,
String? barrierLabel,
bool useRootNavigator = true,
TimePickerEntryMode initialEntryMode = TimePickerEntryMode.dial,
String? cancelText,
String? confirmText,
String? helpText,
String? errorInvalidText,
String? hourLabelText,
String? minuteLabelText,
RouteSettings? routeSettings,
EntryModeChangeCallback? onEntryModeChanged,
Offset? anchorPoint,
Orientation? orientation,
})
import 'package:flutter/painting.dart';
Alignment(double x, double y)
AlignmentDirectional(double start, double y)
AssetImage(
String assetName,
{
AssetBundle? bundle,
String? package
}
)
BorderRadius.circular(double radius)
BoxDecoration({
Color? color,
DecorationImage? image,
BoxBorder? border,
BorderRadiusGeometry? borderRadius,
List<BoxShadow>? boxShadow,
Gradient? gradient,
BlendMode? backgroundBlendMode,
BoxShape shape = BoxShape.rectangle
})
继承
Object > EdgeInsetsGeometry > EdgeInsets
构造函数
所有边距使用相同的值:
EdgeInsets.all(double value)
分布指定四个方向的边距:
EdgeInsets.fromLTRB(double left, double top, double right, double bottom)
可只指定某些方向的边距:
EdgeInsets.only({double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0})
可只指定某些对称方向的边距:
EdgeInsets.symmetric({double vertical = 0.0, double horizontal = 0.0})
常量
FlutterLogoDecoration({
Color textColor = const Color(0xFF757575),
FlutterLogoStyle style = FlutterLogoStyle.markOnly,
EdgeInsets margin = EdgeInsets.zero
})
LinearGradient({
AlignmentGeometry begin = Alignment.centerLeft,
AlignmentGeometry end = Alignment.centerRight,
required List<Color> colors,
List<double>? stops,
TileMode tileMode = TileMode.clamp,
GradientTransform? transform
})
NetworkImage(
String url,
{
double scale,
Map<String, String>? headers
}
)
ShapeDecoration({
Color? color,
DecorationImage? image,
Gradient? gradient,
List<BoxShadow>? shadows,
required ShapeBorder shape
})
TextSpan({
String? text,
List<InlineSpan>? children,
TextStyle? style,
GestureRecognizer? recognizer,
MouseCursor? mouseCursor,
PointerEnterEventListener? onEnter,
PointerExitEventListener? onExit,
String? semanticsLabel,
Locale? locale,
bool? spellOut
})
构造函数
TextStyle({
bool inherit = true,
Color? color,
Color? backgroundColor,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? letterSpacing,
double? wordSpacing,
TextBaseline? textBaseline,
double? height,
TextLeadingDistribution? leadingDistribution,
Locale? locale,
Paint? foreground,
Paint? background,
List<Shadow>? shadows,
List<FontFeature>? fontFeatures,
List<FontVariation>? fontVariations,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double? decorationThickness,
String? debugLabel,
String? fontFamily,
List<String>? fontFamilyFallback,
String? package,
TextOverflow? overflow
})
属性
import 'package:path/path.dart';
import 'package:flutter/rendering.dart';
BoxConstraints({
double minWidth = 0.0,
double maxWidth = double.infinity,
double minHeight = 0.0,
double maxHeight = double.infinity
})
滚动方向为主轴方向。
SliverGridDelegateWithFixedCrossAxisCount({
required int crossAxisCount,
double mainAxisSpacing = 0.0,
double crossAxisSpacing = 0.0,
double childAspectRatio = 1.0,
double? mainAxisExtent
})
滚动方向为主轴方向。
SliverGridDelegateWithMaxCrossAxisExtent({
required double maxCrossAxisExtent,
double mainAxisSpacing = 0.0,
double crossAxisSpacing = 0.0,
double childAspectRatio = 1.0,
double? mainAxisExtent
})
Stack。对于具有基线的组件,文字基线以亮绿色显示,表意基线以橙色显示。
bool debugPaintBaselinesEnabled
被点击的组件以深青色高亮显示。
bool debugPaintPointersEnabled
边界以青色边框显示,对齐方式以黄色箭头显示。
bool debugPaintSizeEnabled
void debugDumpLayerTree()
void debugDumpRenderTree()
void debugDumpSemanticsTree([ DebugSemanticsDumpOrder childOrder = DebugSemanticsDumpOrder.traversalOrder ])
import 'package:flutter/scheduler.dart';
debugPrintBeginFrameBanner ↔ bool
debugPrintEndFrameBanner ↔ bool
应只在程序启动后设置一次,否则可能引发一些副作用。
import 'package:flutter/services.dart';
Flutter侧称为客户端(Client),原生侧称为宿主(Host)。消息的传递是异步的,保证前台UI不会因此而停止响应。发送和接收消息时,序列化和反序列化会自动进行。
MethodChannel(
String name,
[
MethodCodec codec = const StandardMethodCodec(),
BinaryMessenger? binaryMessenger
]
)
import 'package:flutter/widgets.dart';
runApp(Widget app) → void
接收并丢弃事件,子组件无法接收。
AbsorbPointer({
Key? key,
bool absorbing = true,
@Deprecated(
'Use ExcludeSemantics or create a custom absorb pointer widget instead. '
'This feature was deprecated after v3.8.0-12.0.pre.'
)
bool? ignoringSemantics, Widget? child
})
BottomNavigationBarItem({
Key? key,
required Widget icon,
String? label,
Widget? activeIcon,
Color? backgroundColor,
String? tooltip
})
BouncingScrollPhysics({
ScrollDecelerationRate decelerationRate = ScrollDecelerationRate.normal,
ScrollPhysics? parent
})
Builder({
Key? key,
required WidgetBuilder builder
})
Center({
Key? key,
double? widthFactor,
double? heightFactor,
Widget? child
})
ClampingScrollPhysics({ScrollPhysics? parent})
Column({
Key? key,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
MainAxisSize mainAxisSize = MainAxisSize.max,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
List<Widget> children = const <Widget>[]
})
mainAxisSize为MainAxisSize.min时,本属性不起作用,因为空间已被占满。TextDirection.ltr。VerticalDirection.down。当子组件超出最大约束时会显示异常,当子组件未填满最小约束时未填充部分显示背景色。
ConstrainedBox({
Key? key,
required BoxConstraints constraints,
Widget? child
})
Container({
Key? key,
AlignmentGeometry? alignment,
EdgeInsetsGeometry? padding,
Color? color,
Decoration? decoration,
Decoration? foregroundDecoration,
double? width,
double? height,
BoxConstraints? constraints,
EdgeInsetsGeometry? margin,
Matrix4? transform,
AlignmentGeometry? transformAlignment,
Widget? child,
Clip clipBehavior = Clip.none
})
CustomScrollView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
ScrollBehavior? scrollBehavior,
bool shrinkWrap = false,
Key? center, double anchor = 0.0,
double? cacheExtent,
List<Widget> slivers = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
为子组件添加视觉效果。
DecoratedBox({
Key? key,
required Decoration decoration,
DecorationPosition position = DecorationPosition.background,
Widget? child
})
其子组件的文本以此为默认文本样式。
DefaultTextStyle({
Key? key,
required TextStyle style,
TextAlign? textAlign,
bool softWrap = true,
TextOverflow overflow = TextOverflow.clip,
int? maxLines,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
TextHeightBehavior? textHeightBehavior,
required Widget child
})
可见的。
Element(Widget widget)
令子组件尽可能地填充可用空间。
Expanded({
Key? key,
int flex = 1,
required Widget child
})
flex/父组件所有子组件的flex之和。初始显示占位图片,实际图片加载完成后淡入替换。
FadeInImage.assetNetwork({
Key? key,
required String placeholder,
ImageErrorWidgetBuilder? placeholderErrorBuilder,
required String image,
ImageErrorWidgetBuilder? imageErrorBuilder,
AssetBundle? bundle,
double? placeholderScale,
double imageScale = 1.0,
bool excludeFromSemantics = false,
String? imageSemanticLabel,
Duration fadeOutDuration = const Duration(milliseconds: 300),
Curve fadeOutCurve = Curves.easeOut,
Duration fadeInDuration = const Duration(milliseconds: 700),
Curve fadeInCurve = Curves.easeIn,
double? width,
double? height,
BoxFit? fit,
Color? color,
BlendMode? colorBlendMode,
Color? placeholderColor,
BlendMode? placeholderColorBlendMode,
BoxFit? placeholderFit,
FilterQuality filterQuality = FilterQuality.medium,
FilterQuality? placeholderFilterQuality,
AlignmentGeometry alignment = Alignment.center,
ImageRepeat repeat = ImageRepeat.noRepeat,
bool matchTextDirection = false,
int? placeholderCacheWidth,
int? placeholderCacheHeight,
int? imageCacheWidth,
int? imageCacheHeight
})
FocusNode({
String? debugLabel,
@Deprecated(
'Use onKeyEvent instead. '
'This feature was deprecated after v3.18.0-2.0.pre.'
)
FocusOnKeyCallback? onKey,
FocusOnKeyEventCallback? onKeyEvent,
bool skipTraversal = false,
bool canRequestFocus = true,
bool descendantsAreFocusable = true,
bool descendantsAreTraversable = true
})
Form({
Key? key,
required Widget child,
bool? canPop,
@Deprecated(
'Use onPopInvokedWithResult instead. '
'This feature was deprecated after v3.22.0-12.0.pre.'
)
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<Object?>? onPopInvokedWithResult,
@Deprecated(
'Use canPop and/or onPopInvokedWithResult instead. '
'This feature was deprecated after v3.12.0-1.0.pre.'
)
WillPopCallback? onWillPop,
VoidCallback? onChanged,
AutovalidateMode? autovalidateMode
})
FormState()
FutureBuilder({
Key? key,
required Future<T>? future,
T? initialData,
required AsyncWidgetBuilder<T> builder
})
按比例摆放子组件。要求子组件可以被Expanded包裹。
Flex({
Key? key,
required Axis direction,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
MainAxisSize mainAxisSize = MainAxisSize.max,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
Clip clipBehavior = Clip.none,
List<Widget> children = const <Widget>[]
})
FormField<T>的onSaved方法。FormField<T>的validator方法。内部使用GestureRecognizer实现。
GestureDetector({
Key? key,
Widget? child,
GestureTapDownCallback? onTapDown,
GestureTapUpCallback? onTapUp,
GestureTapCallback? onTap,
GestureTapCancelCallback? onTapCancel,
GestureTapCallback? onSecondaryTap,
GestureTapDownCallback? onSecondaryTapDown,
GestureTapUpCallback? onSecondaryTapUp,
GestureTapCancelCallback? onSecondaryTapCancel,
GestureTapDownCallback? onTertiaryTapDown,
GestureTapUpCallback? onTertiaryTapUp,
GestureTapCancelCallback? onTertiaryTapCancel,
GestureTapDownCallback? onDoubleTapDown,
GestureTapCallback? onDoubleTap,
GestureTapCancelCallback? onDoubleTapCancel,
GestureLongPressDownCallback? onLongPressDown,
GestureLongPressCancelCallback? onLongPressCancel,
GestureLongPressCallback? onLongPress,
GestureLongPressStartCallback? onLongPressStart,
GestureLongPressMoveUpdateCallback? onLongPressMoveUpdate,
GestureLongPressUpCallback? onLongPressUp,
GestureLongPressEndCallback? onLongPressEnd,
GestureLongPressDownCallback? onSecondaryLongPressDown,
GestureLongPressCancelCallback? onSecondaryLongPressCancel,
GestureLongPressCallback? onSecondaryLongPress,
GestureLongPressStartCallback? onSecondaryLongPressStart,
GestureLongPressMoveUpdateCallback? onSecondaryLongPressMoveUpdate,
GestureLongPressUpCallback? onSecondaryLongPressUp,
GestureLongPressEndCallback? onSecondaryLongPressEnd,
GestureLongPressDownCallback? onTertiaryLongPressDown,
GestureLongPressCancelCallback? onTertiaryLongPressCancel,
GestureLongPressCallback? onTertiaryLongPress,
GestureLongPressStartCallback? onTertiaryLongPressStart,
GestureLongPressMoveUpdateCallback? onTertiaryLongPressMoveUpdate,
GestureLongPressUpCallback? onTertiaryLongPressUp,
GestureLongPressEndCallback? onTertiaryLongPressEnd,
GestureDragDownCallback? onVerticalDragDown,
GestureDragStartCallback? onVerticalDragStart,
GestureDragUpdateCallback? onVerticalDragUpdate,
GestureDragEndCallback? onVerticalDragEnd,
GestureDragCancelCallback? onVerticalDragCancel,
GestureDragDownCallback? onHorizontalDragDown,
GestureDragStartCallback? onHorizontalDragStart,
GestureDragUpdateCallback? onHorizontalDragUpdate,
GestureDragEndCallback? onHorizontalDragEnd,
GestureDragCancelCallback? onHorizontalDragCancel,
GestureForcePressStartCallback? onForcePressStart,
GestureForcePressPeakCallback? onForcePressPeak,
GestureForcePressUpdateCallback? onForcePressUpdate,
GestureForcePressEndCallback? onForcePressEnd,
GestureDragDownCallback? onPanDown,
GestureDragStartCallback? onPanStart,
GestureDragUpdateCallback? onPanUpdate,
GestureDragEndCallback? onPanEnd,
GestureDragCancelCallback? onPanCancel,
GestureScaleStartCallback? onScaleStart,
GestureScaleUpdateCallback? onScaleUpdate,
GestureScaleEndCallback? onScaleEnd,
HitTestBehavior? behavior,
bool excludeFromSemantics = false,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool trackpadScrollCausesScale = false,
Offset trackpadScrollToScaleFactor = kDefaultTrackpadScrollToScaleFactor,
Set<PointerDeviceKind>? supportedDevices
})
onPanDown与onTap共存时可能只有onPanDown事件响应。onPanDown与onTap共存时可能只有onPanDown事件响应。GlobalKey({String? debugLabel})
继承
Object > DiagnosticableTree > Widget > StatelessWidget > ScrollView > BoxScrollView > GridView
构造函数
在有足够简单的子组件的情况下使用:
GridView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
required SliverGridDelegate gridDelegate,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
List<Widget> children = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Clip clipBehavior = Clip.hardEdge,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
适合在子组件较多的情况下使用:
GridView.builder({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
required SliverGridDelegate gridDelegate,
required NullableIndexedWidgetBuilder itemBuilder,
ChildIndexGetter? findChildIndexCallback,
int? itemCount,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
等价于使用SliverGridDelegateWithFixedCrossAxisCount的快捷实现;
GridView.count({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
required int crossAxisCount,
double mainAxisSpacing = 0.0,
double crossAxisSpacing = 0.0,
double childAspectRatio = 1.0,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
List<Widget> children = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
等价于使用SliverGridDelegateWithMaxCrossAxisExtent的快捷实现;
GridView.extent({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
required double maxCrossAxisExtent,
double mainAxisSpacing = 0.0,
double crossAxisSpacing = 0.0,
double childAspectRatio = 1.0,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent, List<Widget> children = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
属性
在两个页面之间共同存在的内容的动画。
Hero({
Key? key,
required Object tag,
CreateRectTween? createRectTween,
HeroFlightShuttleBuilder? flightShuttleBuilder,
HeroPlaceholderBuilder? placeholderBuilder,
bool transitionOnUserGestures = false,
required Widget child
})
Icon(
IconData? icon,
{
Key? key,
double? size,
double? fill,
double? weight,
double? grade,
double? opticalSize,
Color? color,
List<Shadow>? shadows,
String? semanticLabel,
TextDirection? textDirection,
bool? applyTextScaling
}
)
IconData(
int codePoint,
{
String? fontFamily,
String? fontPackage,
bool matchTextDirection = false,
List<String>? fontFamilyFallback
}
)
不接收事件,但子组件可以接收。
IgnorePointer({
Key? key,
bool ignoring = true,
@Deprecated(
'Use ExcludeSemantics or create a custom ignore pointer widget instead. '
'This feature was deprecated after v3.8.0-12.0.pre.'
)
bool? ignoringSemantics, Widget? child
})
InheritedWidget({Key? key, required Widget child})
didChangeDependencies方法会被调用。继承
Object > DiagnosticableTree > Widget > StatefulWidget > Image
构造函数
Image({
Key? key,
required ImageProvider\<Object> image,
ImageFrameBuilder? frameBuilder,
ImageLoadingBuilder? loadingBuilder,
ImageErrorWidgetBuilder? errorBuilder,
String? semanticLabel,
bool excludeFromSemantics = false,
double? width,
double? height,
Color? color,
Animation<double>? opacity,
BlendMode? colorBlendMode,
BoxFit? fit,
AlignmentGeometry alignment = Alignment.center,
ImageRepeat repeat = ImageRepeat.noRepeat,
Rect? centerSlice,
bool matchTextDirection = false,
bool gaplessPlayback = false,
bool isAntiAlias = false,
FilterQuality filterQuality = FilterQuality.medium
})
从资源文件夹(于pubspec.yaml中的flutter.assets配置)加载图片:
Image.asset(
String name,
{
Key? key,
AssetBundle? bundle,
ImageFrameBuilder? frameBuilder,
ImageErrorWidgetBuilder? errorBuilder,
String? semanticLabel,
bool excludeFromSemantics = false,
double? scale,
double? width,
double? height,
Color? color,
Animation<double>? opacity,
BlendMode? colorBlendMode,
BoxFit? fit,
AlignmentGeometry alignment = Alignment.center,
ImageRepeat repeat = ImageRepeat.noRepeat,
Rect? centerSlice,
bool matchTextDirection = false,
bool gaplessPlayback = false,
bool isAntiAlias = false,
String? package,
FilterQuality filterQuality = FilterQuality.medium,
int? cacheWidth,
int? cacheHeight
})
从文件加载图片:
Image.file(
File file,
{
Key? key,
double scale = 1.0,
ImageFrameBuilder? frameBuilder,
ImageErrorWidgetBuilder? errorBuilder,
String? semanticLabel,
bool excludeFromSemantics = false,
double? width,
double? height,
Color? color,
Animation<double>? opacity,
BlendMode? colorBlendMode,
BoxFit? fit,
AlignmentGeometry alignment = Alignment.center,
ImageRepeat repeat = ImageRepeat.noRepeat,
Rect? centerSlice,
bool matchTextDirection = false,
bool gaplessPlayback = false,
bool isAntiAlias = false,
FilterQuality filterQuality = FilterQuality.medium,
int? cacheWidth,
int? cacheHeight
})
从网络加载图片:
Image.network(
String src,
{
Key? key,
double scale = 1.0,
ImageFrameBuilder? frameBuilder,
ImageLoadingBuilder? loadingBuilder,
ImageErrorWidgetBuilder? errorBuilder,
String? semanticLabel,
bool excludeFromSemantics = false,
double? width,
double? height,
Color? color,
Animation<double>? opacity,
BlendMode? colorBlendMode,
BoxFit? fit,
AlignmentGeometry alignment = Alignment.center,
ImageRepeat repeat = ImageRepeat.noRepeat,
Rect? centerSlice,
bool matchTextDirection = false,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.medium,
bool isAntiAlias = false,
Map<String, String>? headers,
int? cacheWidth,
int? cacheHeight
}
)
属性
Listener({
Key? key,
PointerDownEventListener? onPointerDown,
PointerMoveEventListener? onPointerMove,
PointerUpEventListener? onPointerUp,
PointerHoverEventListener? onPointerHover,
PointerCancelEventListener? onPointerCancel,
PointerPanZoomStartEventListener? onPointerPanZoomStart,
PointerPanZoomUpdateEventListener? onPointerPanZoomUpdate,
PointerPanZoomEndEventListener? onPointerPanZoomEnd,
PointerSignalEventListener? onPointerSignal,
HitTestBehavior behavior = HitTestBehavior.deferToChild,
Widget? child
})
继承
Object > DiagnosticableTree > Widget > StatelessWidget > ScrollView > BoxScrollView > ListView
构造函数
在有足够简单的子组件的情况下使用:
ListView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
double? itemExtent,
ItemExtentBuilder? itemExtentBuilder,
Widget? prototypeItem,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
List<Widget> children = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
AutomaticKeepAlive中,令子组件超出屏幕时不会被垃圾回收。默认为true。RepaintBoundary中,令元素在第一次显示时被记住,即使滚出屏幕后再显示也无需重新绘制。内部使用IndexedWidgetBuilder,子组件仅在显示时才会被创建,即懒加载,适合在子组件较多的情况下使用:
ListView.builder({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
double? itemExtent,
ItemExtentBuilder? itemExtentBuilder,
Widget? prototypeItem,
required NullableIndexedWidgetBuilder itemBuilder,
ChildIndexGetter? findChildIndexCallback,
int? itemCount,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
增加元素间的分隔线:
ListView.separated({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
required NullableIndexedWidgetBuilder itemBuilder,
ChildIndexGetter? findChildIndexCallback,
required IndexedWidgetBuilder separatorBuilder,
required int itemCount,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
使用SliverChildDelegate提供自定义子组件的额外属性:
ListView.custom({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
double? itemExtent,
Widget? prototypeItem,
ItemExtentBuilder? itemExtentBuilder,
required SliverChildDelegate childrenDelegate,
double? cacheExtent,
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque
})
属性
ListView应沿滚动方向占用尽可能多的空间,仅当其处于一个相同滚动方向且无边界的父组件中并用于处理某些滚动冲突时,设置为true。Localizations({
Key? key,
required Locale locale,
required List<LocalizationsDelegate> delegates,
Widget? child
})
build方法被调用时,是否重新加载语系资源。通常为false。Navigator({
Key? key,
List<Page> pages = const <Page<dynamic>>[],
@Deprecated(
'Use onDidRemovePage instead. '
'This feature was deprecated after v3.16.0-17.0.pre.'
)
PopPageCallback? onPopPage,
String? initialRoute,
RouteListFactory onGenerateInitialRoutes = Navigator.defaultGenerateInitialRoutes,
RouteFactory? onGenerateRoute,
RouteFactory? onUnknownRoute,
TransitionDelegate transitionDelegate = const DefaultTransitionDelegate<dynamic>(),
bool reportsRouteUpdateToEngine = false,
Clip clipBehavior = Clip.hardEdge,
List<NavigatorObserver> observers = const <NavigatorObserver>[],
bool requestFocus = true,
String? restorationScopeId,
TraversalEdgeBehavior routeTraversalEdgeBehavior = kDefaultRouteTraversalEdgeBehavior,
DidRemovePageCallback? onDidRemovePage
})
通知会逐层上报。
NotificationListener({
Key? key,
required Widget child,
NotificationListenerCallback<T>? onNotification
})
Padding({
Key? key,
required EdgeInsetsGeometry padding,
Widget? child
})
显示GPU和CPU的性能图表。二者的理想状态是每秒60帧,即约16毫秒刷新一帧。
PerformanceOverlay.allEnabled({Key? key})
Positioned({
Key? key,
double? left,
double? top,
double? right,
double? bottom,
double? width,
double? height,
required Widget child
})
left、right、width只可使用其二;top、bottom、height只可使用其二。Route({RouteSettings? settings})
Row({
Key? key,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
MainAxisSize mainAxisSize = MainAxisSize.max,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
List<Widget> children = const <Widget>[]
})
mainAxisSize为MainAxisSize.min时,本属性不起作用,因为空间已被占满。TextDirection.ltr。VerticalDirection.down。ScrollController({
double initialScrollOffset = 0.0,
bool keepScrollOffset = true,
String? debugLabel,
ScrollControllerCallback? onAttach,
ScrollControllerCallback? onDetach
})
SingleChildScrollView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
EdgeInsetsGeometry? padding,
bool? primary,
ScrollPhysics? physics,
ScrollController? controller,
Widget? child,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Clip clipBehavior = Clip.hardEdge,
HitTestBehavior hitTestBehavior = HitTestBehavior.opaque,
String? restorationId,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
})
SizedBox({
Key? key,
double? width,
double? height,
Widget? child
})
SliverChildBuilderDelegate(
NullableIndexedWidgetBuilder builder,
{
ChildIndexGetter? findChildIndexCallback,
int? childCount,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
SemanticIndexCallback semanticIndexCallback = _kDefaultSemanticIndexCallback,
int semanticIndexOffset = 0
})
SliverFixedExtentList({
Key? key,
required SliverChildDelegate delegate,
required double itemExtent
})
SliverGrid({
Key? key,
required SliverChildDelegate delegate,
required SliverGridDelegate gridDelegate
})
Stack({
Key? key,
AlignmentGeometry alignment = AlignmentDirectional.topStart,
TextDirection? textDirection,
StackFit fit = StackFit.loose,
Clip clipBehavior = Clip.hardEdge,
List<Widget> children = const <Widget>[]
})
Positioned包裹的子组件或已使用Positioned包裹但没有充足定位信息的子组件使用。TextDirection.ltr。State()
setState)后被自动调用。StatefulElement(StatefulWidget widget)
StatefulWidget({Key? key})
StatelessElement(StatelessWidget widget)
StatelessWidget({Key? key})
继承
Object > DiagnosticableTree > Widget > StatelessWidget > Text
构造函数
Text(
String data,
{
Key? key,
TextStyle? style,
StrutStyle? strutStyle,
TextAlign? textAlign,
TextDirection? textDirection,
Locale? locale,
bool? softWrap,
TextOverflow? overflow,
@Deprecated(
'Use textScaler instead. '
'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
'This feature was deprecated after v3.12.0-2.0.pre.'
)
double? textScaleFactor,
TextScaler? textScaler,
int? maxLines,
String? semanticsLabel,
TextWidthBasis? textWidthBasis,
TextHeightBehavior? textHeightBehavior,
Color? selectionColor
}
)
Text.rich(
InlineSpan textSpan,
{
Key? key,
TextStyle? style,
StrutStyle? strutStyle,
TextAlign? textAlign,
TextDirection? textDirection,
Locale? locale,
bool? softWrap,
TextOverflow? overflow,
@Deprecated(
'Use textScaler instead. '
'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
'This feature was deprecated after v3.12.0-2.0.pre.'
)
double? textScaleFactor,
TextScaler? textScaler,
int? maxLines,
String? semanticsLabel,
TextWidthBasis? textWidthBasis,
TextHeightBehavior? textHeightBehavior,
Color? selectionColor
}
)
属性
overflow结合使用。TextEditingController({
String? text
})
无论怎样变换,组件的尺寸始终是未变换时的大小。
继承
Object > DiagnosticableTree > Widget > RenderObjectWidget > SingleChildRenderObjectWidget > Transform
构造函数
矩阵变换:
Transform({
Key? key,
required Matrix4 transform,
Offset? origin,
AlignmentGeometry? alignment,
bool transformHitTests = true,
FilterQuality? filterQuality,
Widget? child
})
旋转变换:
Transform.rotate({
Key? key,
required double angle,
Offset? origin,
AlignmentGeometry? alignment = Alignment.center,
bool transformHitTests = true,
FilterQuality? filterQuality,
Widget? child
})
缩放变换:
Transform.scale({
Key? key,
double? scale,
double? scaleX,
double? scaleY,
Offset? origin,
AlignmentGeometry? alignment = Alignment.center,
bool transformHitTests = true,
FilterQuality? filterQuality,
Widget? child
})
平移变换:
Transform.translate({
Key? key,
required Offset offset,
bool transformHitTests = true,
FilterQuality? filterQuality,
Widget? child
})
与交互有关的。
Widget({Key? key})
WillPopScope({
Key? key,
required Widget child,
required WillPopCallback? onWillPop
})
Future.value(true),表示正常推出页面。如回调返回Future.value(false)则不退出,停留在当前页面。Wrap({
Key? key,
Axis direction = Axis.horizontal,
WrapAlignment alignment = WrapAlignment.start,
double spacing = 0.0,
WrapAlignment runAlignment = WrapAlignment.start,
double runSpacing = 0.0,
WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
Clip clipBehavior = Clip.none,
List<Widget> children = const <Widget>[]
})
需至少构建过一次组件,且不能在build方法执行过程中调用。
void debugDumpApp()
转储信息实际上是把所有组件按树形结构罗列出来。如组件被标记为dirty,表示转储行为是通过该组件触发的。
Flutter Web 开发避坑指南:VS Code 保存无法