adaptable_widget 0.2.1

adaptable_widget #

A collection of widgets that adapt to match the preferred style of the current platform

Why? #

Flutter is a great development platform, but often different platforms require different UI components to match the style the user is most familiar with (i.e. Material on Android and Cupertino on iOS). This platform aims to make detecting and switching between those platforms as simple as throwing it in another widget that does all the work.

Getting Started #

The simplest use case is just the AdaptableWidget:

Widget build() {
  return AdaptableWidget(
    android: AndroidWidget(...),
    ios: CupertinoWidget(...),
    fuschia: FuschiaWidget(...),
    windows: WindowsWidget(...), //Currently not supported
    macos: MacOSWidget(...), //Currently not supported
    web: WebWidget(...), //Support coming soon
  );
}

Other Widgets #

These other widgets wrap the AdaptableWidget to provide common-use-case adaptations with less boilerplate.


AdaptableApp #

This is an easy way to switch between MaterialApp and CupertinoApp so that the material and cupertino widgets have the proper ancestors.

Example #

Widget build() {
  return AdaptableApp(
    title: "My App",
    materialTheme: ThemeData(...),
    cupertinoTheme: CupertinoThemeData(...),
    home: MyHomePage(...),
  );
}

AdaptableScaffold #

The aim of AdaptableScaffold is to switch between Scaffold or CupertinoScaffoldPage without having to write the child UI code twice.

Example #

Widget build() {
  return AdaptableScaffold(
    child: MyHomePage(), //Required
    appBar: AppBar(...),
    cupertinoNavigationBar: cupertinoNavigationBar(...),
    backgroundColor: Colors.white,
    resizeToAvoidBottomInset: true,
  );
}

AdaptableButton #

Buttons are one Widget that often have a certain look and feel on different platforms. This AdaptableButton class provides simply a child and an onPressed callback.

Example #

Widget build() {
  return AdaptableButton(
    child: Text("Tap Me!"),
    onPressed: doSomething,
  );
}

AdaptableTextField #

Switches between TextField and CupertinoTextField based on the platform.

Helper Functions #

adaptableTextStyle #

This function returns a TextStyle or based on the Platform.

[0.2.1] - May 27, 2019

  • Add decoration properties to AdaptableTextField widget.

[0.2.0] - May 27, 2019

  • Make AdaptableWidget stateful.

[0.1.4] - May 27, 2019

  • Add AdaptableText widget.

[0.1.3] - May 27, 2019

  • Add adaptableTextStyle function.

[0.1.2] - May 25, 2019

  • Add AdaptableTextField widget.

[0.1.1] - May 25, 2019

  • Add AdaptableApp widget.

[0.1.0] - May 25, 2019

  • Initial release

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  adaptable_widget: ^0.2.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:adaptable_widget/adaptable_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
8
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Aug 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test