parallax_image_ns 0.3.2 copy "parallax_image_ns: ^0.3.2" to clipboard
parallax_image_ns: ^0.3.2 copied to clipboard

null safe safty correction. A Flutter widget that paints an image and moves it at a slower speed than the main scrolling content.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:parallax_image_ns/parallax_image.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Parallax Image Demo',
      theme: new ThemeData(primarySwatch: Colors.blueGrey),
      home: new MyHomePage(title: 'Parallax Image Demo'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return new Scaffold(
      appBar: new AppBar(title: new Text(title)),
      body: new Column(
        children: <Widget>[
          new Container(
            padding: const EdgeInsets.all(20.0),
            child: new Text(
              'Horizontal scroll parallax',
              style: theme.textTheme.titleMedium, //.title / harfang
            ),
          ),
          new Container(
            padding: const EdgeInsets.symmetric(vertical: 10.0),
            constraints: const BoxConstraints(maxHeight: 200.0),
            child: new ListView.builder(
              scrollDirection: Axis.horizontal,
              itemCount: 7, // null safety  / harfang
              itemBuilder: _buildHorizontalChild,
            ),
          ),
          new Container(
            padding: const EdgeInsets.all(20.0),
            child: new Text(
              'Vertical scroll parallax',
              style: theme.textTheme.titleMedium, //.title / harfang
            ),
          ),
          new Expanded(
            child: new ListView.builder(
              itemCount: 7, // null safety / harfang
              itemBuilder: _buildVerticalChild,
            ),
          )
        ],
      ),
    );
  }

  Widget _buildVerticalChild(BuildContext context, int index) {
    index++;
    if (index > 7) return Container(); //  null safety / harfang
    return new Padding(
      padding: const EdgeInsets.only(bottom: 10.0),
      child: new GestureDetector(
        onTap: () {
          print('Tapped $index');
        },
        child: new ParallaxImage(
          extent: 150.0,
          image: new ExactAssetImage(
            'images/img$index.jpg',
          ),
        ),
      ),
    );
  }

  Widget _buildHorizontalChild(BuildContext context, int index) {
    index++;
    if (index > 7) return Container(); // null safety safety

    return new Padding(
      padding: const EdgeInsets.only(right: 10.0),
      child: new ParallaxImage(
        extent: 100.0,
        image: new ExactAssetImage(
          'images/img$index.jpg',
        ),
      ),
    );
  }
}
13
likes
130
points
91
downloads

Publisher

unverified uploader

Weekly Downloads

null safe safty correction. A Flutter widget that paints an image and moves it at a slower speed than the main scrolling content.

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on parallax_image_ns