invalid_ widget_ preview_ private_ argument
                  '@Preview(...)' can only accept arguments that consist of literals and public symbols.
Description
#
                    The analyzer produces this diagnostic when the Preview constructor is
                    invoked with arguments that contain references to private symbols.
                  
Example
#
                    The following code produces this diagnostic because the constant variable
                    _name is private to the current library:
                  
import 'package:flutter/widgets.dart';
import 'package:flutter/widget_previews.dart';
const String _name = 'My Foo Preview';
@Preview(name: _name)
Widget myPreview() => Text('Foo');
                      
                      
                      
                    Common fixes
#If appropriate, the private symbol should be made public:
import 'package:flutter/widgets.dart';
import 'package:flutter/widget_previews.dart';
const String name = 'My Foo Preview';
@Preview(name: name)
Widget myPreview() => Text('Foo');
                      
                      
                      
                    Otherwise, a different public constant symbol should be used:
import 'package:flutter/widgets.dart';
import 'package:flutter/widget_previews.dart';
@Preview(name: 'My Foo Preview')
Widget myPreview() => Text('Foo');
                      
                      
                      
                    Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.