I've already created one page route, to the feed_page
, but now, when going from feed_page
to new_post_page
, the new_post_page
is just blank on the simulated phone.
Here's the obligatory code dump :)
In this first code dump (page of origin), I omitted the other contents of the appBar
and the body
of the scaffold:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:we_rise/post_card.dart';
import 'new_post_page.dart';
import 'constants.dart';
class FeedPage extends StatefulWidget {
@override
_FeedPageState createState() => _FeedPageState();
}
class _FeedPageState extends State<FeedPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
...
),
actions: <Widget>[
// PAGE ROUTE IN QUESTION
IconButton(
icon: const Icon(Icons.add_circle),
onPressed: () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => NewPostPage()));
},
),
],
),
body: ListView.builder(
...
),
);
}
}
And then the problematic new page that is just showing up blank in the simulated phone:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'constants.dart';
class NewPostPage extends StatefulWidget {
@override
_NewPostPageState createState() => _NewPostPageState();
}
class _NewPostPageState extends State<NewPostPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xFFFFC033),
title: const Text('New Post'),
),
body: Expanded(
child: Column(
children: const <Widget>[
Text('Placeholder')
],
)
),
);
}
}
CodePudding user response:
Problem is in body, Remove Expanded widget from body only keep Column widget and Run, set as below.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'constants.dart';
class NewPostPage extends StatefulWidget {
@override
_NewPostPageState createState() => _NewPostPageState();
}
class _NewPostPageState extends State<NewPostPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xFFFFC033),
title: const Text('New Post'),
),
body: Column(
children: const <Widget>[
Text('Placeholder')
],
),
);
}
}
CodePudding user response:
Ex:
=> You are Remove Expanded Widigit
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'constants.dart';
class NewPostPage extends StatefulWidget {
@override
_NewPostPageState createState() => _NewPostPageState();
}
class _NewPostPageState extends State<NewPostPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xFFFFC033),
title: const Text('New Post'),
),
body: Column(
children: const <Widget>[
Text('Placeholder')
],
),
);
}
}