Este pacote inclui uma série de componentes com estilo Cupertino que tornam a seleção de data e hora fluida e visualmente consistente com os princípios de design do iOS.
Orientação gerada a partir de informações públicas. Apenas para referência.
Um pacote Flutter que fornece seletores de data e hora no estilo Cupertino, garantindo uma experiência fluida e visualmente coerente alinhada aos princípios de design do iOS. Oferece componentes semelhantes aos nativos para seleção de datas e horários em múltiplas plataformas, incluindo Android, iOS, Web, macOS, Windows e Linux. O pacote melhora a consistência da interface do usuário em aplicativos voltados para a estética da Apple, mantendo funcionalidade multiplataforma.
Casos de uso
Seleção de data do estilo iOS em aplicativos multiplataforma
visualizações de calendário integradas nos recursos de agendamento
rastreamento de tempo com interface consistente
entradas de formulário que exigem seleção de data
melhorando a UX com design específico para plataforma
seletores de data personalizáveis para aplicativos móveis
Principais recursos
Seletor de data com tema Cupertino
compatibilidade multiplataforma
integração contínua com o Flutter
Adesão à linguagem de design do iOS
aparência personalizável
suporte para múltiplas plataformas
Indicado para
desenvolvedores direcionados para a estética do iOS
aplicativos que precisam de entrada de data consistente
aplicativos móveis multiplataforma
implementações de UI voltadas para o design
equipes priorizando aparência e sensação nativas
Considerações
personalização limitada além do estilo Cupertino
pode não ser adequado para temas de design não-iOS
exige manipulação cuidadosa em plataformas não-iOS
dependência dos widgets Cupertino do Flutter
impacto potencial no desempenho com calendários grandes
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
The package provides a sleek and stylish cupertino calendar widgets designed to mimic the aesthetics of iOS. With smooth animations and intuitive user interactions, it seamlessly integrates into your Flutter app to deliver a delightful user experience.
Features
iOS Style: The cupertino calendar picker follows the design principles of iOS, ensuring consistency and familiarity for iOS users.
Smooth Animations: Enjoy fluid animations that enhance the overall look and feel of the calendar, providing a polished user experience.
Customizable: Easily customize the appearance of the calendar to match your app's theme and branding.
Intuitive Interactions: Users can effortlessly navigate through years, months and interact with the calendar thanks to its intuitive design.
Getting started
In the pubspec.yaml of your flutter project, add the following dependency:
You can add actions to the calendar picker by passing a list of CupertinoCalendarAction objects.
The package provides two built-in actions: CancelCupertinoCalendarAction and ConfirmCupertinoCalendarAction.
Call the showCupertinoCalendarPicker passing date constrains and widget's RenderBox of the widget above/below which you wish to display the calendar.
@overrideWidgetbuild(BuildContext context) {
returnCupertinoApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: CupertinoPageScaffold(
child: Builder(
builder: (context) {
/// Passing exactly this `BuildContext` is mandatory here to /// get the `RenderBox` of the appropriate widget.returnYourWidget(
onTap: () => onTap(context),
);
},
),
),
);
}
/// The `BuildContext` comes from the `Builder` above the widget tree.Future<void> onTap(BuildContext context) {
final renderBox = context.findRenderObject() asRenderBox?;
final nowDate = DateTime.now();
returnshowCupertinoCalendarPicker(
context,
widgetRenderBox: renderBox,
minimumDate: nowDate.subtract(constDuration(days: 15)),
initialDate: nowDate,
maximumDate: nowDate.add(constDuration(days: 360)),
);
}
How to get a RenderBox?
There are 3 simple ways of how you can get the widget's render box to pass it to the showCupertinoCalendarPicker or showCupertinoTimePicker function.
You can choose any of these.
Wrap your widget with Builder widget.
Builder(
builder: (context) {
returnYourWidget(
onTap: () => onTap(context),
);
},
);
Future<void> onTap(BuildContext context) {
/// And here you can get the `RenderBox` of your widget /// using the `Builder`s `BuildContext`final renderBox = context.findRenderObject() asRenderBox?;
returnshowCupertinoCalendarPicker(...);
}
Use a GlobalKey.
final globalKey = GlobalKey();
@overrideWidgetbuild(BuildContext context) {
returnCupertinoApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: CupertinoPageScaffold(
child: YourWidget(
key: globalKey,
onTap: onTap,
),
),
);
}
Future<void> onTap(BuildContext context) {
/// And here you can get the `RenderBox` of your widget using the `GlobalKey`.final renderBox = globalKey.currentContext?.findRenderObject() asRenderBox?;
returnshowCupertinoCalendarPicker(...);
}
Pass a BuildContext directly from your widget's build method.
classYourWidgetextendsStatelessWidget{
constYourWidget({
requiredthis.onTap,
});
finalvoidFunction(BuildContext context) onTap;
@overrideWidgetbuild(BuildContext context) {
returnGestureDetector(
onTap: () => onTap(context),
child: ...,
);
}
}
Future<void> onTap(BuildContext context) {
/// And here you can get the `RenderBox` of your widget's `build` method.final renderBox = context.findRenderObject() asRenderBox?;
returnshowCupertinoCalendarPicker(...);
}