Search
 
SCRIPT & CODE EXAMPLE
 

DART

how to update listview in flutter

// Assuming you've extended the StatefulWidget, you must call setState 
// everytime you change the state. Ex:

setState(() { propList.add('text'); });

// Quick Example

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) => MaterialApp(home: MyList());
}

class MyList extends StatefulWidget {
  @override
  _MyListState createState() => _MyListState();
}

class _MyListState extends State<MyList> {
  List<String> propList = [];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My List'),
      ),
      body: ListView.builder(
        itemCount: propList.length,
        scrollDirection: Axis.horizontal,
        shrinkWrap: true,
        itemBuilder: (context,index)=> Text(propList[index]),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => setState(() => propList.add('text')),
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: AudioPlayerState.Playing flutter 
Dart :: difference between hot reload and hot restart in flutter 
Dart :: select an item woth index list dart 
Dart :: flutter mouse paralax 
Dart :: ruby on rails db migrate 
Dart :: how to effect container radius to children flutter 
Dart :: flutter getit short 
Dart :: flutter add checkbox 
Dart :: hive dart type adapter 
Dart :: geturedetector flutter 
Dart :: how to groupby list of maps in flutter 
Dart :: dart map list to map 
Dart :: arrow upwars button flutter 
Dart :: extract common elements from lists dart 
Dart :: package:grpc/grpc.dart import target uri doesnt exist 
Dart :: flutter image size percentage 
Swift :: swift ui open link in browser 
Swift :: swift generate uuid 
Swift :: Unique device id ios swift 
Swift :: stackoverflow get firbas analytics in ios 
Swift :: get request swift 
Swift :: ionic Library not found for -lGoogleToolboxForMac 
Swift :: how to play a video in swift 
Swift :: swift create array from range 
Swift :: swift reload tableview 
Swift :: swift center label 
Swift :: swift hex color 
Swift :: uibutton swift set title color 
Swift :: swift get current hour 
Swift :: hello world in swift 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =