Copy List Into Another List
Complete Code For Copy List Into Another List In Flutter
main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
List<int> intList = [1, 2, 3, 4,];
var stringList = ['Apple', 'Bananaa', 'Orange','Mango',];
void copyList() {
List<int> newList_1 = List.from(intList);
var newList_2 = List.from(stringList);
print(newList_1);
print(newList_2);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.fromLTRB(20, 10, 20, 10),
child:
RaisedButton(
onPressed: () => copyList(),
child: Text('Copy List Into Another List'),
textColor: Colors.white,
color: Colors.pink,
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
)
),
])
)
)
);
}
}