Last active
January 12, 2022 16:27
-
-
Save Abhilash-Chandran/7f5573d328cffbdbdeaa6d918f1a26f3 to your computer and use it in GitHub Desktop.
Overflow Text button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: darkBlue, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatefulWidget { | |
@override | |
State<MyWidget> createState() => _MyWidgetState(); | |
} | |
class _MyWidgetState extends State<MyWidget> { | |
final _controller = TextEditingController(text: 'Small Text, make it big'); | |
var _buttonText = 'Small Text, make it big'; | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: [ | |
TextField( | |
controller: _controller, | |
onChanged: (val) { | |
setState(() { | |
_buttonText = val; | |
}); | |
}, | |
), | |
Align( | |
alignment: Alignment.centerRight, | |
child: Padding( | |
padding: const EdgeInsets.all(18.0), | |
child: TextButton( | |
style:TextButton.styleFrom(primary: Colors.amber,backgroundColor: Colors.white24), | |
child: Text( | |
_buttonText, | |
style: const TextStyle( | |
overflow: TextOverflow.ellipsis, | |
), | |
), | |
onPressed: () {}, | |
), | |
), | |
), | |
Align( | |
alignment: Alignment.centerRight, | |
child: FractionallySizedBox( | |
widthFactor: 0.25, | |
child: Padding( | |
padding: const EdgeInsets.all(18.0), | |
child: TextButton( | |
style:TextButton.styleFrom(primary: Colors.amber,backgroundColor: Colors.white24), | |
child: Text( | |
_buttonText, | |
style: const TextStyle( | |
overflow: TextOverflow.ellipsis, | |
), | |
), | |
onPressed: () {}, | |
), | |
), | |
), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment