But, every page in my app shows black screen when navigated to, I want to believe this is just a minor issue, any help on why am getting this black screens that once worked would be highly appreciated.
Thanks.
class HomeView extends StatefulWidget {
HomeView({Key key, this.title,this.user}) : super(key: key);
static String tag = 'home-page';
final User user;
final Object avatarTag=1;
final String title;
@override
Home createState() => Home();
}
class Home extends State<HomeView> {
// int _counter = 0;
static User _user;
final LatLng _center= const LatLng(45.521563,-122.677433);
RestDatasource datasource=new RestDatasource();
Future<User> user;
@override
void initState() {
super.initState();
user= datasource.getUser(context, RestDatasource.tokenResponse.accessToken, RestDatasource.tokenResponse.userName);
user.then((User user){
_user=user;
});
location.onLocationChanged().listen((location) async {
if(marker != null) {
mapController.removeMarker(marker);
}
marker = await mapController?.addMarker(MarkerOptions(
position: LatLng(location["latitude"], location["longitude"]),
));
mapController?.moveCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(
location["latitude"],
location["longitude"],
),
zoom: 20.0,
),
),
);
});
}
Future<Map<String, double>> _getLocation() async {
var currentLocation = <String, double>{};
try {
currentLocation = await location.getLocation();
} catch (e) {
currentLocation = null;
}
return currentLocation;
}
var location=new Location();
Map<String, double> userLocation;
GoogleMapController mapController;
Marker marker;
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var textTheme = theme.textTheme;
Widget _buildLocationInfo(TextTheme textTheme) {
return new Row(
children: <Widget>[
new Icon(
Icons.place,
color: Colors.blueAccent,
size: 16.0,
),
new Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
"Hello world",
style: textTheme.subhead.copyWith(color: Colors.blueAccent),
),
),
],
);
}
Widget _createCircleBadge(IconData iconData, Color color,String type) {
return new Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new FloatingActionButton(
child: new Icon(
iconData,
color: Colors.white,
size: 16.0,
),
onPressed: () {
if(type=="STREET_VIEW")
{
RestDatasource.prefsSave("MapType",type);
}
else if(type=="SATELLITE_VIEW")
{
RestDatasource.prefsSave("MapType",type);
}
else if(type=="TERRAIN_VIEW")
{
RestDatasource.prefsSave("MapType",type);
}
},
backgroundColor: Colors.deepPurple,
),
);
}
var linearGradient = const BoxDecoration(
gradient: const LinearGradient(
begin: FractionalOffset.centerRight,
end: FractionalOffset.bottomLeft,
colors: <Color>[Colors.white12, Colors.blueAccent]
// colors: <Color>[
// const Color(0xFF413070),
// const Color(0xFF2B264A),
// ],
),
);
return new Scaffold(
appBar:new AppBar(title: new Text("My App"),),
drawer: FlyoutMenu(),
body: new SingleChildScrollView(
child: new Container(
decoration: linearGradient,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new HomeHeader(
widget.user,
// avatarTag: widget.avatarTag,
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
"Samuel Kingsley",
style: textTheme.headline.copyWith(color: Colors.grey),
),
new Padding(
padding: const EdgeInsets.only(top: 4.0),
child: _buildLocationInfo(textTheme),
),
new Padding(
padding: const EdgeInsets.only(top: 16.0),
child: new Text(RestDatasource.tokenResponse.userName,
style:
textTheme.body1.copyWith(color: Colors.grey, fontSize: 16.0),
),
),
new Padding(
padding: const EdgeInsets.only(top: 16.0),
child: new Row(
children: <Widget>[
_createCircleBadge(Icons.streetview, Colors.white,"STREET_VIEW"),
_createCircleBadge(Icons.terrain, Colors.deepPurple,"TERRAIN_VIEW"),
_createCircleBadge(Icons.satellite, Colors.deepPurple,"SATELLITE_VIEW"),
],
),
),
new SizedBox.fromSize(
size: const Size.fromHeight(300.0),
child: Card(
child: GoogleMap(
onMapCreated: (GoogleMapController controller) {
mapController = controller;
mapController.addMarker(
MarkerOptions(
position:LatLng(
mapController.cameraPosition.target.latitude,
mapController.cameraPosition.target.longitude,),
infoWindowText: InfoWindowText("Random place","5 star rating"),
icon: BitmapDescriptor.defaultMarker
)
);
},
options: GoogleMapOptions(
cameraPosition: CameraPosition(
target: _center,
zoom: 11.0
),
myLocationEnabled: true,
trackCameraPosition: true,
compassEnabled: true,
zoomGesturesEnabled: true,
),)
),),
new HomeFooter(user:widget.user),
],
),
]),
),
)
);
}
}
...........
class HomeHeader extends StatelessWidget {
static const BACKGROUND_IMAGE = 'assets/images/mountains.jpg';
HomeHeader(this.user);
final User user;
// final Object avatarTag;
Widget _buildDiagonalImageBackground(BuildContext context) {
var screenWidth = MediaQuery.of(context).size.width;
return new DiagonallyCutColoredImage(
new Image.asset(
BACKGROUND_IMAGE,
width: screenWidth,
height: 280.0,
fit: BoxFit.cover,
),
color: Colors.blueAccent
// color: const Color(0xBB8338f4),
);
}
Widget _buildAvatar() {
// return new Hero(
// tag: avatarTag,
return new CircleAvatar(
// backgroundImage: new NetworkImage(user.imageUrl),
radius: 50.0,
);
// );
}
Widget _buildFollowerInfo(TextTheme textTheme) {
var followerStyle =
textTheme.subhead.copyWith(color: const Color(0xBBFFFFFF));
return new Padding(
padding: const EdgeInsets.only(top: 16.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text('90 Tracking', style: followerStyle),
new Text(
' | ',
style: followerStyle.copyWith(
fontSize: 24.0, fontWeight: FontWeight.normal),
),
new Text('100 Trackers', style: followerStyle),
],
),
);
}
Widget _buildActionButtons(ThemeData theme) {
return new Padding(
padding: const EdgeInsets.only(
top: 16.0,
left: 16.0,
right: 16.0,
),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
_createPillButton(
'BUZZ ME',
backgroundColor:Colors.orangeAccent
),
new DecoratedBox(
decoration: new BoxDecoration(
border: new Border.all(color: Colors.white30),
borderRadius: new BorderRadius.circular(30.0),
),
child: _createPillButton(
'CALL ME',
textColor: Colors.white70,
),
),
],
),
);
}
Widget _createPillButton(
String text, {
Color backgroundColor = Colors.transparent,
Color textColor = Colors.white70,
}) {
return new ClipRRect(
borderRadius: new BorderRadius.circular(30.0),
child: new RaisedButton(
// minWidth: 140.0,
color: backgroundColor,
textColor: textColor,
onPressed: () {},
child: new Text(text),
),
);
}
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var textTheme = theme.textTheme;
return new Stack(
children: <Widget>[
_buildDiagonalImageBackground(context),
new Align(
alignment: FractionalOffset.bottomCenter,
heightFactor: 1.4,
child: new Column(
children: <Widget>[
_buildAvatar(),
_buildFollowerInfo(textTheme),
_buildActionButtons(theme),
],
),
),
],
);
}
}
--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.