adaptive_widgets_flutter 0.0.6 copy "adaptive_widgets_flutter: ^0.0.6" to clipboard
adaptive_widgets_flutter: ^0.0.6 copied to clipboard

A Flutter package for supporting adaptive widgets for iOS and Android platform.

example/lib/main.dart

import 'package:adaptive_widgets_flutter/adaptive_widgets.dart';
import 'package:adaptive_widgets_flutter/bottom_action_sheet/adaptive_bottom_action_sheet.dart';
import 'package:adaptive_widgets_flutter/dialog/adaptive_dialog.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Adaptive Widgets',
      home: Home(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Adaptive Widgets'),
      ),
      body: AdaptiveWidgets.buildRefreshableScrollView(
        context,
        onRefresh: () async {
          await Future.delayed(const Duration(seconds: 2));
        },
        slivers: [
          const SliverPadding(padding: EdgeInsets.only(top: 20)),
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: CupertinoButton.filled(
                onPressed: () async {
                  await AdaptiveWidgets.showDatePicker(context);
                },
                child: const Text('Show Date Picker'),
              ),
            ),
          ),
          const SliverPadding(padding: EdgeInsets.only(top: 20)),
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: CupertinoButton.filled(
                onPressed: () async {
                  await AdaptiveWidgets.showDialog(
                    context,
                    title: 'Sample Title',
                    content: 'Sample Content',
                    actionButtons: [
                      AdaptiveDialogButtonBuilder(
                        text: 'OK',
                        onPressed: (context) {
                          Navigator.of(context).pop();
                        },
                      ),
                    ],
                  );
                },
                child: const Text('Show Dialog'),
              ),
            ),
          ),
          const SliverPadding(padding: EdgeInsets.only(top: 20)),
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: CupertinoButton.filled(
                onPressed: () async {
                  final actionButtons = [
                    AdaptiveBottomSheetButtonBuilder(
                      text: 'Action 1',
                      onPressed: (context) => Navigator.of(context).pop('action 1'),
                    ),
                    AdaptiveBottomSheetButtonBuilder(text: 'Action 2'),
                    AdaptiveBottomSheetButtonBuilder(text: 'Cancel', isCancelAction: true),
                    AdaptiveBottomSheetButtonBuilder(text: 'Action 3'),
                  ];

                  final result = await AdaptiveBottomActionSheet(Theme.of(context).platform).show(
                    context,
                    actionButtons: actionButtons,
                  );
                  debugPrint(result);
                },
                child: const Text('Show Bottom Action Sheet'),
              ),
            ),
          )
        ],
      ),
    );
  }
}
7
likes
0
points
60
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for supporting adaptive widgets for iOS and Android platform.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, flutter

More

Packages that depend on adaptive_widgets_flutter