Skip to content

Instantly share code, notes, and snippets.

@OnlyTarg
Last active December 13, 2021 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OnlyTarg/e4acaaa18939f6403d7a050009776760 to your computer and use it in GitHub Desktop.
Save OnlyTarg/e4acaaa18939f6403d7a050009776760 to your computer and use it in GitHub Desktop.
Tear-off constructor on flutter_app
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomeScreen(),
);
}
}
class MyHomeScreen extends StatelessWidget {
MyHomeScreen({Key? key}) : super(key: key);
final List<String> stringList = ['S1', 'S2', 'S3'];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Test App'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('S1'),
Text('S2'),
Text('S3'),
]
),
),
);
}
}
//stringList.map((String s)=>Text(s)).toList(),
//stringList.map(Text.new).toList(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment