native_widgets 0.1.1+1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 92

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.

// 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();

NativeLoadingIndicator(text: Text('Loading...'));

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,
        )),
  ]);

App Bar

appBar: NativeAppBar(
  title: Text('Title Here'),
  backgroundColor:
      Platform.isIOS ? null : globals.isDark ? null : Colors.white,
  leading: IconButton(
    icon: Icon(
      Icons.settings,
      color: globals.isDark ? Colors.white : Colors.black,
    ),
    onPressed: () {
      Navigator.pushNamed(context, '/settings');
    },
  ),
  actions: <Widget>[
    IconButton(
      icon: Icon(Icons.delete_sweep,
          color: globals.isDark ? Colors.white : Colors.black),
      onPressed: null,
    ),
    IconButton(
      icon: Icon(Icons.share,
          color: globals.isDark ? Colors.white : Colors.black),
      onPressed: null,
    ),
  ],
),

[0.1.1] - Bug Fixes and Breaking Changes

  • Native button will now default to 16.0 padding internal

[0.1.0] - Bug Fixes and Breaking Changes

  • Native button will now use Material Button on Android instead of raised button
  • You can specify android specific options and cupertino ios options
  • There is now internal and external paddign for buttons

[0.0.4] - Bug Fixes

  • Bug Fix for Center Loading Indicator

[0.0.3] - Adding Components

  • Bug Fix for App Bar

[0.0.2] - Adding Components

  • Added App Bar and optional text for Loading Indicator

[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.1.1+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.1.1+1 Jul 27, 2018 Go to the documentation of native_widgets 0.1.1+1 Download native_widgets 0.1.1+1 archive
0.1.1 Jul 27, 2018 Go to the documentation of native_widgets 0.1.1 Download native_widgets 0.1.1 archive
0.1.0 Jul 27, 2018 Go to the documentation of native_widgets 0.1.0 Download native_widgets 0.1.0 archive
0.0.4 Jul 27, 2018 Go to the documentation of native_widgets 0.0.4 Download native_widgets 0.0.4 archive
0.0.3 Jul 25, 2018 Go to the documentation of native_widgets 0.0.3 Download native_widgets 0.0.3 archive
0.0.2 Jul 25, 2018 Go to the documentation of native_widgets 0.0.2 Download native_widgets 0.0.2 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]
87
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

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.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test