Skip to content

RodrigoBertotti/flutter_url_image_load_fail

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

flutter_url_image_load_fail

Flutter Widget that allows load images from an URL and define the Widgets that will be shown on loading, loaded with success and failed to load states

Getting Started

Alt Text

Add the dependency on pubspec.yaml

dependencies:
  flutter_url_image_load_fail: ^1.0.0

Import the Widget

import 'package:flutter_url_image_load_fail/flutter_url_image_load_fail.dart';

Instantiate the LoadImageFromUrl Widget and use it

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('flutter_url_image_load_fail example'),
      ),
      body: Center(
        child: LoadImageFromUrl(
          imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png', //Image URL to load
          buildSuccessWidget:  (image) => image,
          buildLoadingWidget:  () => Text('Loading...'),
          buildFailedWidget: (retryLoadImage, code, message){
              return ElevatedButton(
                child: Text('Try Again'),
                onPressed: (){
                  retryLoadImage();
                },
              );
            },
            requestTimeout: Duration(seconds: 5) //Optionally set the timeout
        ),
      ),
    );
  }

About

Flutter - Load a Image and depending of the state show a loading icon or error message

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published