useful_widgets 1.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

useful_widgets #

This package makes it easy to build apps by providing a list of simple and useful widgets.

import 'package:useful_widgets/useful_widgets.dart';

List of Widgets available in this package

  • FutureWidget
  • RefreshWidget
  • SearchWidget

Below I will explain how each widget is used

FutureWidget #

Simple widget to load Future requests, showing a loading screen and, if accour error, show error screen.

FutureWidget<String>(
    future: (context) => myFutureRequest,
    retry: (context) => retryMyFutureRequest(),
    builder: (context, result) => Text(result),
);
SucessError
PieChartPieChart

The 'Retry' button only is showed if retry parameter is informed.

Example: Weather Forecast

RefreshWidget #

Simple widget to implement pull refresh in yours ListView.

RefreshWidget<List<String>>(
    future: (context) => myFutureItems,
    builder: (context, result) => ListView.separated(
      itemCount: result.length,
      itemBuilder: (context, index) => Text(result[index]),
      separatorBuilder: (context, index) => Divider(),
    ),
);
Refresh
PieChart

Example: Weather Forecast

SearchWidget #

This widget help you to create a simple Search page, you need create a class and extend SearchWidget.

class CitySearchWidget extends SearchWidget<List<CityModel>> {
    CitySearchWidget();

    @override
    Widget buildResult(BuildContext context, List<CityModel> result) {
        return ListView.separated(
            itemCount: result.length,
            itemBuilder: (context, index) => buildItemView(context, result[index]),
            separatorBuilder: (context, index) => Divider(),
        );
    }

    @override
    bool canSearch(BuildContext context, String query) {
        return query.length > 3;
    }

    @override
    Future<List<CityModel>> search(String query) {
        return Module.of<AppModule>().service<OpenWeatherApi>().searchCities(query);
    }

    buildItem(BuildContext context, CityModel city) {
        return ListTile(
            leading: Image.network('http://openweathermap.org/img/wn/${city.weather[0].icon}@2x.png'),
            title: buildItemTitle(city),
            onTap: () {
                Module.of<AppModule>().service<AppService>().updateCurrentCity(context, city.id);
                close(context);
            },
        );
    }

    buildItemTitle(CityModel city) {
        return Row(
            children: <Widget>[
            Image.network('http://openweathermap.org/images/flags/${city.sys.country.toLowerCase()}.png'),
            Padding(padding: EdgeInsets.all(2),),
            Text(city.name),
            Padding(padding: EdgeInsets.all(2),),
            ],
        );
    }
}
Search
PieChart

Example: Weather Forecast

1.0.0+1 #

  • Email added to pubspec.yaml

1.0.0 - 2019-01-03 #

  • Added FutureWidget, RefreshWidget, SearchWidget

example/README.md

useful_widgets examples #

Weather Forecast #

Simple weather forecast app using future FutureWidget, RefreshWidget, SearchWidget.

Use this package as a library

1. Depend on it

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


dependencies:
  useful_widgets: ^1.0.0+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:useful_widgets/useful_widgets.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
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]
50
Learn more about scoring.

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

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/useful_widgets.dart.

Run flutter format to format lib/useful_widgets.dart.

Format lib/widgets/future/await_widget.dart.

Run flutter format to format lib/widgets/future/await_widget.dart.

Format lib/widgets/future/error_widget.dart.

Run flutter format to format lib/widgets/future/error_widget.dart.

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/widgets/future/future_widget.dart (Run flutter format to format lib/widgets/future/future_widget.dart.)
  • lib/widgets/refresh/refresh_widget.dart (Run flutter format to format lib/widgets/refresh/refresh_widget.dart.)
  • lib/widgets/search/active_page_enum.dart (Run flutter format to format lib/widgets/search/active_page_enum.dart.)
  • lib/widgets/search/search_widget.dart (Run flutter format to format lib/widgets/search/search_widget.dart.)

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.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.8.0