Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev1.2.1

cupertino_will_pop_scope

Habilita callbacks 'onWillPop' em transições de página Cupertino e melhora o feedback visual de gestos de 'deslize para voltar' rejeitados.

AndroidiOSWebmacOSWindowsLinux
Downloads em 30 dias
8,9 mil
Curtidas
58
Pontos Pub
140

Instalar pacote

flutter pub add cupertino_will_pop_scope

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

O pacote cupertino_will_pop_scope estende os widgets Cupertino do Flutter habilitando callbacks onWillPop durante transições de página na navegação com estilo iOS. Ele melhora a experiência do usuário ao fornecer feedback visual quando um gesto de deslizar para voltar é rejeitado, garantindo uma navegação mais suave e intuitiva. Esse pacote é especialmente útil para aplicativos que exigem lógica personalizada de confirmação antes de navegar de volta, como validação de formulários ou alterações não salvas. Ele se integra perfeitamente às implementações existentes de CupertinoPageScaffold e CupertinoPageRoute.

Casos de uso

  • Tratamento de alterações não salvas antes da navegação
  • Validação de gesto personalizado de volta
  • Melhorando a UX na navegação do estilo iOS
  • Evitando navegação acidental
  • Implementando diálogos de confirmação no toque de retorno
  • Melhorando o feedback de deslize para trás

Principais recursos

  • Suporte a onWillPop em transições Cupertino
  • Feedback visual para gestos de deslize rejeitados
  • Funciona com CupertinoPageScaffold e rotas
  • Integração com boilerplate mínimo
  • Compatibilidade multiplataforma
  • API limpa para controle de gesto de retorno

Indicado para

  • Aplicativos com estilo iOS usando navegação Cupertino
  • Aplicativos que precisam de lógica personalizada de navegação de volta
  • Desenvolvedores aprimorando a experiência do usuário com o gesto de retorno por deslize
  • Projetos que exigem confirmação antes de pop
  • Equipes construindo navegação móvel consistente
  • Aplicativos Flutter direcionados a múltiplas plataformas

Considerações

  • Requer o uso do CupertinoPageScaffold
  • Limitado a padrões de navegação do estilo iOS
  • Pode entrar em conflito com outros interceptores de rota
  • Não necessário para aplicativos de design material
  • Melhor usado com tratamento explícito de volta
  • Não afeta o comportamento de voltar do Android

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

CupertinoWillPopScope

pub package

Note: This package can be used on any platform, and is not specific to iOS. ConditionalWillPopScope and CupertinoWillPopScopePageTransionsBuilder can each be used seprately.


CupertinoWillPopScopePageTransionsBuilder

The key to this package is a modified version of Flutter's CupertinoPageRoute, which has been enhanced with the following:

  • Visual feedback when users attempt to "swipe to go back" - the screen is allowed to be dragged a bit before it is snapped back to place.
  • If an enclosing route has willPop callbacks, they are triggered once the screen is snapped back to place.
ConditionalWillPopScope

When using this widget, be sure to update shouldAddCallbacks based on the state of your screen, and only set it to true when the screen should not be allowed to pop. Additionally, the onWillPop property should not be changed once set.


A working app using this package can be found in the example folder.

Usage

To use this package, add cupertino_will_pop_scope as a dependency in your pubspec.yaml file.

Example

Import the library
// main.dart
import 'package:decorated_icon/cupertino_will_pop_scope.dart';
Configure page transitions

Set the transition builder of the desired platform to CupertinoWillPopScopePageTransionsBuilder in your theme configuration.

// main.dart
theme = ThemeData(
  ...
  pageTransitionsTheme: PageTransitionsTheme(
    builders: {
      TargetPlatform.android: ZoomPageTransitionsBuilder(),
      TargetPlatform.iOS: CupertinoWillPopScopePageTransionsBuilder(),
    },
  ),
);
Make sure the theme is applied to the app.
// main.dart
MaterialApp(
  ...
  theme: theme,
  home: HomeScreen(),
);
Wrap your screen

Using the included ConditionalWillPopScope widget, or Flutter's WillPopScope widget, wrap your screen and define an onWillPop callback for it.

Note that onWillPop should always return a bool. See the Flutter Docs for more.
Using ConditionalWillPopScope:
// my_screen.dart
@override
Widget build(BuildContext context) {
  return ConditionalWillPopScope(
    child: _MyScreenContent(),
    onWillPop: _onWillPop,
    shouldAddCallbacks: _hasChanges,
  );
}
Using WillPopScope:
// my_screen.dart
@override
Widget build(BuildContext context) {
  return WillPopScope(
    child: _MyScreenContent(),
    onWillPop: _hasChanges ? _onWillPop : null,
  );
}

:warning: When using Flutter's WillPopScope widget, the onWillPop must be set conditionally. Otherwise, the "swipe to go back" gesture will be cancelled. In the example above, this is achieved by using _hasChanges as the condition.

Categorias

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.