preload_page_view 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

PreloadPageView #

Like the name, this is the widget to support Pre-load function for PageView widget.

For better user experience sometimes we need pre-load the images/web requests before user really scrolled to next PageView but the official PageView don't support that.So this is the time to use PreloadPageView.

Usage #

Everything is similar like PageView, you need PreloadPageView.builder and PreloadPageController to create the PreloadPageView.

Also you can use preloadPagesCount to set preload pages count when you need.

Example #

  @override
  Widget build(BuildContext context) {
    return new PreloadPageView.builder(
      itemCount: ...,
      itemBuilder: ...,
      onPageChanged: (int position) {...},
      .....
      preloadPagesCount: 3,
      controller: PreloadPageController(),
    );
  }

[0.0.2] #

  • Add 1 page pre-load function for PreloadPageView

[0.1.2] #

  • Add an example to library

[0.1.3] #

  • Add preloadPagesCount for preload multiple pages

[0.1.4] #

  • Bug fix

example/lib/main.dart

import 'package:example/page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:preload_page_view/preload_page_view.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PreloadPageView Demo',
      home: PreloadPageViewDemo(),
    );
  }
}

class PreloadPageViewDemo extends StatefulWidget {
  PreloadPageViewDemo({Key key}) : super(key: key);

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

class _PreloadPageViewState extends State<PreloadPageViewDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("PreloadPageView Demo"),
        ),
        body: Container(
            child: PreloadPageView.builder(
          preloadPagesCount: 5,
          itemBuilder: (BuildContext context, int position) => DemoPage(position),
          controller: PreloadPageController(initialPage: 1),
          onPageChanged: (int position) {
            print('page changed. current: $position');
          },
        )));
  }
}

Use this package as a library

1. Depend on it

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


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

We analyzed this package on Apr 8, 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 suggestions

Format lib/preload_page_view.dart.

Run flutter format to format lib/preload_page_view.dart.

Maintenance suggestions

Package is getting outdated. (-5.48 points)

The package was last published 55 weeks ago.

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.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test