Dart/flutter how to change the timer inside periodic after every time


I'm making a custom logic for showing ads in my app, so when the user opens the app after 1 min pops up an ad then supposed this 1 min to get increased by 1 min every time, So x be 2 then 3 then 4 ...etc.

I tried to do so, but didn't work for me ( showing the ad every 1 min not increase it );

<pre class="lang-dart prettyprint-override">int x = 1; Timer.periodic(Duration(minutes: x), (timer) { x = x + 1; interstitialAd.load(); });

I think you cannot do it. You can alternatively cancel the current timer and start a new timer based on conditions. Check the following pseudo-code

<pre class="lang-dart prettyprint-override"> Timer.periodic(Duration(minutes: 5), (timer) { if(condition){ timer.cancel(); createNewPeriodicTask(); } // task code });



  • How to use column value as column name?
  • Recommended CORS Allow and Expose Headers
  • Getting java.lang.RuntimeException while starting an activity
  • ggplot2 - annotate text with superscript
  • Indexing views with a CTE
  • Vue.js. Which better to use event bus or storage?
  • Angular5 Custom Validators for Reactive forms
  • Mongoose query to exclude a value from the result
  • Parsing proprietary tag syntax with regex - how to detect nested tags?
  • TYPO3 distribution.png issue when posting images
  • How to show only a substring of an item in a ComboBox in C#
  • Shared Forms Auth cookie not working on subdomain
  • Reuse jQuery object from an iframe?
  • Is the Windows App Store required for a UWP application?
  • PostgreSQL in Docker - pg_hba.conf to allow access from host to container
  • Preventing duplicate slashes in file paths in R
  • The output is not displayed in its entirety [8086 assembly]
  • How do decorators in es6 work?
  • How to customize marker colors and shapes in scatter plot?
  • Keep node's X and Z axes parallel to ground while rotating Y axis to face camera
  • Raphael-GWT: fill image of a shape (Rect) appears offset. How to resolve this?
  • getting the values of checkboxes in a checkboxlist control
  • How to add ng-app after page load?
  • Problems with special characters in php soap client
  • jQuery YQL SELECT FROM rss variable
  • No Gradle file syntax highlighting in Eclipse Mars.2
  • internal javascript not works in angular2
  • playing mp3 from nsbundle
  • Creating 2d platforms using JavaScript
  • How to write seo friendly url's using htaccess?
  • Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?
  • JQuery: Infinite input select
  • reshape/remould data frame to create normalized bar chart and pie chart
  • Google App Engine Datastore: Dealing with eventual consistency
  • Google App Engine backend servlet not responding
  • Make checkout phone field optional for specific countries in WooCommerce
  • Excel VBA : conditional formatting of sheet1 cells from sheet2 values in excel 2007
  • Accessing Arguments, Workflow Variables from custom activities
  • ReferenceError: TextEncoder is not defined
  • How to check if object is null in Java?