Flutter Share package causing not helpful error
I am trying to use the Share package provided by the Flutter team. I tried implementing the package and when that didn't work I tried straight up copying and pasting their code, but got an error just the same. Unfortunately the error is not very helpful and the description of the error says "we need to explain this better". Any ideas?
Here's the package I'm using
My Code:
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
The Error:
flutter: The following assertion was thrown while handling a gesture:
flutter: type 'RenderSliverList' is not a subtype of type 'RenderBox'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _EverythingState._buildEventCards.<anonymous closure> (package:loopt_in/widgets/everything.dart:175:43)
flutter: #1 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
flutter: #2 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
flutter: #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
flutter: #4 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
flutter: #5 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
flutter: #6 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
flutter: #7 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
flutter: #8 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
flutter: #9 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
flutter: #10 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
flutter: #11 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
flutter: #12 _invoke1 (dart:ui/hooks.dart:165:13)
flutter: #13 _dispatchPointerDataPacket (dart:ui/hooks.dart:119:5)
flutter: Handler: onTap
flutter: Recognizer:
flutter: TapGestureRecognizer#ecc56(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
flutter: Offset(196.0, 747.5), sent tap down)
Update
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
New Error Traceback
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:291:7)
<asynchronous suspension>
#1 Share.share (package:share/share.dart:44:20)
#2 ShareButton.build.<anonymous closure> (package:loopt_in/widgets/everything.dart:220:17)
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
dart flutter
add a comment |
I am trying to use the Share package provided by the Flutter team. I tried implementing the package and when that didn't work I tried straight up copying and pasting their code, but got an error just the same. Unfortunately the error is not very helpful and the description of the error says "we need to explain this better". Any ideas?
Here's the package I'm using
My Code:
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
The Error:
flutter: The following assertion was thrown while handling a gesture:
flutter: type 'RenderSliverList' is not a subtype of type 'RenderBox'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _EverythingState._buildEventCards.<anonymous closure> (package:loopt_in/widgets/everything.dart:175:43)
flutter: #1 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
flutter: #2 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
flutter: #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
flutter: #4 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
flutter: #5 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
flutter: #6 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
flutter: #7 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
flutter: #8 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
flutter: #9 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
flutter: #10 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
flutter: #11 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
flutter: #12 _invoke1 (dart:ui/hooks.dart:165:13)
flutter: #13 _dispatchPointerDataPacket (dart:ui/hooks.dart:119:5)
flutter: Handler: onTap
flutter: Recognizer:
flutter: TapGestureRecognizer#ecc56(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
flutter: Offset(196.0, 747.5), sent tap down)
Update
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
New Error Traceback
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:291:7)
<asynchronous suspension>
#1 Share.share (package:share/share.dart:44:20)
#2 ShareButton.build.<anonymous closure> (package:loopt_in/widgets/everything.dart:220:17)
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
dart flutter
This peace of code is working fine in both android and iOS I think the problem coming from somewhere else inside your code
– Saed Nabil
Nov 22 '18 at 4:52
@SaedNabil I will add the rest of my code to show
– Garrett
Nov 22 '18 at 19:02
I fixed the issue please check the Edit section
– Saed Nabil
Nov 23 '18 at 2:20
add a comment |
I am trying to use the Share package provided by the Flutter team. I tried implementing the package and when that didn't work I tried straight up copying and pasting their code, but got an error just the same. Unfortunately the error is not very helpful and the description of the error says "we need to explain this better". Any ideas?
Here's the package I'm using
My Code:
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
The Error:
flutter: The following assertion was thrown while handling a gesture:
flutter: type 'RenderSliverList' is not a subtype of type 'RenderBox'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _EverythingState._buildEventCards.<anonymous closure> (package:loopt_in/widgets/everything.dart:175:43)
flutter: #1 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
flutter: #2 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
flutter: #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
flutter: #4 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
flutter: #5 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
flutter: #6 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
flutter: #7 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
flutter: #8 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
flutter: #9 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
flutter: #10 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
flutter: #11 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
flutter: #12 _invoke1 (dart:ui/hooks.dart:165:13)
flutter: #13 _dispatchPointerDataPacket (dart:ui/hooks.dart:119:5)
flutter: Handler: onTap
flutter: Recognizer:
flutter: TapGestureRecognizer#ecc56(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
flutter: Offset(196.0, 747.5), sent tap down)
Update
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
New Error Traceback
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:291:7)
<asynchronous suspension>
#1 Share.share (package:share/share.dart:44:20)
#2 ShareButton.build.<anonymous closure> (package:loopt_in/widgets/everything.dart:220:17)
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
dart flutter
I am trying to use the Share package provided by the Flutter team. I tried implementing the package and when that didn't work I tried straight up copying and pasting their code, but got an error just the same. Unfortunately the error is not very helpful and the description of the error says "we need to explain this better". Any ideas?
Here's the package I'm using
My Code:
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
The Error:
flutter: The following assertion was thrown while handling a gesture:
flutter: type 'RenderSliverList' is not a subtype of type 'RenderBox'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _EverythingState._buildEventCards.<anonymous closure> (package:loopt_in/widgets/everything.dart:175:43)
flutter: #1 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
flutter: #2 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
flutter: #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
flutter: #4 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
flutter: #5 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
flutter: #6 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
flutter: #7 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
flutter: #8 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
flutter: #9 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
flutter: #10 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
flutter: #11 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
flutter: #12 _invoke1 (dart:ui/hooks.dart:165:13)
flutter: #13 _dispatchPointerDataPacket (dart:ui/hooks.dart:119:5)
flutter: Handler: onTap
flutter: Recognizer:
flutter: TapGestureRecognizer#ecc56(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
flutter: Offset(196.0, 747.5), sent tap down)
Update
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
New Error Traceback
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:291:7)
<asynchronous suspension>
#1 Share.share (package:share/share.dart:44:20)
#2 ShareButton.build.<anonymous closure> (package:loopt_in/widgets/everything.dart:220:17)
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
dart flutter
dart flutter
edited Nov 23 '18 at 3:34
Garrett
asked Nov 22 '18 at 0:27
GarrettGarrett
468421
468421
This peace of code is working fine in both android and iOS I think the problem coming from somewhere else inside your code
– Saed Nabil
Nov 22 '18 at 4:52
@SaedNabil I will add the rest of my code to show
– Garrett
Nov 22 '18 at 19:02
I fixed the issue please check the Edit section
– Saed Nabil
Nov 23 '18 at 2:20
add a comment |
This peace of code is working fine in both android and iOS I think the problem coming from somewhere else inside your code
– Saed Nabil
Nov 22 '18 at 4:52
@SaedNabil I will add the rest of my code to show
– Garrett
Nov 22 '18 at 19:02
I fixed the issue please check the Edit section
– Saed Nabil
Nov 23 '18 at 2:20
This peace of code is working fine in both android and iOS I think the problem coming from somewhere else inside your code
– Saed Nabil
Nov 22 '18 at 4:52
This peace of code is working fine in both android and iOS I think the problem coming from somewhere else inside your code
– Saed Nabil
Nov 22 '18 at 4:52
@SaedNabil I will add the rest of my code to show
– Garrett
Nov 22 '18 at 19:02
@SaedNabil I will add the rest of my code to show
– Garrett
Nov 22 '18 at 19:02
I fixed the issue please check the Edit section
– Saed Nabil
Nov 23 '18 at 2:20
I fixed the issue please check the Edit section
– Saed Nabil
Nov 23 '18 at 2:20
add a comment |
1 Answer
1
active
oldest
votes
The issue in this line
RenderBox box = context.findRenderObject();
the right side return RenderSliverList and you assigning it to RenderBox that why there is a mismatch type.
What excactly you are trying to share? so I can help with that
Edit:
You need to extract share button into its own widget. Try the following complete code. It works.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
new MyButton(),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
class MyButton extends StatelessWidget {
const MyButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422293%2fflutter-share-package-causing-not-helpful-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue in this line
RenderBox box = context.findRenderObject();
the right side return RenderSliverList and you assigning it to RenderBox that why there is a mismatch type.
What excactly you are trying to share? so I can help with that
Edit:
You need to extract share button into its own widget. Try the following complete code. It works.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
new MyButton(),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
class MyButton extends StatelessWidget {
const MyButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
|
show 2 more comments
The issue in this line
RenderBox box = context.findRenderObject();
the right side return RenderSliverList and you assigning it to RenderBox that why there is a mismatch type.
What excactly you are trying to share? so I can help with that
Edit:
You need to extract share button into its own widget. Try the following complete code. It works.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
new MyButton(),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
class MyButton extends StatelessWidget {
const MyButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
|
show 2 more comments
The issue in this line
RenderBox box = context.findRenderObject();
the right side return RenderSliverList and you assigning it to RenderBox that why there is a mismatch type.
What excactly you are trying to share? so I can help with that
Edit:
You need to extract share button into its own widget. Try the following complete code. It works.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
new MyButton(),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
class MyButton extends StatelessWidget {
const MyButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
The issue in this line
RenderBox box = context.findRenderObject();
the right side return RenderSliverList and you assigning it to RenderBox that why there is a mismatch type.
What excactly you are trying to share? so I can help with that
Edit:
You need to extract share button into its own widget. Try the following complete code. It works.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:share/share.dart';
class Everything extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EverythingState();
}
}
class _EverythingState extends State<Everything> {
Widget _buildEventCards(BuildContext context, DocumentSnapshot document) {
var width = MediaQuery.of(context).size.width;
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 14.0),
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Image.asset(
document['image'],
fit: BoxFit.cover,
),
Container(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
child: Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// Icon(document['icon']),
],
),
],
),
SizedBox(
height: 10.0,
),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: <Widget>[
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['date'],
),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(document['source']),
),
SizedBox(
width: 10.0,
),
Chip(
backgroundColor: Colors.grey[100],
label: Text(
document['location'],
),
),
],
),
SizedBox(
height: 15.0,
),
Container(
width: width,
child: Text(
document['title'],
style: TextStyle(fontSize: 24.0),
),
),
SizedBox(
height: 20.0,
),
Text(document['desc']),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
FlatButton(
child: Text(
'More',
style: TextStyle(
color: Color.fromRGBO(118, 190, 208, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
print('webview clicked');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebviewScaffold(
url: document['url'],
appBar: AppBar(
title: Text(document['source']),
backgroundColor: Color.fromRGBO(
135,
142,
136,
1.0,
),
),
),
),
);
},
),
SizedBox(
width: 15.0,
),
new MyButton(),
],
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
});
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// var bannerAd = _buildBanner()..load();
// }
}
class MyButton extends StatelessWidget {
const MyButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
edited Nov 27 '18 at 3:11
Pang
6,9891666105
6,9891666105
answered Nov 22 '18 at 22:39
Saed NabilSaed Nabil
1,303310
1,303310
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
|
show 2 more comments
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
I’m trying to allow users to share stuff via Facebook and Twitter
– Garrett
Nov 22 '18 at 22:53
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
what is this stuff ? what types ? where it come from in your widget tree
– Saed Nabil
Nov 22 '18 at 23:09
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
Thanks for the answer, however it gave me another error. I added the trace back to my question
– Garrett
Nov 23 '18 at 3:31
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
You need to stop the app and run it so it completely build
– Saed Nabil
Nov 23 '18 at 3:41
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
That worked thank you. Can you explain to me what you did?
– Garrett
Nov 23 '18 at 3:55
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422293%2fflutter-share-package-causing-not-helpful-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This peace of code is working fine in both android and iOS I think the problem coming from somewhere else inside your code
– Saed Nabil
Nov 22 '18 at 4:52
@SaedNabil I will add the rest of my code to show
– Garrett
Nov 22 '18 at 19:02
I fixed the issue please check the Edit section
– Saed Nabil
Nov 23 '18 at 2:20