我会在最高级别使用ClipRRect:
以下是完整示例:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: MyHomePage(title: 'Flutter Demo Home Page')),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Something")),
body: Container(alignment: Alignment.center, color: Colors.blue, child: Text("hello")));
}
}
这是最终结果:
也许你会想将半径从20减小到8,以使结果与你提供的图片类似。