Buscar pacotes, repositórios e categorias de apps

Repositório GitHubcaseyryan/flutter_cupertino_bottom_sheet

flutter_cupernino_bottom_sheet

Um pacote que simula uma folha inferior em estilo Cupertino em tela cheia

Capa do projeto flutter_cupernino_bottom_sheet
Estrelas
10
Forks
3
Último push (UTC)
14 de out. de 2024
Status do projeto
Ativo

README original

Texto original em inglês. Visite o GitHub para a versão atual.

A package that mimics a Cupertino bottom sheet like this VERY EASILY

pub.devstyle: effective dart Awesome Flutter

Apr-20-2023 11-43-53

Unlike existing packages that can mimic the same behavior flutter_cupertino_bottom_sheet does not require a scaffold for this purpose and can be used from any place and any time. You don't have to use any special code except for wrapping your MaterialApp with CupertinoBottomSheetRepaintBoundary() at the beginning. And that's it. That simple. You don't even need a specific context for it to work

How it works.

It's very simple. Internally it uses a repaint boundary to create a screenshot of the whole screen and make a RawImage out of it. So it doesn't matter if the previous route maintains its state or not. It doesn't really need to know anything about the previous route as it uses a screenshot instead of a widget snapshot

Getting started

import the package where you initialize your app

import 'package:flutter_cupertino_bottom_sheet/flutter_cupertino_bottom_sheet.dart';

And then wrap your MaterialApp or whatever type you use with CupertinoBottomSheetRepaintBoundary

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return CupertinoBottomSheetRepaintBoundary(
      child: MaterialApp(
        ...
      ),
    );
  }
}

This will provide a necessary RenderRepaintBoundary for the library to work.

Then you can use a Navigator to push this route like this:

Navigator.of(context).push(
    CupertinoBottomSheetRoute(
        args: const CupertinoBottomSheetRouteArgs(
            swipeSettings: SwipeSettings(
            canCloseBySwipe: true,
            ),
        ),
        builder: (context) {
            return const TestPage();
        },
    ),
);
Want less code? No problem.

Pass a cupertinoBottomSheetNavigatorKey to your App initialization

@override
Widget build(BuildContext context) {
  return CupertinoBottomSheetRepaintBoundary(
    child: MaterialApp(
      navigatorKey: cupertinoBottomSheetNavigatorKey,
      ...
    ),
  );
}

And then call openCupertinoBottomSheet() from any place, regardless of context

openCupertinoBottomSheet(builder: (c) {
    return const TestPage();
    args: CupertinoBottomSheetRouteArgs(
      appBar: CupertinoBottomSheetAppBar.withCloseButton(
        title: 'Cupertino Actionsheet',
        buttonText: 'Done',
        headerStyle: Theme.of(context).textTheme.bodyMedium,
        onClosePressed: Navigator.of(context).pop,
      ),
    ),
});
Konstantin Serov GitHub avatar
Autor no GitHub

Konstantin Serov ↗

Senior Flutter / Dart developer passionate for cool complex modern UI designs. 8+ years of commercial work on Flutter and 9+ years of other technologies

Serov KonstantinNovosibirskSite oficial ↗
LinguagensDartC++CMakeRubyHTMLCSwiftKotlinObjective-C

Dependências usadas

Lista de dependências 4 itens

Como escolher um repositório para seu projeto?

Filtre pelo caso de uso, compare a atividade e confira o projeto original antes de adotá-lo.

  1. Busque por nome, autor ou descrição e filtre por tema.
  2. Compare estrelas, forks e envios recentes. Estrelas indicam interesse, mas não garantem qualidade.
  3. Confira o README, a licença e as issues no GitHub antes de usar o projeto.

Fontes e manutenção

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗