useful_widgets 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

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.

    future: (context) => myFutureRequest,
    retry: (context) => retryMyFutureRequest(),
    builder: (context, result) => Text(result),

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

Example: Weather Forecast

RefreshWidget #

Simple widget to implement pull refresh in yours ListView.

    future: (context) => myFutureItems,
    builder: (context, result) => ListView.separated(
      itemCount: result.length,
      itemBuilder: (context, index) => Text(result[index]),
      separatorBuilder: (context, index) => Divider(),

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>> {

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

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

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

    buildItem(BuildContext context, CityModel city) {
        return ListTile(
            title: buildItemTitle(city),
            onTap: () {

    buildItemTitle(CityModel city) {
        return Row(
            children: <Widget>[
            Padding(padding: EdgeInsets.all(2),),
            Padding(padding: EdgeInsets.all(2),),

Example: Weather Forecast

Customize package locations #

First let's create the custom internationalization that will extend the default package location. You should override customValues and enter only the messages you want to change.

import 'package:useful_widgets/useful_widgets.dart';

class CustomLocalization extends UsefulWidgetsLocalizations {
  CustomLocalization(Locale locale) : super(locale);
  Map<dynamic, Map<dynamic, String>> get customValues => {
    'en': {
      WidgetMessages.message1: 'Custom first message',
      WidgetMessages.message2: 'Custom second message',
    'es': {
      WidgetMessages.message1: 'Primer mensaje personalizado',
      WidgetMessages.message2: 'Segundo mensaje personalizado',
    'pt': {
      WidgetMessages.message1: 'Primeira mensagem personalizada',
      WidgetMessages.message2: 'Segunda mensagem personalizada',

And finally, inform the delegate in localizationsDelegates of your apps MaterialApp.

  localizationsDelegates: [
    UsefulWidgetsLocalizationsDelegate((locale) => CustomLocalization(locale)),

1.2.0 #

  • Created 'UsefulWidgetsLocalizationsDelegate' class to allow package internationalization customization
  • updated with example of how to customize package internationalization

1.1.0 #

  • Internationalization added for English, Spanish and Portuguese.

1.0.0 #

  • Added FutureWidget, RefreshWidget, SearchWidget


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:

  useful_widgets: ^1.2.0

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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/localizations/localizations_enums.dart.

Run flutter format to format lib/localizations/localizations_enums.dart.

Format lib/localizations/useful_widgets_localization.dart.

Run flutter format to format lib/localizations/useful_widgets_localization.dart.

Format lib/useful_widgets.dart.

Run flutter format to format lib/useful_widgets.dart.

Fix additional 11 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/widgets/future/await_widget.dart (Run flutter format to format lib/widgets/future/await_widget.dart.)
  • lib/widgets/future/error_widget.dart (Run flutter format to format lib/widgets/future/error_widget.dart.)
  • 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/icon_search_button.dart (Run flutter format to format lib/widgets/search/icon_search_button.dart.)
  • lib/widgets/search/search_widget.dart (Run flutter format to format lib/widgets/search/search_widget.dart.)
  • lib/widgets/stepper/inherited_stepper.dart (Run flutter format to format lib/widgets/stepper/inherited_stepper.dart.)
  • lib/widgets/stepper/step_widget.dart (Run flutter format to format lib/widgets/stepper/step_widget.dart.)
  • lib/widgets/stepper/stepper_widget.dart (Run flutter format to format lib/widgets/stepper/stepper_widget.dart.)
  • lib/widgets/tab_button/tab_button.dart (Run flutter format to format lib/widgets/tab_button/tab_button.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_cupertino_localizations ^1.0.1 1.0.1
flutter_localizations 0.0.0
simple_localization ^1.1.1 1.1.1
Transitive dependencies
collection 1.14.11 1.14.12
intl 0.16.0 0.16.1
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
pedantic ^1.8.0