Search
 
SCRIPT & CODE EXAMPLE
 

DART

ordered/numbered list in flutter

class OrderedList extends StatelessWidget {
  OrderedList(this.texts);
  final List<dynamic> texts;

  @override
  Widget build(BuildContext context) {
    var widgetList = <Widget>[];
    int counter = 0;
    for (var text in texts) {
      // Add list item
      counter++;
      widgetList.add(OrderedListItem(counter, text));
      // Add space between items
      widgetList.add(SizedBox(height: 5.0));
    }

    return Column(children: widgetList);
  }
}

class OrderedListItem extends StatelessWidget {
  OrderedListItem(this.counter, this.text);
  final int counter;
  final String text;

  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text("$counter. "),
        Expanded(
          child: Text(text),
        ),
      ],
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: dart format print 
Dart :: dart initialize array 
Dart :: * In pubspec.yaml the flutter.plugin.{androidPackage,iosPrefix,pluginClass} keys are deprecated. Instead use the flutter.plugin.platforms key introduced in Flutter 1.10.0 
Dart :: showing ads every x seconds flutter 
Dart :: dart list of lists 
Dart :: flutter main.dart example 
Dart :: flutter padding symmetric 
Dart :: custom icon flutter 
Dart :: cascade notation 
Swift :: How to convert radians to degrees swift ui 
Swift :: swift ui int to binary 
Swift :: swift share with 
Swift :: hide status bar ios 
Swift :: playing a sound in swift 
Swift :: get hours difference between two dates swift 
Swift :: swift 5 func to increase number every time call 
Swift :: swift get top constraint 
Swift :: how to get rid of excess space in swift 
Swift :: prevent iphone to sleep swift 
Swift :: swiftui full screen sheet 
Swift :: swift qrcode scanner 
Swift :: change the title of a button using Swift 
Swift :: NumberFormatter swift 
Swift :: Swift Swift continue statement with nested loops 
Swift :: How to hide view in swiftui 
Swift :: navigationBarTitle text size swiftui 
Swift :: how to make text selectable swiftui 
Swift :: Swift Character Example 
Swift :: float vs double in swift 
Swift :: Swift Named Tuples 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =