Skip to content

Instantly share code, notes, and snippets.

@Abhilash-Chandran
Last active January 12, 2022 16:27
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 Abhilash-Chandran/7f5573d328cffbdbdeaa6d918f1a26f3 to your computer and use it in GitHub Desktop.
Save Abhilash-Chandran/7f5573d328cffbdbdeaa6d918f1a26f3 to your computer and use it in GitHub Desktop.
Overflow Text button
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