Flutter - Error in PageView, parameters doesn´t exist

I´m trying to create a simple PageView in Flutter 1.5. Code look similar to:

import 'package:flutter/material.dart';
import 'package:datameter/screens/configuration/form/partials/form_page.dart';

class PageView extends AnimatedWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        controller: PageController(
          initialPage: 1,
          viewportFraction: 0.8,
        ),
        scrollDirection: Axis.vertical,
        children: [
          FormPageScreen,
          Container(
              margin: EdgeInsets.symmetric(
                horizontal: 10.0,
              ),
              color: Colors.purpleAccent),
          Container(
              margin: EdgeInsets.symmetric(
                horizontal: 10.0,
              ),
              color: Colors.greenAccent)
        ],
      ),
    );
  }
}

Multiple errors appear:

  1. The named parameter controller isn´t defined.
  2. The named parameter scrollDirection isn´t defined.
  3. The named parameter children isn´t defined.

So, what's wrong in the code?

QUESTION UPDATE

import 'package:flutter/material.dart';
import 'package:datameter/screens/configuration/form/partials/slider/partials/form_page.dart';

class PageViewPage extends AnimatedWidget {
  final double latitude;
  final double longitude;

  final String aliasValue;
  final String datameterValue;
  final String contadorModelValue;
  final String contadorFabricanteValue;
  final String contadorValue;
  final String instalation;
  final String otherFabricante;
  final String otherModelo;
  final List arrayDatos;

  PageViewPage(
      {Key key,
      this.instalation,
      this.latitude,
      this.longitude,
      this.aliasValue,
      this.datameterValue,
      this.contadorModelValue,
      this.contadorFabricanteValue,
      this.contadorValue,
      this.otherFabricante,
      this.arrayDatos,
      this.otherModelo})
      : super(key: key); //HERE A WARNING APPEAR: LISTENABLE IS REQUIRED

  final controller = PageController(
    initialPage: 1,
    viewportFraction: 0.8,
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: PageView(
      controller: controller,
      scrollDirection: Axis.vertical,
      children: <Widget>[
        FormPageScreen(),
        Container(color: Colors.red),
        Container(color: Colors.blue)
      ],
    ));
  }
}

Now the error is "listenable" is required. Any idea? I think is

1 answer

  • answered 2019-05-21 07:35 Sami Kanafani

    you can't name your class PageView, try the following:

    class PageViewAnimated extends AnimatedWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: PageView(
            controller: PageController(
              initialPage: 1,
              viewportFraction: 0.8,
            ),
            scrollDirection: Axis.vertical,
            children: <Widget>[
              FormPageScreen(),
              Container(
                  margin: EdgeInsets.symmetric(
                    horizontal: 10.0,
                  ),
                  color: Colors.purpleAccent),
              Container(
                  margin: EdgeInsets.symmetric(
                    horizontal: 10.0,
                  ),
                  color: Colors.greenAccent)
            ],
          )
        );
      }
    }