Combine Concat Two Strings
Complete Code For Combine Concat Two Strings In Flutter
main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
title: Text("String Concat in Dart"),
),
body: SafeArea(
child : Center(
child:NextWidget(),
)
)
),
);
}
}
class NextWidget extends StatefulWidget {
@override
StateNextWidget createState() => StateNextWidget();
}
class StateNextWidget extends State<NextWidget> {
String one = 'Hello';
String two = 'Guys';
String three ;
void join(){
setState(() {
three = one + ' ' + two ;
});
}
Widget build(BuildContext context) {
return Center(child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('$three', style: TextStyle(fontSize: 24),),
RaisedButton(
child: Text('Combine Two Strings on Button Press'),
onPressed: join,
color: Colors.green,
textColor: Colors.white,
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
),
],
));
}
}