我正在尝试创建这样的按钮。
以下是平面按钮代码。但是我没有得到想要的结果。
FlatButton(
padding: EdgeInsets.all(15),
color: Colors.orange,
textColor: Colors.white,
child: Text(
'NEXT',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
onPressed: () => _nextButtonTapped,
)
如何在平面按钮的背景中设置两种颜色?
答案 0 :(得分:1)
怎么样
import 'package:flutter/material.dart';
final 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 StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 50.0,
child: RaisedButton(
onPressed: () {},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(80.0)),
padding: EdgeInsets.all(0.0),
child: Ink(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [Colors.orange.shade100, Colors.orange.shade900],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.circular(30.0)
),
child: Container(
constraints: BoxConstraints(maxWidth: 100.0, minHeight: 50.0),
alignment: Alignment.center,
child: Text(
"Next",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white
),
),
),
),
),
);
}
}
答案 1 :(得分:1)