FlatButton中的两种颜色

时间:2020-02-12 06:10:42

标签: flutter dart

我正在尝试创建这样的按钮。

enter image description here

以下是平面按钮代码。但是我没有得到想要的结果。

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,
          )

如何在平面按钮的背景中设置两种颜色?

2 个答案:

答案 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
          ),
        ),
      ),
    ),
  ),
);
  }
}

https://dartpad.dev/d0d9fdb6cd8bc07a78056aad05e2199d

答案 1 :(得分:1)

具有启动效果的示例代码。

$file_url = $_GET['link'];           // http://www.somedomain.com/test.mp4
header('Content-Type: video/mp4'); 
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\""); 
readfile($file_url);

给出

sample