Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

Stack list of widgets timed flutter

import 'package:flutter/material.dart';
import 'dart:async';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  const MyHomePage({
    Key? key,
    required this.title,
  }) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late Timer _timer;
  List<Widget> history = [];
  int _counter = 0;

  void _updateHistory(Timer timer) {
    setState(() {
      _counter++;
      history.add(ListTile(title: Text(_counter.toString())));
    });
  }

  @override
  void initState() {
    super.initState();
    _timer = Timer.periodic(const Duration(seconds: 1), _updateHistory);
  }

  @override
  void dispose() {
    super.dispose();
    _timer.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: history,
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _counter = 0;
            history.clear();
          });
        },
        tooltip: 'Clear all',
        child: const Icon(Icons.clear_all),
      ),
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript different types support 
Typescript :: how to call a function in a macro with variadic arguments c++ 
Typescript :: Integer Which of the following can be described as the decision whether to obtain the necessary software from internal or external sources?and Development Environment meaning 
Typescript :: cluster on lists of values that start with a certain value 
Typescript :: reader.readasarraybuffer(file) is undefined 
Typescript :: Rails flags for tests assets and helpers 
Typescript :: code to check if a triangle is valid or not 
Typescript :: how to populate array in typescript 
Typescript :: Ionic toast animation 
Typescript :: deleting a comnent from arrays of comments in mongodb 
Typescript :: code solutions online for public IActionResult Student() { return View(Students Controller 1); } 
Typescript :: ts Template pattern 
Typescript :: post data 
Typescript :: why do we use #Email in angular with ngmodel 
Typescript :: jquery to typescript converter 
Typescript :: typescript check if value is in enum 
Typescript :: INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. 
Typescript :: Enter into postgresql database AS 
Typescript :: 2d array of strings and ints python 
Typescript :: unity destroy all objects with tag 
Cpp :: how to hide the console c++ 
Cpp :: how to include everything in c++ 
Cpp :: c++ generate random char 
Cpp :: c++ print colorful 
Cpp :: const iterator c++ 
Cpp :: input output c++ 
Cpp :: sum vector c++ 
Cpp :: convert set to vector c++ 
Cpp :: how to interface c++ in haxe 
Cpp :: penjanje 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =