Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@13k
Last active January 18, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 13k/3c6bb56d8751b4b610bb4ac136d5c3bb to your computer and use it in GitHub Desktop.
Save 13k/3c6bb56d8751b4b610bb4ac136d5c3bb to your computer and use it in GitHub Desktop.
Flutter in Go (https://divan.github.io/posts/flutter_go) - Functional options approach
func (m *MyHomePage) Build(ctx BuildContext) Widget {
return NewScaffold(
ScaffoldWithAppBar(
NewAppBar(
AppBarWithTitle(
NewTitle(
TitleWithText(NewText(TextWithText("My home page"))),
),
),
),
),
ScaffoldWithBody(
NewCenter(
CenterWithChild(
NewColumn(
ColumnWithMainAxisAlignment(MainAxisAlignment.center),
ColumnWithChildren(
[]Widget{
NewText(TextWithText("You have pushed the button this many times:")),
NewText(
TextWithText(fmt.Sprintf("%d", m.counter)),
TextWithStyle(ctx.textTheme.display1),
),
},
),
),
),
),
),
ScaffoldWithFloatingActionButton(
NewFloatingActionButton(
FloatingActionButtonWithOnPressed(m.incrementCounter),
FloatingActionButtonWithTooltip("Increment"),
FloatingActionButtonWithChild(
NewIcon(IconWithIcon(Icons.add)),
),
),
),
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment