Apple restricts a lot of app access to battery data. Most apps I've seen simply take your current battery percentage and multiply it with the maximum Apple states each activity can go. These are not very accurate as your usage can change dramatically in minutes.
E.G. Texting -> taking a picture -> streaming a movie
Checking your widget will not be accurate as it will constantly recalculate your usage.