Uchenna Ndukwe
Uchenna Ndukwe

Reputation: 71

Trying to add a PageView

please i am trying to add a pageview. i dont know how cos i tried but its not working. i feel i did something wrong by the way i placed this code:

    import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class HomeView extends StatefulWidget {
  @override
  _HomeViewState createState() => _HomeViewState();
}

class _HomeViewState extends State<HomeView> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffede7e6),
      body: Container(
        padding: EdgeInsets.symmetric(vertical: Platform.isIOS? 60: 50, horizontal: 50),
        child: Column(
          children: <Widget>[
            Text(
              "Select",
              style: TextStyle(
                fontSize: 28
              ),
            ),
            Text(
              "Coffee",
              style: TextStyle(
                fontSize: 30,
                fontWeight: FontWeight.w800
              ),
            )
          ],
        ),
      )
    );
  }
}

Please help me create the pageview or show me how please thank you.

Upvotes: 0

Views: 43

Answers (1)

CommonMind
CommonMind

Reputation: 198

I tried your code, it actually works fine when you wrap it in a MaterialApp:

import 'dart:io';

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeView(),
    );
  }
}

class HomeView extends StatefulWidget {
  @override
  _HomeViewState createState() => _HomeViewState();
}

class _HomeViewState extends State<HomeView> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffede7e6),
      body: Container(
        padding: EdgeInsets.symmetric(
            vertical: Platform.isIOS ? 60 : 50, horizontal: 50),
        child: Column(
          children: <Widget>[
            Text(
              "Select",
              style: TextStyle(fontSize: 28),
            ),
            Text(
              "Coffee",
              style: TextStyle(fontSize: 30, fontWeight: FontWeight.w800),
            )
          ],
        ),
      ),
    );
  }
}

Could you elaborate your problem?

Upvotes: 1

Related Questions