widget_extensions 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

widget_extensions #

An Extension library for Flutter Widgets.

Getting Started #

This Lib helps by providing utility functions for Flutter Widgets. These Methods are written using extension methods provided by dart sdk 2.6.0. See the below Supported Widget Section for the implemented Widgets. This is mainly useful for dynamic widgets which will be implemented in code push project for flutter, as well as useful for updatable widgets for your custom implementations.

Install #

widget_extensions: ^0.0.4

Example #

Text('').fromMap({
    'data' : 'This is Extension Widget Library'
});

if more than one same widget is used we can instantiate single Widget at once and modify in next itirations.

Text text = Text('');

text.fromMap({
    'data' : 'This is Extension Widget Library'
});

text.fromMap({
    'data' : 'You can Contribute to this Library by extending Other Widgets',
    'style': Theme.of(context).textTheme.display1.toMap(),
});

you can see normal example by git clone and run this repo.

Contributing to Library #

All Contributions are welcome and thankful You can contribute to this library if you can or like those extensions.

There should be four methods in a widget to be Extended

toMap()

fromMap(jsonMap)

toJson()

fromJson(json)

see container extension file for reference.

Issues #

feel free to open an issue for bugs or improvements.

Supported Widgets #

[0.0.4] : 12-12-2019 #

  • Updated sdk Constraints
  • Now You can Use library with latest flutter stable i.e v1.12.13
  • Removed imports.dart helper that misbihaves while generating docs.

[0.0.3] : 08-12-2019 #

  • Added RaisedButton Extension Method
  • Added Placeholder Extension Method
  • Added Expanded Extension Method
  • Added AspectRatio Extension Method
  • Added SizedBox Extension Method
  • Added ClipRRect Extension Method

[0.0.2] : 08-12-2019 #

  • Added Row Extension Method
  • Added Column Extension Method
  • Added Stack Extension Method
  • Added Centre Extension Method
  • Added Wrap Extension Method
  • Added Opacity Extension Method
  • Added Align Extension Method
  • Added Padding Extension Method

[0.0.1] : 02-12-2019 #

  • Initial Release
  • Added Container Extension Method
  • Added Text Extension Method
  • Added TextSpan Extension Method
  • Added TextStyle Extension Method

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:widget_extensions/widget_extensions.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  Text txt = Text('');

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: txt.fromMap({'data': '${widget.title}'}),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            txt.fromMap(
                {'data': 'You have pushed the button this many times:'}),
            txt.fromMap({
              'data': '$_counter',
              'style': Theme.of(context).textTheme.display1.toMap(),
            }),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  widget_extensions: ^0.0.4

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:widget_extensions/widget_extensions.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-0.77 points)

261 out of 263 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

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