createLeading static method
KeyedSubtree?
createLeading({
- required GlobalKey<
State< leadingKey,StatefulWidget> > - required Widget? userLeading,
- required ModalRoute? route,
- required bool automaticallyImplyLeading,
- required EdgeInsetsDirectional? padding,
Implementation
static KeyedSubtree? createLeading({
required GlobalKey leadingKey,
required Widget? userLeading,
required ModalRoute<dynamic>? route,
required bool automaticallyImplyLeading,
required EdgeInsetsDirectional? padding,
}) {
Widget? leadingContent;
if (userLeading != null) {
leadingContent = userLeading;
} else if (automaticallyImplyLeading &&
route is PageRoute &&
route.canPop &&
route.fullscreenDialog) {
leadingContent = CupertinoButton(
padding: EdgeInsets.zero,
onPressed: () {
route.navigator!.maybePop();
},
child: const Text('Close'),
);
} else if (!automaticallyImplyLeading && userLeading == null) {
/// this will help animate things whatever it takes
leadingContent = const SizedBox();
}
if (leadingContent == null) {
return null;
}
return KeyedSubtree(
key: leadingKey,
child: Padding(
padding: EdgeInsetsDirectional.only(
start: padding?.start ?? 0,
),
child: IconTheme.merge(
data: const IconThemeData(
size: 32.0,
),
child: leadingContent,
),
),
);
}