Widget build()

in packages/diagrams/lib/src/theme_data.dart [29:131]


  Widget build(BuildContext context) {
    late Widget returnWidget;

    switch (name) {
      case _themeData:
        returnWidget = ConstrainedBox(
          key: UniqueKey(),
          constraints: BoxConstraints.tight(const Size(150.0, 150.0)),
          child: Container(
            padding: const EdgeInsets.all(5.0),
            color: Colors.white,
            child: Center(
              child: Theme(
                data: ThemeData(primaryColor: Colors.blue),
                child: Builder(
                  builder: (BuildContext context) {
                    return Container(
                      width: 100,
                      height: 100,
                      color: Theme.of(context).primaryColor,
                    );
                  },
                ),
              ),
            ),
          ),
        );
        break;
      case _materialAppThemeData:
        returnWidget = ConstrainedBox(
          key: UniqueKey(),
          constraints: BoxConstraints.tight(const Size(420, 533)),
          child: Container(
            padding: const EdgeInsets.only(right: 120),
            color: Colors.white,
            child: Center(
              child: MaterialApp(
                debugShowCheckedModeBanner: false,
                theme: ThemeData(
                  colorScheme: ColorScheme.fromSwatch(
                    primarySwatch: Colors.blue,
                  ).copyWith(
                    secondary: Colors.green,
                  ),
                  textTheme: const TextTheme(
                      bodyText2: TextStyle(color: Colors.purple)),
                ),
                home: Stack(
                  children: <Widget>[
                    Positioned.fill(
                      child: Scaffold(
                        key: _heroKey,
                        appBar: AppBar(
                          key: _appBarKey,
                          title: const Text('ThemeData Demo'),
                        ),
                        floatingActionButton: FloatingActionButton(
                          child: const Icon(Icons.add),
                          onPressed: () {},
                          key: _fabKey,
                        ),
                        body: Center(
                          child: Text(
                            'Button pressed 0 times',
                            key: _bodyKey,
                          ),
                        ),
                      ),
                    ),
                    Positioned.fill(
                      child: LabelPainterWidget(
                        key: _canvasKey,
                        heroKey: _heroKey,
                        labels: <Label>[
                          Label(
                            _appBarKey,
                            ' primaryColor',
                            const FractionalOffset(0.9, 0.6),
                          ),
                          Label(
                            _bodyKey,
                            ' bodyText2',
                            const FractionalOffset(1.1, 0.5),
                          ),
                          Label(
                            _fabKey,
                            ' accentColor',
                            const FractionalOffset(0.8, 0.5),
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
        );
        break;
    }

    return returnWidget;
  }