Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

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 of these useful widgets

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),
);
sucess error
future_widget_sucess future_useful-widgets_error

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
refresh_widget

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
search_widget

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);
  
  @override
  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.

materialapp(
  localizationsdelegates: [
    usefulwidgetslocalizationsdelegate((locale) => customlocalization(locale)),
  ],
)

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Top