native_widgets 0.0.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new77

Native Widgets

pub package

A Flutter plugin to show the correct widgets for iOS and Android.

Avoid duplicating code and just write once for supported widgets.

Android will use Material Design and iOS will use Cupertino style widgets.

Usage

To use this plugin, add native_widgets as a dependency in your pubspec.yaml file.

Make sure you add the following permissions to your Android Manifest

// Import package
import 'package:native_widgets/native_widgets.dart';

Button

NativeButton(
    child: Text(
      'BUTTON TEXT HERE',
      textScaleFactor: 1.0,
    ),
    buttonColor: Colors.blue,
    padding: const EdgeInsets.all(10.0), // Add Padding (Optional)
    onPressed: () {
       // BUTTON PRESS ACTION HERE
    },
),

Switch

bool switchValue = false; // Set Inital Value
void handelChanged(bool value) {
 setState(() {
   switchValue = value; // Update the UI
 });
}
  
NativeSwitch(
    onChanged: handelChanged,
    value: switchValue,
),

Dialog

// Function to generate the dialog
void showNativeDialog<T>({BuildContext context, Widget child}) {
    showDialog<T>(
      context: context,
      builder: (BuildContext context) => child,
    );
}

// Show the Pop Up
void showNativePopUp(BuildContext context) {
showNativeDialog<null>(
  context: context,
  child: NativeDialog(
    title: "TITLE HERE",
    content:
        'DETAIL HERE',
    actions: <NativeDialogAction>[
      NativeDialogAction(
          text: 'BUTTON 1 TEXT',
          isDestructive: false, // Set True to indicate with red accent
          onPressed: () {
            Navigator.pop(context);
            // BUTTON 1 ACTION
          }),
      NativeDialogAction(
          text: 'BUTTON 2 TEXT',
          isDestructive: false,  // Set True to indicate with red accent
          onPressed: () {
            Navigator.pop(context);
            // BUTTON 2 ACTION
          }),
    ],
  ));
}

Loading Indicator

NativeLoadingIndicator();

Tab Bar

int _page = 0;
final _pageController = PageController();

void onPageChanged(int page) {
  setState(() {
    this._page = page;
  });
}

static const _kDuration = const Duration(milliseconds: 300);
static const _kCurve = Curves.ease;

void navigationTapped(int page) {
  _pageController.animateToPage(page, duration: _kDuration, curve: _kCurve);
}

@override
void dispose() {
  _pageController.dispose();
  super.dispose();
}

final List<Widget> _pages = <Widget>[
  ConstrainedBox(
    constraints: const BoxConstraints.expand(),
    child: Page1Widget(), // CHANGE TO YOUR PAGE
  ),
  ConstrainedBox(
    constraints: const BoxConstraints.expand(),
    child: Page2Widget(), // CHANGE TO YOUR PAGE
  ),
  ConstrainedBox(
    constraints: const BoxConstraints.expand(),
    child: Page3Widget(), // CHANGE TO YOUR PAGE
  ),
];

final Widget botNavBar = NativeBottomTabBar(
  currentIndex: _page,
  onTap: navigationTapped,
  activeColor: Colors.blueAccent,
  items: [
    BottomNavigationBarItem(
        icon: Icon(Icons.info),
        title: Text(
          "TAB 1",
          textScaleFactor: 1.0,
        )),
    BottomNavigationBarItem(
        icon: Icon(Icons.info),
        title: Text(
          "TAB 2",
          textScaleFactor: 1.0,
        )),
    BottomNavigationBarItem(
        icon: Icon(Icons.info),
        title: Text(
          "TAB 3",
          textScaleFactor: 1.0,
        )),
  ]);

[0.0.1] - Adding Components

  • Added Button, Switch, Dialog, Loading Indicator, and Tab Bar

Use this package as a library

1. Depend on it

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


dependencies:
  native_widgets: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:native_widgets/native_widgets.dart';
  
Version Uploaded Documentation Archive
0.0.1 Jul 10, 2018 Go to the documentation of native_widgets 0.0.1 Download native_widgets 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
54
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]
77
Learn more about scoring.

We analyzed this package on Jul 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7
  • Flutter: 0.5.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use native_widgets.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.11
meta 1.1.5 1.1.6
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test