Theme( // 覆盖accentColor为Colors.yellow data: Theme.of(context).copyWith(accentColor: Colors.yellow), child: FloatingActionButton( onPressed: null, child: Icon(Icons.add), ), );
Flutter 扩展父主题时无须覆盖所有的主题属性 copyWith
3 min read
Theme( // 覆盖accentColor为Colors.yellow data: Theme.of(context).copyWith(accentColor: Colors.yellow), child: FloatingActionButton( onPressed: null, child: Icon(Icons.add), ), );