Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving a list of widgets throws findRenderObject was called on null exception. #32

Closed
tehsunnliu opened this issue Jan 25, 2021 · 7 comments

Comments

@tehsunnliu
Copy link

I have a list of items in
ListView(), not ListView.builder(). And in the ListView each child is wrapped with Screenshot widget.
When the ListView is built I store the Screenshot controller for each widget in a list.
When trying to capture only the first widget gets captured and then I get this exception

/flutter ( 2557): Caught error: NoSuchMethodError: The method 'findRenderObject' was called on null.
I/flutter ( 2557): Receiver: null
I/flutter ( 2557): Tried calling: findRenderObject()
I/flutter ( 2557): #0      ScreenshotController.capture.<anonymous closure>
package:screenshot/screenshot.dart:41
I/flutter ( 2557): #1      new Future.delayed.<anonymous closure> (dart:async/future.dart:326:39)
I/flutter ( 2557): #2      _rootRun (dart:async/zone.dart:1182:47)
I/flutter ( 2557): #3      _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter ( 2557): #4      _CustomZone.runGuarded (dart:async/zone.dart:997:7)
I/flutter ( 2557): #5      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
I/flutter ( 2557): #6      _rootRun (dart:async/zone.dart:1190:13)
I/flutter ( 2557): #7      _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter ( 2557): #8      _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
I/flutter ( 2557): #9      Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
I/flutter ( 2557): #10     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
I/flutter ( 2557): #11     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
I/flutter ( 2557): #12     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

@callmejm
Copy link

callmejm commented Feb 4, 2021

same +1

@yogi0823
Copy link

Screenshot(
controller: screenshotController,
child: Component(),
),

wrapp your widget with Screenshot()

@ritheshSalyan
Copy link
Collaborator

@tehsunnliu how exactly do you need? do you want to take a screenshot of the entire list at once like this? or
screenshot of individual elements on some event like this?

@tehsunnliu
Copy link
Author

Hi, I wanted to capture individual elements in the listview, I wrapped ewach element in the listview with Screenshot widget but it doesn't work. I get same error as mentioned earlier.
Since in my case the listview won't contain many elements I chose not to use listview and created a column with the elements. This way I was able to take screenshots of each element individually.

@BhavyKoshti9spl
Copy link

created list view like this :

ListView.separated( shrinkWrap: false, itemBuilder: (context, position) => getPost(position), separatorBuilder: (context, position) { return Container( height: 4, color: Colors.transparent, ); }, scrollDirection: Axis.vertical, controller: _scrollController, itemCount: feedList.length, )

and i wrapped each item with screenshot with different controller each time , actually i take one var in list and assigned controller to it if its null so this way every item has its different controller and while i am trying to capture it it gives me error like above

the same way i did this in different page and working file i couldn't find any difference in it ,

in my list there are too many items so i can't put columns there.

@BhavyKoshti9spl
Copy link

any updates ? @SachinGanesh

@stevendz
Copy link

stevendz commented Feb 19, 2021

Had the same problem, I guess the easiest way is replacing the ListView with a SingleChildScrollView and a Column, you will lose the lazy loading but the screenshots will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants