Flutter Dart Calculate Find Cube or N Power of Exponent Example

In Flutter the ‘dart:math’ library contains most of mathematical functions. One of them is pow() method. The pow() function returns Returns x to the power of given exponent. Using this we can find Square, Cube and all the mathematical exponent related calculations. All we have to do is pass the Number and exponent and it will return us the calculated result. So in this tutorial we would Flutter Dart Calculate Find Cube or N Power of Exponent Example.

Contents in this project Flutter Dart Calculate Find Cube or N Power of Exponent Example:

1. Open your project’s main.dart file and import material.dart and dart:math package.

2. Creating our main Void main runApp() method and here we would call our main MyApp class.

3. Creating our main class MyApp extends StatelessWidget. This is our Root class.

4. Creating a Double variable named as A with 9 value. We would also make a variable named as B with empty value.

5. Creating a function named as findSquareRoot(). In this function we would call the pow() inbuilt method and pass both arguments. We would also print the Cube on Terminal screen. To read more about this function please go check out Flutter Dart official page.

6. Creating Widget Build area and we would make a Raised Button widget. We would call the findSquareRoot() function on button onPress event.

7. Complete source code for main.dart file:

Screenshots:

Leave a Reply

Your email address will not be published. Required fields are marked *