Untitled
unknown
dart
a year ago
1.7 kB
3
Indexable
Never
import 'package:flutter/material.dart'; import 'package:flutter_basics/practice2/Widget/rounded_button.dart'; import 'package:flutter_basics/ui_helper/util.dart'; class button extends StatelessWidget { const button({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Container( width: 100, child: RoundedButton( name: 'log in', icon: Icon(Icons.lock), callback: (){ print('Logged in'); }, textStyle: myTestStyle16(), ), ), ) ); } } import 'package:flutter/material.dart'; class RoundedButton extends StatelessWidget { final String name; final Color? bgColor; final Icon? icon; final TextStyle? textStyle; final VoidCallback? callback; RoundedButton({ required this.name, this.bgColor=Colors.blue, this.icon, this.textStyle, this.callback } ); @override Widget build(BuildContext context) { return ElevatedButton(onPressed: (){ callback!(); }, child: icon!=null ? Row( children: [ icon!, Text('name',style: textStyle,) ], ): Text('name',style: textStyle,), style: ElevatedButton.styleFrom( backgroundColor: bgColor, shadowColor: bgColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(11), bottomRight: Radius.circular(11), bottomLeft: Radius.circular(11), topRight: Radius.circular(11) ) ) ), ); } }