Widget build()

in packages/sampler/lib/detail_view.dart [82:166]


  Widget build(BuildContext context) {
    if (Model.instance.currentSample == null) {
      return const Scaffold(
          body: Center(child: Text('Working sample not set.')));
    }
    final CodeSample sample = Model.instance.currentSample!;
    final String filename = sample.start.file != null
        ? path.relative(sample.start.file!.path,
            from: Model.instance.flutterRoot.path)
        : '<generated>';
    return Scaffold(
      appBar: AppBar(
        title: Text('${sample.element} - $filename:${sample.start.line}'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: DefaultTabController(
          initialIndex: 0,
          length: 2,
          child: Column(
            children: <Widget>[
              DataLabel(label: 'Type of sample:', data: sample.type),
              DataLabel(
                  label: 'Sample is attached to:',
                  data:
                      '${sample.element} starting at line ${sample.start.line}'),
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: CodePanel(
                      code: sample.inputAsString,
                      color: Colors.deepPurple.shade50),
                ),
              ),
              ActionPanel(
                isBusy: exporting,
                children: <Widget>[
                  if (!exporting)
                    TextButton(
                        child: Tooltip(
                          message:
                              'Extract a sample from the Flutter source file',
                          child: Text(
                            project == null
                                ? 'EXTRACT SAMPLE'
                                : 'RE-EXTRACT SAMPLE',
                          ),
                        ),
                        onPressed: _extractSample),
                  if (project != null && !exporting)
                    OutputLocation(
                      location: project!.location,
                      file: project!.location
                          .childDirectory('lib')
                          .childFile('main.dart'),
                    ),
                ],
              ),
              ActionPanel(
                isBusy: importing,
                children: <Widget>[
                  TextButton(
                      child: const Tooltip(
                        message:
                            'Reinsert extracted, edited sample into the Flutter source file',
                        child: Text('REINSERT'),
                      ),
                      onPressed: project != null && !exporting && !importing
                          ? () => _reinsertIntoFrameworkFile(context)
                          : null),
                  const Spacer(),
                  if (sample.start.file != null)
                    OutputLocation(
                      location: FlutterInformation.instance.getFlutterRoot(),
                      file: sample.start.file!.absolute,
                      startLine: sample.start.line,
                    ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }